Update bindings
[ldk-java] / ts / bindings.c
1 #include <rust_types.h>
2 #include "js-wasm.h"
3 #include <stdatomic.h>
4 #include <lightning.h>
5
6 // These should be provided...somehow...
7 void *memset(void *s, int c, size_t n);
8 void *memcpy(void *dest, const void *src, size_t n);
9 int memcmp(const void *s1, const void *s2, size_t n);
10
11 void __attribute__((noreturn)) abort(void);
12 static inline void assert(bool expression) {
13         if (!expression) { abort(); }
14 }
15
16 void *malloc(size_t size);
17 void free(void *ptr);
18
19 #define MALLOC(a, _) malloc(a)
20 #define FREE(p) if ((long)(p) > 1024) { free(p); }
21 #define DO_ASSERT(a) (void)(a)
22 #define CHECK(a)
23
24 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
25 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
26 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
27 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
28
29 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
30
31 typedef uint32_t int64_tArray;
32 typedef uint32_t int8_tArray;
33 typedef uint32_t uint32_tArray;
34 typedef uint32_t ptrArray;
35 typedef uint32_t jstring;
36
37 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
38         uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
39         elems[0] = arr_len;
40         return (uint32_t)elems;
41 }
42
43 jstring str_ref_to_ts(const char* chars, size_t len) {
44         char* err_buf = MALLOC(len + 4, "str conv buf");
45         *((uint32_t*)err_buf) = len;
46         memcpy(err_buf + 4, chars, len);
47         return (uint32_t) err_buf;
48 }
49
50 typedef bool jboolean;
51
52 uint32_t __attribute__((visibility("default"))) TS_malloc(uint32_t size) {
53         return (uint32_t)MALLOC(size, "JS-Called malloc");
54 }
55 void __attribute__((visibility("default"))) TS_free(uint32_t ptr) {
56         FREE((void*)ptr);
57 }
58 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
59 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
60         switch (ord) {
61                 case 0: return LDKAccessError_UnknownChain;
62                 case 1: return LDKAccessError_UnknownTx;
63         }
64         abort();
65 }
66 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
67         switch (val) {
68                 case LDKAccessError_UnknownChain: return 0;
69                 case LDKAccessError_UnknownTx: return 1;
70                 default: abort();
71         }
72 }
73 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
74         switch (ord) {
75                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
76                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
77         }
78         abort();
79 }
80 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
81         switch (val) {
82                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
83                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
84                 default: abort();
85         }
86 }
87 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
88         switch (ord) {
89                 case 0: return LDKConfirmationTarget_Background;
90                 case 1: return LDKConfirmationTarget_Normal;
91                 case 2: return LDKConfirmationTarget_HighPriority;
92         }
93         abort();
94 }
95 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
96         switch (val) {
97                 case LDKConfirmationTarget_Background: return 0;
98                 case LDKConfirmationTarget_Normal: return 1;
99                 case LDKConfirmationTarget_HighPriority: return 2;
100                 default: abort();
101         }
102 }
103 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
104         switch (ord) {
105                 case 0: return LDKLevel_Off;
106                 case 1: return LDKLevel_Error;
107                 case 2: return LDKLevel_Warn;
108                 case 3: return LDKLevel_Info;
109                 case 4: return LDKLevel_Debug;
110                 case 5: return LDKLevel_Trace;
111         }
112         abort();
113 }
114 static inline int32_t LDKLevel_to_js(LDKLevel val) {
115         switch (val) {
116                 case LDKLevel_Off: return 0;
117                 case LDKLevel_Error: return 1;
118                 case LDKLevel_Warn: return 2;
119                 case LDKLevel_Info: return 3;
120                 case LDKLevel_Debug: return 4;
121                 case LDKLevel_Trace: return 5;
122                 default: abort();
123         }
124 }
125 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
126         switch (ord) {
127                 case 0: return LDKNetwork_Bitcoin;
128                 case 1: return LDKNetwork_Testnet;
129                 case 2: return LDKNetwork_Regtest;
130         }
131         abort();
132 }
133 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
134         switch (val) {
135                 case LDKNetwork_Bitcoin: return 0;
136                 case LDKNetwork_Testnet: return 1;
137                 case LDKNetwork_Regtest: return 2;
138                 default: abort();
139         }
140 }
141 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
142         switch (ord) {
143                 case 0: return LDKSecp256k1Error_IncorrectSignature;
144                 case 1: return LDKSecp256k1Error_InvalidMessage;
145                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
146                 case 3: return LDKSecp256k1Error_InvalidSignature;
147                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
148                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
149                 case 6: return LDKSecp256k1Error_InvalidTweak;
150                 case 7: return LDKSecp256k1Error_NotEnoughMemory;
151                 case 8: return LDKSecp256k1Error_CallbackPanicked;
152         }
153         abort();
154 }
155 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
156         switch (val) {
157                 case LDKSecp256k1Error_IncorrectSignature: return 0;
158                 case LDKSecp256k1Error_InvalidMessage: return 1;
159                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
160                 case LDKSecp256k1Error_InvalidSignature: return 3;
161                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
162                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
163                 case LDKSecp256k1Error_InvalidTweak: return 6;
164                 case LDKSecp256k1Error_NotEnoughMemory: return 7;
165                 case LDKSecp256k1Error_CallbackPanicked: return 8;
166                 default: abort();
167         }
168 }
169 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
170         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
171         ret->datalen = *((uint32_t*)elems);
172         if (ret->datalen == 0) {
173                 ret->data = NULL;
174         } else {
175                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
176                 int8_t *java_elems = (int8_t*)(elems + 4);
177                 for (size_t i = 0; i < ret->datalen; i++) {
178                         ret->data[i] = java_elems[i];
179                 }
180         }
181         return (long)ret;
182 }
183 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
184         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
185         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
186         return ret;
187 }
188 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_new(int64_t a, int64_t b) {
189         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
190         ret->a = a;
191         ret->b = b;
192         return (long)ret;
193 }
194 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_get_a(uint32_t ptr) {
195         LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)(ptr & ~1);
196         return tuple->a;
197 }
198 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_get_b(uint32_t ptr) {
199         LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)(ptr & ~1);
200         return tuple->b;
201 }
202 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
203         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
204         switch(obj->tag) {
205                 case LDKSpendableOutputDescriptor_StaticOutput: {
206                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
207                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
208                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
209                         long outpoint_ref = (long)outpoint_var.inner & ~1;
210                         long output_ref = ((long)&obj->static_output.output) | 1;
211                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
212                 }
213                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
214                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
215                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
216                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
217                         long outpoint_ref = (long)outpoint_var.inner & ~1;
218                         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
219                         memcpy((uint8_t*)(per_commitment_point_arr + 4), obj->dynamic_output_p2wsh.per_commitment_point.compressed_form, 33);
220                         long output_ref = ((long)&obj->dynamic_output_p2wsh.output) | 1;
221                         long key_derivation_params_ref = (long)(&obj->dynamic_output_p2wsh.key_derivation_params) | 1;
222                         int8_tArray revocation_pubkey_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
223                         memcpy((uint8_t*)(revocation_pubkey_arr + 4), obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form, 33);
224                         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;
225                 }
226                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
227                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
228                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
229                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
230                         long outpoint_ref = (long)outpoint_var.inner & ~1;
231                         long output_ref = ((long)&obj->static_output_counterparty_payment.output) | 1;
232                         long key_derivation_params_ref = (long)(&obj->static_output_counterparty_payment.key_derivation_params) | 1;
233                         return 0 /* LDKSpendableOutputDescriptor - StaticOutputCounterpartyPayment */; (void) outpoint_ref; (void) (long)output_ref; (void) key_derivation_params_ref;
234                 }
235                 default: abort();
236         }
237 }
238 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
239         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
240         ret->datalen = *((uint32_t*)elems);
241         if (ret->datalen == 0) {
242                 ret->data = NULL;
243         } else {
244                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
245                 uint32_t *java_elems = (uint32_t*)(elems + 4);
246                 for (size_t i = 0; i < ret->datalen; i++) {
247                         uint32_t arr_elem = java_elems[i];
248                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
249                         FREE((void*)arr_elem);
250                         ret->data[i] = arr_elem_conv;
251                 }
252         }
253         return (long)ret;
254 }
255 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
256         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
257         for (size_t i = 0; i < ret.datalen; i++) {
258                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
259         }
260         return ret;
261 }
262 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
263         LDKErrorAction *obj = (LDKErrorAction*)ptr;
264         switch(obj->tag) {
265                 case LDKErrorAction_DisconnectPeer: {
266                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
267                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
268                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
269                         long msg_ref = (long)msg_var.inner & ~1;
270                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
271                 }
272                 case LDKErrorAction_IgnoreError: {
273                         return 0 /* LDKErrorAction - IgnoreError */;
274                 }
275                 case LDKErrorAction_SendErrorMessage: {
276                         LDKErrorMessage msg_var = obj->send_error_message.msg;
277                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
278                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
279                         long msg_ref = (long)msg_var.inner & ~1;
280                         return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
281                 }
282                 default: abort();
283         }
284 }
285 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
286         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
287         switch(obj->tag) {
288                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
289                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
290                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
291                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
292                         long msg_ref = (long)msg_var.inner & ~1;
293                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
294                 }
295                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
296                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
297                 }
298                 case LDKHTLCFailChannelUpdate_NodeFailure: {
299                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
300                         memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
301                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
302                 }
303                 default: abort();
304         }
305 }
306 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
307         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
308         switch(obj->tag) {
309                 case LDKMessageSendEvent_SendAcceptChannel: {
310                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
311                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
312                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
313                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
314                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
315                         long msg_ref = (long)msg_var.inner & ~1;
316                         return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
317                 }
318                 case LDKMessageSendEvent_SendOpenChannel: {
319                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
320                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
321                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
322                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
323                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
324                         long msg_ref = (long)msg_var.inner & ~1;
325                         return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
326                 }
327                 case LDKMessageSendEvent_SendFundingCreated: {
328                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
329                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
330                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
331                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
332                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
333                         long msg_ref = (long)msg_var.inner & ~1;
334                         return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
335                 }
336                 case LDKMessageSendEvent_SendFundingSigned: {
337                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
338                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
339                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
340                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
341                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
342                         long msg_ref = (long)msg_var.inner & ~1;
343                         return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
344                 }
345                 case LDKMessageSendEvent_SendFundingLocked: {
346                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
347                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
348                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
349                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
350                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
351                         long msg_ref = (long)msg_var.inner & ~1;
352                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
353                 }
354                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
355                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
356                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
357                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
358                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
359                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
360                         long msg_ref = (long)msg_var.inner & ~1;
361                         return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
362                 }
363                 case LDKMessageSendEvent_UpdateHTLCs: {
364                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
365                         memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
366                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
367                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
368                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
369                         long updates_ref = (long)updates_var.inner & ~1;
370                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
371                 }
372                 case LDKMessageSendEvent_SendRevokeAndACK: {
373                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
374                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
375                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
376                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
377                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
378                         long msg_ref = (long)msg_var.inner & ~1;
379                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
380                 }
381                 case LDKMessageSendEvent_SendClosingSigned: {
382                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
383                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
384                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
385                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
386                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
387                         long msg_ref = (long)msg_var.inner & ~1;
388                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
389                 }
390                 case LDKMessageSendEvent_SendShutdown: {
391                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
392                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
393                         LDKShutdown msg_var = obj->send_shutdown.msg;
394                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
395                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
396                         long msg_ref = (long)msg_var.inner & ~1;
397                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
398                 }
399                 case LDKMessageSendEvent_SendChannelReestablish: {
400                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
401                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
402                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
403                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
404                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
405                         long msg_ref = (long)msg_var.inner & ~1;
406                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
407                 }
408                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
409                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
410                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
411                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
412                         long msg_ref = (long)msg_var.inner & ~1;
413                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
414                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
415                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
416                         long update_msg_ref = (long)update_msg_var.inner & ~1;
417                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
418                 }
419                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
420                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
421                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
422                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
423                         long msg_ref = (long)msg_var.inner & ~1;
424                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
425                 }
426                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
427                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
428                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
429                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
430                         long msg_ref = (long)msg_var.inner & ~1;
431                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
432                 }
433                 case LDKMessageSendEvent_HandleError: {
434                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
435                         memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
436                         long action_ref = ((long)&obj->handle_error.action) | 1;
437                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
438                 }
439                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
440                         long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
441                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
442                 }
443                 case LDKMessageSendEvent_SendChannelRangeQuery: {
444                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
445                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
446                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
447                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
448                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
449                         long msg_ref = (long)msg_var.inner & ~1;
450                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
451                 }
452                 case LDKMessageSendEvent_SendShortIdsQuery: {
453                         int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
454                         memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
455                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
456                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
457                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
458                         long msg_ref = (long)msg_var.inner & ~1;
459                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
460                 }
461                 default: abort();
462         }
463 }
464 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
465         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
466         ret->datalen = *((uint32_t*)elems);
467         if (ret->datalen == 0) {
468                 ret->data = NULL;
469         } else {
470                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
471                 uint32_t *java_elems = (uint32_t*)(elems + 4);
472                 for (size_t i = 0; i < ret->datalen; i++) {
473                         uint32_t arr_elem = java_elems[i];
474                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
475                         FREE((void*)arr_elem);
476                         ret->data[i] = arr_elem_conv;
477                 }
478         }
479         return (long)ret;
480 }
481 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
482         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
483         for (size_t i = 0; i < ret.datalen; i++) {
484                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
485         }
486         return ret;
487 }
488 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
489         LDKEvent *obj = (LDKEvent*)ptr;
490         switch(obj->tag) {
491                 case LDKEvent_FundingGenerationReady: {
492                         int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
493                         memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
494                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
495                         int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
496                         memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
497                         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;
498                 }
499                 case LDKEvent_FundingBroadcastSafe: {
500                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
501                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
502                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
503                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
504                         return 0 /* LDKEvent - FundingBroadcastSafe */; (void) funding_txo_ref; (void) obj->funding_broadcast_safe.user_channel_id;
505                 }
506                 case LDKEvent_PaymentReceived: {
507                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
508                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
509                         int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
510                         memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
511                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
512                 }
513                 case LDKEvent_PaymentSent: {
514                         int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
515                         memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
516                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
517                 }
518                 case LDKEvent_PaymentFailed: {
519                         int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
520                         memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
521                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
522                 }
523                 case LDKEvent_PendingHTLCsForwardable: {
524                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
525                 }
526                 case LDKEvent_SpendableOutputs: {
527                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
528                         uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
529                         uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
530                         for (size_t b = 0; b < outputs_var.datalen; b++) {
531                                 long arr_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
532                                 outputs_arr_ptr[b] = arr_conv_27_ref;
533                         }
534                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
535                 }
536                 default: abort();
537         }
538 }
539 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
540         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
541         ret->datalen = *((uint32_t*)elems);
542         if (ret->datalen == 0) {
543                 ret->data = NULL;
544         } else {
545                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
546                 uint32_t *java_elems = (uint32_t*)(elems + 4);
547                 for (size_t i = 0; i < ret->datalen; i++) {
548                         uint32_t arr_elem = java_elems[i];
549                         LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
550                         FREE((void*)arr_elem);
551                         ret->data[i] = arr_elem_conv;
552                 }
553         }
554         return (long)ret;
555 }
556 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
557         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
558         for (size_t i = 0; i < ret.datalen; i++) {
559                 ret.data[i] = Event_clone(&orig->data[i]);
560         }
561         return ret;
562 }
563 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
564         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
565         ret->a = a;
566         LDKTransaction b_ref;
567         b_ref.datalen = *((uint32_t*)b);
568         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
569         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
570         b_ref.data_is_owned = false;
571         ret->b = b_ref;
572         return (long)ret;
573 }
574 int64_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
575         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
576         return tuple->a;
577 }
578 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
579         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
580         LDKTransaction b_var = tuple->b;
581         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
582         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
583         return b_arr;
584 }
585 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
586         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
587         ret->datalen = *((uint32_t*)elems);
588         if (ret->datalen == 0) {
589                 ret->data = NULL;
590         } else {
591                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
592                 uint32_t *java_elems = (uint32_t*)(elems + 4);
593                 for (size_t i = 0; i < ret->datalen; i++) {
594                         uint32_t arr_elem = java_elems[i];
595                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
596                         FREE((void*)arr_elem);
597                         ret->data[i] = arr_elem_conv;
598                 }
599         }
600         return (long)ret;
601 }
602 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
603         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
604 }
605 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
606         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
607         CHECK(val->result_ok);
608         return *val->contents.result;
609 }
610 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
611         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
612         CHECK(!val->result_ok);
613         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
614         return err_conv;
615 }
616 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
617         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
618         ret->datalen = *((uint32_t*)elems);
619         if (ret->datalen == 0) {
620                 ret->data = NULL;
621         } else {
622                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
623                 uint32_t *java_elems = (uint32_t*)(elems + 4);
624                 for (size_t i = 0; i < ret->datalen; i++) {
625                         uint32_t arr_elem = java_elems[i];
626                         LDKMonitorEvent arr_elem_conv;
627                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
628                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
629                         arr_elem_conv = MonitorEvent_clone(&arr_elem_conv);
630                         ret->data[i] = arr_elem_conv;
631                 }
632         }
633         return (long)ret;
634 }
635 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
636         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
637         for (size_t i = 0; i < ret.datalen; i++) {
638                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
639         }
640         return ret;
641 }
642 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
643         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
644 }
645 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
646         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
647         CHECK(val->result_ok);
648         LDKChannelMonitorUpdate res_var = (*val->contents.result);
649         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
650         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
651         long res_ref = (long)res_var.inner & ~1;
652         return res_ref;
653 }
654 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
655         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
656         CHECK(!val->result_ok);
657         LDKDecodeError err_var = (*val->contents.err);
658         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
659         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
660         long err_ref = (long)err_var.inner & ~1;
661         return err_ref;
662 }
663 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
664         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
665 }
666 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
667         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
668         CHECK(val->result_ok);
669         return *val->contents.result;
670 }
671 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
672         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
673         CHECK(!val->result_ok);
674         LDKMonitorUpdateError err_var = (*val->contents.err);
675         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
676         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
677         long err_ref = (long)err_var.inner & ~1;
678         return err_ref;
679 }
680 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
681         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
682         LDKOutPoint a_conv;
683         a_conv.inner = (void*)(a & (~1));
684         a_conv.is_owned = (a & 1) || (a == 0);
685         a_conv = OutPoint_clone(&a_conv);
686         ret->a = a_conv;
687         LDKCVec_u8Z b_ref;
688         b_ref.datalen = *((uint32_t*)b);
689         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
690         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
691         ret->b = b_ref;
692         return (long)ret;
693 }
694 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
695         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
696         LDKOutPoint a_var = tuple->a;
697         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
698         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
699         long a_ref = (long)a_var.inner & ~1;
700         return a_ref;
701 }
702 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
703         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
704         LDKCVec_u8Z b_var = tuple->b;
705         int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
706         memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
707         return b_arr;
708 }
709 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
710         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
711         ret->a = a;
712         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
713         FREE((void*)b);
714         ret->b = b_conv;
715         return (long)ret;
716 }
717 int32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
718         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
719         return tuple->a;
720 }
721 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
722         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
723         long b_ref = ((long)&tuple->b) | 1;
724         return (long)b_ref;
725 }
726 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
727         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
728         ret->datalen = *((uint32_t*)elems);
729         if (ret->datalen == 0) {
730                 ret->data = NULL;
731         } else {
732                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
733                 uint32_t *java_elems = (uint32_t*)(elems + 4);
734                 for (size_t i = 0; i < ret->datalen; i++) {
735                         uint32_t arr_elem = java_elems[i];
736                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
737                         FREE((void*)arr_elem);
738                         ret->data[i] = arr_elem_conv;
739                 }
740         }
741         return (long)ret;
742 }
743 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
744         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
745         for (size_t i = 0; i < ret.datalen; i++) {
746                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
747         }
748         return ret;
749 }
750 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
751         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
752         LDKThirtyTwoBytes a_ref;
753         CHECK(*((uint32_t*)a) == 32);
754         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
755         ret->a = a_ref;
756         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
757         b_constr.datalen = *((uint32_t*)b);
758         if (b_constr.datalen > 0)
759                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
760         else
761                 b_constr.data = NULL;
762         uint32_t* b_vals = (uint32_t*)(b + 4);
763         for (size_t z = 0; z < b_constr.datalen; z++) {
764                 uint32_t arr_conv_25 = b_vals[z];
765                 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_conv_25) & ~1);
766                 FREE((void*)arr_conv_25);
767                 b_constr.data[z] = arr_conv_25_conv;
768         }
769         ret->b = b_constr;
770         return (long)ret;
771 }
772 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
773         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
774         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
775         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
776         return a_arr;
777 }
778 uint32_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
779         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
780         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
781         uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
782         uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
783         for (size_t z = 0; z < b_var.datalen; z++) {
784                 long arr_conv_25_ref = (long)(&b_var.data[z]) | 1;
785                 b_arr_ptr[z] = arr_conv_25_ref;
786         }
787         return b_arr;
788 }
789 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
790         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
791         ret->datalen = *((uint32_t*)elems);
792         if (ret->datalen == 0) {
793                 ret->data = NULL;
794         } else {
795                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
796                 uint32_t *java_elems = (uint32_t*)(elems + 4);
797                 for (size_t i = 0; i < ret->datalen; i++) {
798                         uint32_t arr_elem = java_elems[i];
799                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
800                         FREE((void*)arr_elem);
801                         ret->data[i] = arr_elem_conv;
802                 }
803         }
804         return (long)ret;
805 }
806 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
807         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
808         LDKSignature a_ref;
809         CHECK(*((uint32_t*)a) == 64);
810         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
811         ret->a = a_ref;
812         LDKCVec_SignatureZ b_constr;
813         b_constr.datalen = *((uint32_t*)b);
814         if (b_constr.datalen > 0)
815                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
816         else
817                 b_constr.data = NULL;
818         int8_tArray* b_vals = (int8_tArray*)(b + 4);
819         for (size_t m = 0; m < b_constr.datalen; m++) {
820                 int8_tArray arr_conv_12 = b_vals[m];
821                 LDKSignature arr_conv_12_ref;
822                 CHECK(*((uint32_t*)arr_conv_12) == 64);
823                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
824                 b_constr.data[m] = arr_conv_12_ref;
825         }
826         ret->b = b_constr;
827         return (long)ret;
828 }
829 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
830         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
831         int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
832         memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
833         return a_arr;
834 }
835 ptrArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
836         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
837         LDKCVec_SignatureZ b_var = tuple->b;
838         ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
839         int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
840         for (size_t m = 0; m < b_var.datalen; m++) {
841                 int8_tArray arr_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
842                 memcpy((uint8_t*)(arr_conv_12_arr + 4), b_var.data[m].compact_form, 64);
843                 b_arr_ptr[m] = arr_conv_12_arr;
844         }
845         return b_arr;
846 }
847 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
848         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
849 }
850 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
851         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
852         CHECK(val->result_ok);
853         long res_ref = (long)(&(*val->contents.result)) | 1;
854         return res_ref;
855 }
856 void  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
857         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
858         CHECK(!val->result_ok);
859         return *val->contents.err;
860 }
861 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
862         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
863 }
864 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
865         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
866         CHECK(val->result_ok);
867         int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
868         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
869         return res_arr;
870 }
871 void  __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
872         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
873         CHECK(!val->result_ok);
874         return *val->contents.err;
875 }
876 typedef struct LDKChannelKeys_JCalls {
877         atomic_size_t refcnt;
878         uint32_t get_per_commitment_point_meth;
879         uint32_t release_commitment_secret_meth;
880         uint32_t key_derivation_params_meth;
881         uint32_t sign_counterparty_commitment_meth;
882         uint32_t sign_holder_commitment_and_htlcs_meth;
883         uint32_t sign_justice_transaction_meth;
884         uint32_t sign_counterparty_htlc_transaction_meth;
885         uint32_t sign_closing_transaction_meth;
886         uint32_t sign_channel_announcement_meth;
887         uint32_t ready_channel_meth;
888         uint32_t write_meth;
889 } LDKChannelKeys_JCalls;
890 static void LDKChannelKeys_JCalls_free(void* this_arg) {
891         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
892         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
893                 js_free(j_calls->get_per_commitment_point_meth);
894                 js_free(j_calls->release_commitment_secret_meth);
895                 js_free(j_calls->key_derivation_params_meth);
896                 js_free(j_calls->sign_counterparty_commitment_meth);
897                 js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
898                 js_free(j_calls->sign_justice_transaction_meth);
899                 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
900                 js_free(j_calls->sign_closing_transaction_meth);
901                 js_free(j_calls->sign_channel_announcement_meth);
902                 js_free(j_calls->ready_channel_meth);
903                 js_free(j_calls->write_meth);
904                 FREE(j_calls);
905         }
906 }
907 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
908         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
909         int8_tArray arg = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
910         LDKPublicKey arg_ref;
911         CHECK(*((uint32_t*)arg) == 33);
912         memcpy(arg_ref.compressed_form, (uint8_t*)(arg + 4), 33);
913         return arg_ref;
914 }
915 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
916         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
917         int8_tArray arg = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
918         LDKThirtyTwoBytes arg_ref;
919         CHECK(*((uint32_t*)arg) == 32);
920         memcpy(arg_ref.data, (uint8_t*)(arg + 4), 32);
921         return arg_ref;
922 }
923 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
924         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
925         LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)js_invoke_function_0(j_calls->key_derivation_params_meth);
926         LDKC2Tuple_u64u64Z ret_conv = *(LDKC2Tuple_u64u64Z*)(((uint64_t)ret) & ~1);
927         ret_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)ret);
928         return ret_conv;
929 }
930 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
931         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
932         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
933         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
934         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
935         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
936         long commitment_tx_ref = (long)commitment_tx_var.inner;
937         if (commitment_tx_var.is_owned) {
938                 commitment_tx_ref |= 1;
939         }
940         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
941         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
942         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
943         return ret_conv;
944 }
945 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
946         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
947         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
948         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
949         CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
950         CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
951         long commitment_tx_ref = (long)commitment_tx_var.inner;
952         if (commitment_tx_var.is_owned) {
953                 commitment_tx_ref |= 1;
954         }
955         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
956         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
957         ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
958         return ret_conv;
959 }
960 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) {
961         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
962         LDKTransaction justice_tx_var = justice_tx;
963         int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
964         memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
965         Transaction_free(justice_tx_var);
966         int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
967         memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
968         LDKHTLCOutputInCommitment htlc_var = *htlc;
969         htlc_var = HTLCOutputInCommitment_clone(htlc);
970         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
971         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
972         long htlc_ref = (long)htlc_var.inner;
973         if (htlc_var.is_owned) {
974                 htlc_ref |= 1;
975         }
976         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);
977         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
978         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
979         return ret_conv;
980 }
981 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) {
982         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
983         LDKTransaction htlc_tx_var = htlc_tx;
984         int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
985         memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
986         Transaction_free(htlc_tx_var);
987         int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
988         memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
989         LDKHTLCOutputInCommitment htlc_var = *htlc;
990         htlc_var = HTLCOutputInCommitment_clone(htlc);
991         CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
992         CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
993         long htlc_ref = (long)htlc_var.inner;
994         if (htlc_var.is_owned) {
995                 htlc_ref |= 1;
996         }
997         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);
998         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
999         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1000         return ret_conv;
1001 }
1002 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1003         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1004         LDKTransaction closing_tx_var = closing_tx;
1005         int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1006         memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1007         Transaction_free(closing_tx_var);
1008         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1009         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1010         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1011         return ret_conv;
1012 }
1013 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1014         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1015         LDKUnsignedChannelAnnouncement msg_var = *msg;
1016         msg_var = UnsignedChannelAnnouncement_clone(msg);
1017         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1018         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1019         long msg_ref = (long)msg_var.inner;
1020         if (msg_var.is_owned) {
1021                 msg_ref |= 1;
1022         }
1023         LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1024         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
1025         ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
1026         return ret_conv;
1027 }
1028 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1029         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1030         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1031         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1032         CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1033         CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1034         long channel_parameters_ref = (long)channel_parameters_var.inner;
1035         if (channel_parameters_var.is_owned) {
1036                 channel_parameters_ref |= 1;
1037         }
1038         js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1039 }
1040 LDKCVec_u8Z write_jcall(const void* this_arg) {
1041         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1042         int8_tArray arg = js_invoke_function_0(j_calls->write_meth);
1043         LDKCVec_u8Z arg_ref;
1044         arg_ref.datalen = *((uint32_t*)arg);
1045         arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
1046         memcpy(arg_ref.data, (uint8_t*)(arg + 4), arg_ref.datalen);
1047         return arg_ref;
1048 }
1049 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1050         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1051         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1052         return (void*) this_arg;
1053 }
1054 static inline LDKChannelKeys LDKChannelKeys_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1055         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1056         atomic_init(&calls->refcnt, 1);
1057         //TODO: Assign calls->o from o
1058
1059         LDKChannelPublicKeys pubkeys_conv;
1060         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1061         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1062         pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1063
1064         LDKChannelKeys ret = {
1065                 .this_arg = (void*) calls,
1066                 .get_per_commitment_point = get_per_commitment_point_jcall,
1067                 .release_commitment_secret = release_commitment_secret_jcall,
1068                 .key_derivation_params = key_derivation_params_jcall,
1069                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1070                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_jcall,
1071                 .sign_justice_transaction = sign_justice_transaction_jcall,
1072                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1073                 .sign_closing_transaction = sign_closing_transaction_jcall,
1074                 .sign_channel_announcement = sign_channel_announcement_jcall,
1075                 .ready_channel = ready_channel_jcall,
1076                 .clone = LDKChannelKeys_JCalls_clone,
1077                 .write = write_jcall,
1078                 .free = LDKChannelKeys_JCalls_free,
1079                 .pubkeys = pubkeys_conv,
1080                 .set_pubkeys = NULL,
1081         };
1082         return ret;
1083 }
1084 long  __attribute__((visibility("default"))) TS_LDKChannelKeys_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1085         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1086         *res_ptr = LDKChannelKeys_init(o, pubkeys);
1087         return (long)res_ptr;
1088 }
1089 int8_tArray  __attribute__((visibility("default"))) TS_ChannelKeys_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1090         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1091         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1092         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1093         return arg_arr;
1094 }
1095
1096 int8_tArray  __attribute__((visibility("default"))) TS_ChannelKeys_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1097         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1098         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1099         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1100         return arg_arr;
1101 }
1102
1103 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_key_derivation_params(uint32_t this_arg) {
1104         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1105         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1106         *ret_ref = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
1107         return (long)ret_ref;
1108 }
1109
1110 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1111         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1112         LDKCommitmentTransaction commitment_tx_conv;
1113         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1114         commitment_tx_conv.is_owned = false;
1115         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1116         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1117         return (long)ret_conv;
1118 }
1119
1120 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
1121         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1122         LDKHolderCommitmentTransaction commitment_tx_conv;
1123         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1124         commitment_tx_conv.is_owned = false;
1125         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1126         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
1127         return (long)ret_conv;
1128 }
1129
1130 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_justice_transaction(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
1131         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1132         LDKTransaction justice_tx_ref;
1133         justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1134         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1135         memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1136         justice_tx_ref.data_is_owned = true;
1137         unsigned char per_commitment_key_arr[32];
1138         CHECK(*((uint32_t*)per_commitment_key) == 32);
1139         memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1140         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1141         LDKHTLCOutputInCommitment htlc_conv;
1142         htlc_conv.inner = (void*)(htlc & (~1));
1143         htlc_conv.is_owned = false;
1144         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1145         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1146         return (long)ret_conv;
1147 }
1148
1149 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
1150         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1151         LDKTransaction htlc_tx_ref;
1152         htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1153         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1154         memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1155         htlc_tx_ref.data_is_owned = true;
1156         LDKPublicKey per_commitment_point_ref;
1157         CHECK(*((uint32_t*)per_commitment_point) == 33);
1158         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1159         LDKHTLCOutputInCommitment htlc_conv;
1160         htlc_conv.inner = (void*)(htlc & (~1));
1161         htlc_conv.is_owned = false;
1162         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1163         *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);
1164         return (long)ret_conv;
1165 }
1166
1167 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1168         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1169         LDKTransaction closing_tx_ref;
1170         closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1171         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1172         memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1173         closing_tx_ref.data_is_owned = true;
1174         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1175         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1176         return (long)ret_conv;
1177 }
1178
1179 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1180         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1181         LDKUnsignedChannelAnnouncement msg_conv;
1182         msg_conv.inner = (void*)(msg & (~1));
1183         msg_conv.is_owned = false;
1184         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1185         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1186         return (long)ret_conv;
1187 }
1188
1189 void  __attribute__((visibility("default"))) TS_ChannelKeys_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1190         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1191         LDKChannelTransactionParameters channel_parameters_conv;
1192         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1193         channel_parameters_conv.is_owned = false;
1194         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1195 }
1196
1197 int8_tArray  __attribute__((visibility("default"))) TS_ChannelKeys_write(uint32_t this_arg) {
1198         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1199         LDKCVec_u8Z arg_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1200         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1201         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
1202         CVec_u8Z_free(arg_var);
1203         return arg_arr;
1204 }
1205
1206 LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* this_arg) {
1207         if (this_arg->set_pubkeys != NULL)
1208                 this_arg->set_pubkeys(this_arg);
1209         return this_arg->pubkeys;
1210 }
1211 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_get_pubkeys(uint32_t this_arg) {
1212         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1213         LDKChannelPublicKeys ret_var = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
1214         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1215         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1216         long ret_ref = (long)ret_var.inner;
1217         if (ret_var.is_owned) {
1218                 ret_ref |= 1;
1219         }
1220         return ret_ref;
1221 }
1222
1223 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
1224         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1225         LDKThirtyTwoBytes a_ref;
1226         CHECK(*((uint32_t*)a) == 32);
1227         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1228         ret->a = a_ref;
1229         LDKChannelMonitor b_conv;
1230         b_conv.inner = (void*)(b & (~1));
1231         b_conv.is_owned = (b & 1) || (b == 0);
1232         b_conv = ChannelMonitor_clone(&b_conv);
1233         ret->b = b_conv;
1234         return (long)ret;
1235 }
1236 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
1237         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1238         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1239         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1240         return a_arr;
1241 }
1242 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
1243         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)(ptr & ~1);
1244         LDKChannelMonitor b_var = tuple->b;
1245         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1246         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1247         long b_ref = (long)b_var.inner & ~1;
1248         return b_ref;
1249 }
1250 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
1251         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
1252 }
1253 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
1254         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
1255         CHECK(val->result_ok);
1256         long res_ref = (long)(&(*val->contents.result)) | 1;
1257         return res_ref;
1258 }
1259 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
1260         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
1261         CHECK(!val->result_ok);
1262         LDKDecodeError err_var = (*val->contents.err);
1263         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1264         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1265         long err_ref = (long)err_var.inner & ~1;
1266         return err_ref;
1267 }
1268 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1269         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1270 }
1271 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1272         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1273         CHECK(val->result_ok);
1274         long res_ref = ((long)&(*val->contents.result)) | 1;
1275         return res_ref;
1276 }
1277 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1278         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
1279         CHECK(!val->result_ok);
1280         LDKDecodeError err_var = (*val->contents.err);
1281         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1282         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1283         long err_ref = (long)err_var.inner & ~1;
1284         return err_ref;
1285 }
1286 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_result_ok(uint32_t arg) {
1287         return ((LDKCResult_ChanKeySignerDecodeErrorZ*)arg)->result_ok;
1288 }
1289 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_get_ok(uint32_t arg) {
1290         LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)(arg & ~1);
1291         CHECK(val->result_ok);
1292         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1293         *ret = ChannelKeys_clone(&(*val->contents.result));
1294         return (long)ret;
1295 }
1296 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_get_err(uint32_t arg) {
1297         LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)(arg & ~1);
1298         CHECK(!val->result_ok);
1299         LDKDecodeError err_var = (*val->contents.err);
1300         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1301         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1302         long err_ref = (long)err_var.inner & ~1;
1303         return err_ref;
1304 }
1305 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_result_ok(uint32_t arg) {
1306         return ((LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg)->result_ok;
1307 }
1308 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_get_ok(uint32_t arg) {
1309         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)(arg & ~1);
1310         CHECK(val->result_ok);
1311         LDKInMemoryChannelKeys res_var = (*val->contents.result);
1312         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1313         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1314         long res_ref = (long)res_var.inner & ~1;
1315         return res_ref;
1316 }
1317 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_get_err(uint32_t arg) {
1318         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)(arg & ~1);
1319         CHECK(!val->result_ok);
1320         LDKDecodeError err_var = (*val->contents.err);
1321         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1322         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1323         long err_ref = (long)err_var.inner & ~1;
1324         return err_ref;
1325 }
1326 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
1327         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1328 }
1329 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
1330         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1331         CHECK(val->result_ok);
1332         long res_ref = ((long)&(*val->contents.result)) | 1;
1333         return (long)res_ref;
1334 }
1335 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
1336         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1337         CHECK(!val->result_ok);
1338         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
1339         return err_conv;
1340 }
1341 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
1342         LDKAPIError *obj = (LDKAPIError*)ptr;
1343         switch(obj->tag) {
1344                 case LDKAPIError_APIMisuseError: {
1345                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
1346                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1347                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1348                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
1349                 }
1350                 case LDKAPIError_FeeRateTooHigh: {
1351                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
1352                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1353                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1354                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
1355                 }
1356                 case LDKAPIError_RouteError: {
1357                         LDKStr err_str = obj->route_error.err;
1358                         jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1359                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
1360                 }
1361                 case LDKAPIError_ChannelUnavailable: {
1362                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
1363                         int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1364                         memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1365                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
1366                 }
1367                 case LDKAPIError_MonitorUpdateFailed: {
1368                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
1369                 }
1370                 default: abort();
1371         }
1372 }
1373 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
1374         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
1375 }
1376 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
1377         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
1378         CHECK(val->result_ok);
1379         return *val->contents.result;
1380 }
1381 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
1382         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
1383         CHECK(!val->result_ok);
1384         long err_ref = ((long)&(*val->contents.err)) | 1;
1385         return err_ref;
1386 }
1387 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
1388         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1389         ret->datalen = *((uint32_t*)elems);
1390         if (ret->datalen == 0) {
1391                 ret->data = NULL;
1392         } else {
1393                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1394                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1395                 for (size_t i = 0; i < ret->datalen; i++) {
1396                         uint32_t arr_elem = java_elems[i];
1397                         LDKChannelDetails arr_elem_conv;
1398                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1399                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1400                         arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1401                         ret->data[i] = arr_elem_conv;
1402                 }
1403         }
1404         return (long)ret;
1405 }
1406 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1407         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1408         for (size_t i = 0; i < ret.datalen; i++) {
1409                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1410         }
1411         return ret;
1412 }
1413 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
1414         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
1415 }
1416 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
1417         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
1418         CHECK(val->result_ok);
1419         return *val->contents.result;
1420 }
1421 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
1422         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
1423         CHECK(!val->result_ok);
1424         LDKPaymentSendFailure err_var = (*val->contents.err);
1425         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1426         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1427         long err_ref = (long)err_var.inner & ~1;
1428         return err_ref;
1429 }
1430 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
1431         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1432         switch(obj->tag) {
1433                 case LDKNetAddress_IPv4: {
1434                         int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
1435                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
1436                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
1437                 }
1438                 case LDKNetAddress_IPv6: {
1439                         int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
1440                         memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
1441                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
1442                 }
1443                 case LDKNetAddress_OnionV2: {
1444                         int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
1445                         memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
1446                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
1447                 }
1448                 case LDKNetAddress_OnionV3: {
1449                         int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1450                         memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
1451                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
1452                 }
1453                 default: abort();
1454         }
1455 }
1456 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
1457         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1458         ret->datalen = *((uint32_t*)elems);
1459         if (ret->datalen == 0) {
1460                 ret->data = NULL;
1461         } else {
1462                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1463                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1464                 for (size_t i = 0; i < ret->datalen; i++) {
1465                         uint32_t arr_elem = java_elems[i];
1466                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
1467                         FREE((void*)arr_elem);
1468                         ret->data[i] = arr_elem_conv;
1469                 }
1470         }
1471         return (long)ret;
1472 }
1473 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1474         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1475         for (size_t i = 0; i < ret.datalen; i++) {
1476                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1477         }
1478         return ret;
1479 }
1480 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
1481         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
1482         ret->datalen = *((uint32_t*)elems);
1483         if (ret->datalen == 0) {
1484                 ret->data = NULL;
1485         } else {
1486                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
1487                 uint32_t *java_elems = (uint32_t*)(elems + 4);
1488                 for (size_t i = 0; i < ret->datalen; i++) {
1489                         uint32_t arr_elem = java_elems[i];
1490                         LDKChannelMonitor arr_elem_conv;
1491                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1492                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1493                         arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
1494                         ret->data[i] = arr_elem_conv;
1495                 }
1496         }
1497         return (long)ret;
1498 }
1499 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
1500         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
1501         for (size_t i = 0; i < ret.datalen; i++) {
1502                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
1503         }
1504         return ret;
1505 }
1506 typedef struct LDKWatch_JCalls {
1507         atomic_size_t refcnt;
1508         uint32_t watch_channel_meth;
1509         uint32_t update_channel_meth;
1510         uint32_t release_pending_monitor_events_meth;
1511 } LDKWatch_JCalls;
1512 static void LDKWatch_JCalls_free(void* this_arg) {
1513         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1514         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1515                 js_free(j_calls->watch_channel_meth);
1516                 js_free(j_calls->update_channel_meth);
1517                 js_free(j_calls->release_pending_monitor_events_meth);
1518                 FREE(j_calls);
1519         }
1520 }
1521 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
1522         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1523         LDKOutPoint funding_txo_var = funding_txo;
1524         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1525         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1526         long funding_txo_ref = (long)funding_txo_var.inner;
1527         if (funding_txo_var.is_owned) {
1528                 funding_txo_ref |= 1;
1529         }
1530         LDKChannelMonitor monitor_var = monitor;
1531         CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1532         CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1533         long monitor_ref = (long)monitor_var.inner;
1534         if (monitor_var.is_owned) {
1535                 monitor_ref |= 1;
1536         }
1537         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
1538         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
1539         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
1540         return ret_conv;
1541 }
1542 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
1543         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1544         LDKOutPoint funding_txo_var = funding_txo;
1545         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1546         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1547         long funding_txo_ref = (long)funding_txo_var.inner;
1548         if (funding_txo_var.is_owned) {
1549                 funding_txo_ref |= 1;
1550         }
1551         LDKChannelMonitorUpdate update_var = update;
1552         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1553         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1554         long update_ref = (long)update_var.inner;
1555         if (update_var.is_owned) {
1556                 update_ref |= 1;
1557         }
1558         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
1559         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
1560         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
1561         return ret_conv;
1562 }
1563 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
1564         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1565         uint32_tArray arg = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
1566         LDKCVec_MonitorEventZ arg_constr;
1567         arg_constr.datalen = *((uint32_t*)arg);
1568         if (arg_constr.datalen > 0)
1569                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
1570         else
1571                 arg_constr.data = NULL;
1572         uint32_t* arg_vals = (uint32_t*)(arg + 4);
1573         for (size_t o = 0; o < arg_constr.datalen; o++) {
1574                 uint32_t arr_conv_14 = arg_vals[o];
1575                 LDKMonitorEvent arr_conv_14_conv;
1576                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
1577                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
1578                 arr_conv_14_conv = MonitorEvent_clone(&arr_conv_14_conv);
1579                 arg_constr.data[o] = arr_conv_14_conv;
1580         }
1581         return arg_constr;
1582 }
1583 static void* LDKWatch_JCalls_clone(const void* this_arg) {
1584         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1585         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1586         return (void*) this_arg;
1587 }
1588 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
1589         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
1590         atomic_init(&calls->refcnt, 1);
1591         //TODO: Assign calls->o from o
1592
1593         LDKWatch ret = {
1594                 .this_arg = (void*) calls,
1595                 .watch_channel = watch_channel_jcall,
1596                 .update_channel = update_channel_jcall,
1597                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
1598                 .free = LDKWatch_JCalls_free,
1599         };
1600         return ret;
1601 }
1602 long  __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
1603         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
1604         *res_ptr = LDKWatch_init(o);
1605         return (long)res_ptr;
1606 }
1607 uint32_t  __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
1608         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1609         LDKOutPoint funding_txo_conv;
1610         funding_txo_conv.inner = (void*)(funding_txo & (~1));
1611         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1612         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1613         LDKChannelMonitor monitor_conv;
1614         monitor_conv.inner = (void*)(monitor & (~1));
1615         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
1616         monitor_conv = ChannelMonitor_clone(&monitor_conv);
1617         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1618         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
1619         return (long)ret_conv;
1620 }
1621
1622 uint32_t  __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
1623         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1624         LDKOutPoint funding_txo_conv;
1625         funding_txo_conv.inner = (void*)(funding_txo & (~1));
1626         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1627         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1628         LDKChannelMonitorUpdate update_conv;
1629         update_conv.inner = (void*)(update & (~1));
1630         update_conv.is_owned = (update & 1) || (update == 0);
1631         update_conv = ChannelMonitorUpdate_clone(&update_conv);
1632         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1633         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
1634         return (long)ret_conv;
1635 }
1636
1637 uint32_tArray  __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
1638         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1639         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
1640         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1641         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
1642         for (size_t o = 0; o < ret_var.datalen; o++) {
1643                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
1644                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1645                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1646                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
1647                 if (arr_conv_14_var.is_owned) {
1648                         arr_conv_14_ref |= 1;
1649                 }
1650                 ret_arr_ptr[o] = arr_conv_14_ref;
1651         }
1652         FREE(ret_var.data);
1653         return ret_arr;
1654 }
1655
1656 typedef struct LDKBroadcasterInterface_JCalls {
1657         atomic_size_t refcnt;
1658         uint32_t broadcast_transaction_meth;
1659 } LDKBroadcasterInterface_JCalls;
1660 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
1661         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1662         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1663                 js_free(j_calls->broadcast_transaction_meth);
1664                 FREE(j_calls);
1665         }
1666 }
1667 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
1668         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1669         LDKTransaction tx_var = tx;
1670         int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1671         memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
1672         Transaction_free(tx_var);
1673         js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
1674 }
1675 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
1676         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1677         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1678         return (void*) this_arg;
1679 }
1680 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
1681         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
1682         atomic_init(&calls->refcnt, 1);
1683         //TODO: Assign calls->o from o
1684
1685         LDKBroadcasterInterface ret = {
1686                 .this_arg = (void*) calls,
1687                 .broadcast_transaction = broadcast_transaction_jcall,
1688                 .free = LDKBroadcasterInterface_JCalls_free,
1689         };
1690         return ret;
1691 }
1692 long  __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
1693         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
1694         *res_ptr = LDKBroadcasterInterface_init(o);
1695         return (long)res_ptr;
1696 }
1697 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
1698         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
1699         LDKTransaction tx_ref;
1700         tx_ref.datalen = *((uint32_t*)tx);
1701         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
1702         memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
1703         tx_ref.data_is_owned = true;
1704         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
1705 }
1706
1707 typedef struct LDKKeysInterface_JCalls {
1708         atomic_size_t refcnt;
1709         uint32_t get_node_secret_meth;
1710         uint32_t get_destination_script_meth;
1711         uint32_t get_shutdown_pubkey_meth;
1712         uint32_t get_channel_keys_meth;
1713         uint32_t get_secure_random_bytes_meth;
1714         uint32_t read_chan_signer_meth;
1715 } LDKKeysInterface_JCalls;
1716 static void LDKKeysInterface_JCalls_free(void* this_arg) {
1717         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1718         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1719                 js_free(j_calls->get_node_secret_meth);
1720                 js_free(j_calls->get_destination_script_meth);
1721                 js_free(j_calls->get_shutdown_pubkey_meth);
1722                 js_free(j_calls->get_channel_keys_meth);
1723                 js_free(j_calls->get_secure_random_bytes_meth);
1724                 js_free(j_calls->read_chan_signer_meth);
1725                 FREE(j_calls);
1726         }
1727 }
1728 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
1729         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1730         int8_tArray arg = js_invoke_function_0(j_calls->get_node_secret_meth);
1731         LDKSecretKey arg_ref;
1732         CHECK(*((uint32_t*)arg) == 32);
1733         memcpy(arg_ref.bytes, (uint8_t*)(arg + 4), 32);
1734         return arg_ref;
1735 }
1736 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
1737         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1738         int8_tArray arg = js_invoke_function_0(j_calls->get_destination_script_meth);
1739         LDKCVec_u8Z arg_ref;
1740         arg_ref.datalen = *((uint32_t*)arg);
1741         arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
1742         memcpy(arg_ref.data, (uint8_t*)(arg + 4), arg_ref.datalen);
1743         return arg_ref;
1744 }
1745 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
1746         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1747         int8_tArray arg = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
1748         LDKPublicKey arg_ref;
1749         CHECK(*((uint32_t*)arg) == 33);
1750         memcpy(arg_ref.compressed_form, (uint8_t*)(arg + 4), 33);
1751         return arg_ref;
1752 }
1753 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
1754         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1755         LDKChannelKeys* ret = (LDKChannelKeys*)js_invoke_function_2(j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
1756         LDKChannelKeys ret_conv = *(LDKChannelKeys*)(((uint64_t)ret) & ~1);
1757         ret_conv = ChannelKeys_clone(ret);
1758         return ret_conv;
1759 }
1760 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
1761         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1762         int8_tArray arg = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
1763         LDKThirtyTwoBytes arg_ref;
1764         CHECK(*((uint32_t*)arg) == 32);
1765         memcpy(arg_ref.data, (uint8_t*)(arg + 4), 32);
1766         return arg_ref;
1767 }
1768 LDKCResult_ChanKeySignerDecodeErrorZ read_chan_signer_jcall(const void* this_arg, LDKu8slice reader) {
1769         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1770         LDKu8slice reader_var = reader;
1771         int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1772         memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
1773         LDKCResult_ChanKeySignerDecodeErrorZ* ret = (LDKCResult_ChanKeySignerDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
1774         LDKCResult_ChanKeySignerDecodeErrorZ ret_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)(((uint64_t)ret) & ~1);
1775         ret_conv = CResult_ChanKeySignerDecodeErrorZ_clone((LDKCResult_ChanKeySignerDecodeErrorZ*)ret);
1776         return ret_conv;
1777 }
1778 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
1779         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1780         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1781         return (void*) this_arg;
1782 }
1783 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
1784         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
1785         atomic_init(&calls->refcnt, 1);
1786         //TODO: Assign calls->o from o
1787
1788         LDKKeysInterface ret = {
1789                 .this_arg = (void*) calls,
1790                 .get_node_secret = get_node_secret_jcall,
1791                 .get_destination_script = get_destination_script_jcall,
1792                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
1793                 .get_channel_keys = get_channel_keys_jcall,
1794                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
1795                 .read_chan_signer = read_chan_signer_jcall,
1796                 .free = LDKKeysInterface_JCalls_free,
1797         };
1798         return ret;
1799 }
1800 long  __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
1801         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
1802         *res_ptr = LDKKeysInterface_init(o);
1803         return (long)res_ptr;
1804 }
1805 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
1806         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1807         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1808         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
1809         return arg_arr;
1810 }
1811
1812 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
1813         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1814         LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
1815         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1816         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
1817         CVec_u8Z_free(arg_var);
1818         return arg_arr;
1819 }
1820
1821 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
1822         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1823         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1824         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
1825         return arg_arr;
1826 }
1827
1828 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_get_channel_keys(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
1829         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1830         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1831         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
1832         return (long)ret;
1833 }
1834
1835 int8_tArray  __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
1836         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1837         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1838         memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
1839         return arg_arr;
1840 }
1841
1842 uint32_t  __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
1843         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1844         LDKu8slice reader_ref;
1845         reader_ref.datalen = *((uint32_t*)reader);
1846         reader_ref.data = (int8_t*)(reader + 4);
1847         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
1848         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
1849         return (long)ret_conv;
1850 }
1851
1852 typedef struct LDKFeeEstimator_JCalls {
1853         atomic_size_t refcnt;
1854         uint32_t get_est_sat_per_1000_weight_meth;
1855 } LDKFeeEstimator_JCalls;
1856 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
1857         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
1858         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1859                 js_free(j_calls->get_est_sat_per_1000_weight_meth);
1860                 FREE(j_calls);
1861         }
1862 }
1863 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
1864         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
1865         uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
1866         return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
1867 }
1868 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
1869         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
1870         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1871         return (void*) this_arg;
1872 }
1873 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
1874         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
1875         atomic_init(&calls->refcnt, 1);
1876         //TODO: Assign calls->o from o
1877
1878         LDKFeeEstimator ret = {
1879                 .this_arg = (void*) calls,
1880                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
1881                 .free = LDKFeeEstimator_JCalls_free,
1882         };
1883         return ret;
1884 }
1885 long  __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
1886         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
1887         *res_ptr = LDKFeeEstimator_init(o);
1888         return (long)res_ptr;
1889 }
1890 int32_t  __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
1891         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
1892         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
1893         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
1894         return ret_val;
1895 }
1896
1897 typedef struct LDKLogger_JCalls {
1898         atomic_size_t refcnt;
1899         uint32_t log_meth;
1900 } LDKLogger_JCalls;
1901 static void LDKLogger_JCalls_free(void* this_arg) {
1902         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1903         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1904                 js_free(j_calls->log_meth);
1905                 FREE(j_calls);
1906         }
1907 }
1908 void log_jcall(const void* this_arg, const char* record) {
1909         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1910         const char* record_str = record;
1911         jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
1912         js_invoke_function_1(j_calls->log_meth, record_conv);
1913 }
1914 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1915         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1916         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1917         return (void*) this_arg;
1918 }
1919 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
1920         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1921         atomic_init(&calls->refcnt, 1);
1922         //TODO: Assign calls->o from o
1923
1924         LDKLogger ret = {
1925                 .this_arg = (void*) calls,
1926                 .log = log_jcall,
1927                 .free = LDKLogger_JCalls_free,
1928         };
1929         return ret;
1930 }
1931 long  __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
1932         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1933         *res_ptr = LDKLogger_init(o);
1934         return (long)res_ptr;
1935 }
1936 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
1937         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
1938         LDKThirtyTwoBytes a_ref;
1939         CHECK(*((uint32_t*)a) == 32);
1940         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1941         ret->a = a_ref;
1942         LDKChannelManager b_conv;
1943         b_conv.inner = (void*)(b & (~1));
1944         b_conv.is_owned = (b & 1) || (b == 0);
1945         // Warning: we need a move here but no clone is available for LDKChannelManager
1946         ret->b = b_conv;
1947         return (long)ret;
1948 }
1949 int8_tArray  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
1950         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
1951         int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1952         memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1953         return a_arr;
1954 }
1955 uint32_t  __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
1956         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)(ptr & ~1);
1957         LDKChannelManager b_var = tuple->b;
1958         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1959         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1960         long b_ref = (long)b_var.inner & ~1;
1961         return b_ref;
1962 }
1963 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
1964         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
1965 }
1966 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
1967         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
1968         CHECK(val->result_ok);
1969         long res_ref = (long)(&(*val->contents.result)) | 1;
1970         return res_ref;
1971 }
1972 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
1973         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
1974         CHECK(!val->result_ok);
1975         LDKDecodeError err_var = (*val->contents.err);
1976         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1977         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1978         long err_ref = (long)err_var.inner & ~1;
1979         return err_ref;
1980 }
1981 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
1982         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
1983 }
1984 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
1985         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
1986         CHECK(val->result_ok);
1987         long res_ref = ((long)&(*val->contents.result)) | 1;
1988         return res_ref;
1989 }
1990 int8_t  __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
1991         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)(arg & ~1);
1992         CHECK(!val->result_ok);
1993         return *val->contents.err;
1994 }
1995 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
1996         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
1997 }
1998 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
1999         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
2000         CHECK(val->result_ok);
2001         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
2002         *res_conv = (*val->contents.result);
2003         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
2004         return (long)res_conv;
2005 }
2006 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
2007         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(arg & ~1);
2008         CHECK(!val->result_ok);
2009         LDKDecodeError err_var = (*val->contents.err);
2010         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2011         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2012         long err_ref = (long)err_var.inner & ~1;
2013         return err_ref;
2014 }
2015 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
2016         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
2017         ret->datalen = *((uint32_t*)elems);
2018         if (ret->datalen == 0) {
2019                 ret->data = NULL;
2020         } else {
2021                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
2022                 int64_t *java_elems = (int64_t*)(elems + 4);
2023                 for (size_t i = 0; i < ret->datalen; i++) {
2024                         ret->data[i] = java_elems[i];
2025                 }
2026         }
2027         return (long)ret;
2028 }
2029 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2030         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2031         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2032         return ret;
2033 }
2034 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
2035         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
2036         ret->datalen = *((uint32_t*)elems);
2037         if (ret->datalen == 0) {
2038                 ret->data = NULL;
2039         } else {
2040                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
2041                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2042                 for (size_t i = 0; i < ret->datalen; i++) {
2043                         uint32_t arr_elem = java_elems[i];
2044                         LDKUpdateAddHTLC arr_elem_conv;
2045                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2046                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2047                         arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
2048                         ret->data[i] = arr_elem_conv;
2049                 }
2050         }
2051         return (long)ret;
2052 }
2053 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
2054         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
2055         for (size_t i = 0; i < ret.datalen; i++) {
2056                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
2057         }
2058         return ret;
2059 }
2060 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
2061         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
2062         ret->datalen = *((uint32_t*)elems);
2063         if (ret->datalen == 0) {
2064                 ret->data = NULL;
2065         } else {
2066                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
2067                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2068                 for (size_t i = 0; i < ret->datalen; i++) {
2069                         uint32_t arr_elem = java_elems[i];
2070                         LDKUpdateFulfillHTLC arr_elem_conv;
2071                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2072                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2073                         arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
2074                         ret->data[i] = arr_elem_conv;
2075                 }
2076         }
2077         return (long)ret;
2078 }
2079 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
2080         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
2081         for (size_t i = 0; i < ret.datalen; i++) {
2082                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
2083         }
2084         return ret;
2085 }
2086 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
2087         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
2088         ret->datalen = *((uint32_t*)elems);
2089         if (ret->datalen == 0) {
2090                 ret->data = NULL;
2091         } else {
2092                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
2093                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2094                 for (size_t i = 0; i < ret->datalen; i++) {
2095                         uint32_t arr_elem = java_elems[i];
2096                         LDKUpdateFailHTLC arr_elem_conv;
2097                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2098                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2099                         arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
2100                         ret->data[i] = arr_elem_conv;
2101                 }
2102         }
2103         return (long)ret;
2104 }
2105 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
2106         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
2107         for (size_t i = 0; i < ret.datalen; i++) {
2108                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
2109         }
2110         return ret;
2111 }
2112 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
2113         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
2114         ret->datalen = *((uint32_t*)elems);
2115         if (ret->datalen == 0) {
2116                 ret->data = NULL;
2117         } else {
2118                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
2119                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2120                 for (size_t i = 0; i < ret->datalen; i++) {
2121                         uint32_t arr_elem = java_elems[i];
2122                         LDKUpdateFailMalformedHTLC arr_elem_conv;
2123                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2124                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2125                         arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
2126                         ret->data[i] = arr_elem_conv;
2127                 }
2128         }
2129         return (long)ret;
2130 }
2131 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
2132         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
2133         for (size_t i = 0; i < ret.datalen; i++) {
2134                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
2135         }
2136         return ret;
2137 }
2138 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
2139         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
2140 }
2141 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
2142         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
2143         CHECK(val->result_ok);
2144         return *val->contents.result;
2145 }
2146 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
2147         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
2148         CHECK(!val->result_ok);
2149         LDKLightningError err_var = (*val->contents.err);
2150         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2151         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2152         long err_ref = (long)err_var.inner & ~1;
2153         return err_ref;
2154 }
2155 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
2156         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
2157         LDKChannelAnnouncement a_conv;
2158         a_conv.inner = (void*)(a & (~1));
2159         a_conv.is_owned = (a & 1) || (a == 0);
2160         a_conv = ChannelAnnouncement_clone(&a_conv);
2161         ret->a = a_conv;
2162         LDKChannelUpdate b_conv;
2163         b_conv.inner = (void*)(b & (~1));
2164         b_conv.is_owned = (b & 1) || (b == 0);
2165         b_conv = ChannelUpdate_clone(&b_conv);
2166         ret->b = b_conv;
2167         LDKChannelUpdate c_conv;
2168         c_conv.inner = (void*)(c & (~1));
2169         c_conv.is_owned = (c & 1) || (c == 0);
2170         c_conv = ChannelUpdate_clone(&c_conv);
2171         ret->c = c_conv;
2172         return (long)ret;
2173 }
2174 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
2175         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2176         LDKChannelAnnouncement a_var = tuple->a;
2177         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2178         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2179         long a_ref = (long)a_var.inner & ~1;
2180         return a_ref;
2181 }
2182 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
2183         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2184         LDKChannelUpdate b_var = tuple->b;
2185         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2186         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2187         long b_ref = (long)b_var.inner & ~1;
2188         return b_ref;
2189 }
2190 uint32_t  __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
2191         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ptr & ~1);
2192         LDKChannelUpdate c_var = tuple->c;
2193         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2194         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2195         long c_ref = (long)c_var.inner & ~1;
2196         return c_ref;
2197 }
2198 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
2199         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
2200         ret->datalen = *((uint32_t*)elems);
2201         if (ret->datalen == 0) {
2202                 ret->data = NULL;
2203         } else {
2204                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
2205                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2206                 for (size_t i = 0; i < ret->datalen; i++) {
2207                         uint32_t arr_elem = java_elems[i];
2208                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1);
2209                         FREE((void*)arr_elem);
2210                         ret->data[i] = arr_elem_conv;
2211                 }
2212         }
2213         return (long)ret;
2214 }
2215 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
2216         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
2217         ret->datalen = *((uint32_t*)elems);
2218         if (ret->datalen == 0) {
2219                 ret->data = NULL;
2220         } else {
2221                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
2222                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2223                 for (size_t i = 0; i < ret->datalen; i++) {
2224                         uint32_t arr_elem = java_elems[i];
2225                         LDKNodeAnnouncement arr_elem_conv;
2226                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2227                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2228                         arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
2229                         ret->data[i] = arr_elem_conv;
2230                 }
2231         }
2232         return (long)ret;
2233 }
2234 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
2235         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
2236         for (size_t i = 0; i < ret.datalen; i++) {
2237                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
2238         }
2239         return ret;
2240 }
2241 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
2242         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
2243 }
2244 void  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
2245         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
2246         CHECK(val->result_ok);
2247         return *val->contents.result;
2248 }
2249 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
2250         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
2251         CHECK(!val->result_ok);
2252         LDKLightningError err_var = (*val->contents.err);
2253         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2254         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2255         long err_ref = (long)err_var.inner & ~1;
2256         return err_ref;
2257 }
2258 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
2259         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
2260 }
2261 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
2262         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
2263         CHECK(val->result_ok);
2264         LDKChannelReestablish res_var = (*val->contents.result);
2265         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2266         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2267         long res_ref = (long)res_var.inner & ~1;
2268         return res_ref;
2269 }
2270 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
2271         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
2272         CHECK(!val->result_ok);
2273         LDKDecodeError err_var = (*val->contents.err);
2274         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2275         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2276         long err_ref = (long)err_var.inner & ~1;
2277         return err_ref;
2278 }
2279 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
2280         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
2281 }
2282 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
2283         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
2284         CHECK(val->result_ok);
2285         LDKInit res_var = (*val->contents.result);
2286         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2287         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2288         long res_ref = (long)res_var.inner & ~1;
2289         return res_ref;
2290 }
2291 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
2292         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
2293         CHECK(!val->result_ok);
2294         LDKDecodeError err_var = (*val->contents.err);
2295         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2296         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2297         long err_ref = (long)err_var.inner & ~1;
2298         return err_ref;
2299 }
2300 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
2301         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
2302 }
2303 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
2304         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
2305         CHECK(val->result_ok);
2306         LDKPing res_var = (*val->contents.result);
2307         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2308         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2309         long res_ref = (long)res_var.inner & ~1;
2310         return res_ref;
2311 }
2312 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
2313         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
2314         CHECK(!val->result_ok);
2315         LDKDecodeError err_var = (*val->contents.err);
2316         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2317         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2318         long err_ref = (long)err_var.inner & ~1;
2319         return err_ref;
2320 }
2321 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
2322         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
2323 }
2324 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
2325         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
2326         CHECK(val->result_ok);
2327         LDKPong res_var = (*val->contents.result);
2328         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2329         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2330         long res_ref = (long)res_var.inner & ~1;
2331         return res_ref;
2332 }
2333 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
2334         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
2335         CHECK(!val->result_ok);
2336         LDKDecodeError err_var = (*val->contents.err);
2337         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2338         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2339         long err_ref = (long)err_var.inner & ~1;
2340         return err_ref;
2341 }
2342 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
2343         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
2344 }
2345 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
2346         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
2347         CHECK(val->result_ok);
2348         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
2349         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2350         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2351         long res_ref = (long)res_var.inner & ~1;
2352         return res_ref;
2353 }
2354 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
2355         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
2356         CHECK(!val->result_ok);
2357         LDKDecodeError err_var = (*val->contents.err);
2358         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2359         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2360         long err_ref = (long)err_var.inner & ~1;
2361         return err_ref;
2362 }
2363 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
2364         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
2365 }
2366 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
2367         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
2368         CHECK(val->result_ok);
2369         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
2370         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2371         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2372         long res_ref = (long)res_var.inner & ~1;
2373         return res_ref;
2374 }
2375 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
2376         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
2377         CHECK(!val->result_ok);
2378         LDKDecodeError err_var = (*val->contents.err);
2379         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2380         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2381         long err_ref = (long)err_var.inner & ~1;
2382         return err_ref;
2383 }
2384 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
2385         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
2386 }
2387 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
2388         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
2389         CHECK(val->result_ok);
2390         LDKErrorMessage res_var = (*val->contents.result);
2391         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2392         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2393         long res_ref = (long)res_var.inner & ~1;
2394         return res_ref;
2395 }
2396 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
2397         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
2398         CHECK(!val->result_ok);
2399         LDKDecodeError err_var = (*val->contents.err);
2400         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2401         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2402         long err_ref = (long)err_var.inner & ~1;
2403         return err_ref;
2404 }
2405 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
2406         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
2407 }
2408 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
2409         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
2410         CHECK(val->result_ok);
2411         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
2412         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2413         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2414         long res_ref = (long)res_var.inner & ~1;
2415         return res_ref;
2416 }
2417 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
2418         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
2419         CHECK(!val->result_ok);
2420         LDKDecodeError err_var = (*val->contents.err);
2421         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2422         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2423         long err_ref = (long)err_var.inner & ~1;
2424         return err_ref;
2425 }
2426 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
2427         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
2428 }
2429 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
2430         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
2431         CHECK(val->result_ok);
2432         LDKQueryShortChannelIds res_var = (*val->contents.result);
2433         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2434         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2435         long res_ref = (long)res_var.inner & ~1;
2436         return res_ref;
2437 }
2438 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
2439         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
2440         CHECK(!val->result_ok);
2441         LDKDecodeError err_var = (*val->contents.err);
2442         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2443         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2444         long err_ref = (long)err_var.inner & ~1;
2445         return err_ref;
2446 }
2447 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
2448         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
2449 }
2450 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
2451         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
2452         CHECK(val->result_ok);
2453         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
2454         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2455         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2456         long res_ref = (long)res_var.inner & ~1;
2457         return res_ref;
2458 }
2459 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
2460         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
2461         CHECK(!val->result_ok);
2462         LDKDecodeError err_var = (*val->contents.err);
2463         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2464         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2465         long err_ref = (long)err_var.inner & ~1;
2466         return err_ref;
2467 }
2468 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
2469         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
2470 }
2471 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
2472         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
2473         CHECK(val->result_ok);
2474         LDKQueryChannelRange res_var = (*val->contents.result);
2475         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2476         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2477         long res_ref = (long)res_var.inner & ~1;
2478         return res_ref;
2479 }
2480 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
2481         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
2482         CHECK(!val->result_ok);
2483         LDKDecodeError err_var = (*val->contents.err);
2484         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2485         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2486         long err_ref = (long)err_var.inner & ~1;
2487         return err_ref;
2488 }
2489 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
2490         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
2491 }
2492 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
2493         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
2494         CHECK(val->result_ok);
2495         LDKReplyChannelRange res_var = (*val->contents.result);
2496         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2497         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2498         long res_ref = (long)res_var.inner & ~1;
2499         return res_ref;
2500 }
2501 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
2502         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
2503         CHECK(!val->result_ok);
2504         LDKDecodeError err_var = (*val->contents.err);
2505         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2506         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2507         long err_ref = (long)err_var.inner & ~1;
2508         return err_ref;
2509 }
2510 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
2511         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
2512 }
2513 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
2514         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
2515         CHECK(val->result_ok);
2516         LDKGossipTimestampFilter res_var = (*val->contents.result);
2517         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2518         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2519         long res_ref = (long)res_var.inner & ~1;
2520         return res_ref;
2521 }
2522 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
2523         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
2524         CHECK(!val->result_ok);
2525         LDKDecodeError err_var = (*val->contents.err);
2526         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2527         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2528         long err_ref = (long)err_var.inner & ~1;
2529         return err_ref;
2530 }
2531 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
2532         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
2533 }
2534 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
2535         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
2536         CHECK(val->result_ok);
2537         LDKCVec_u8Z res_var = (*val->contents.result);
2538         int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2539         memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2540         return res_arr;
2541 }
2542 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
2543         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
2544         CHECK(!val->result_ok);
2545         LDKPeerHandleError err_var = (*val->contents.err);
2546         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2547         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2548         long err_ref = (long)err_var.inner & ~1;
2549         return err_ref;
2550 }
2551 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
2552         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
2553 }
2554 void  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
2555         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
2556         CHECK(val->result_ok);
2557         return *val->contents.result;
2558 }
2559 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
2560         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
2561         CHECK(!val->result_ok);
2562         LDKPeerHandleError err_var = (*val->contents.err);
2563         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2564         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2565         long err_ref = (long)err_var.inner & ~1;
2566         return err_ref;
2567 }
2568 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
2569         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
2570 }
2571 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
2572         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
2573         CHECK(val->result_ok);
2574         return *val->contents.result;
2575 }
2576 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
2577         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
2578         CHECK(!val->result_ok);
2579         LDKPeerHandleError 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_SecretKeySecpErrorZ_result_ok(uint32_t arg) {
2586         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
2587 }
2588 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeySecpErrorZ_get_ok(uint32_t arg) {
2589         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)(arg & ~1);
2590         CHECK(val->result_ok);
2591         int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2592         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
2593         return res_arr;
2594 }
2595 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_SecretKeySecpErrorZ_get_err(uint32_t arg) {
2596         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)(arg & ~1);
2597         CHECK(!val->result_ok);
2598         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2599         return err_conv;
2600 }
2601 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_result_ok(uint32_t arg) {
2602         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
2603 }
2604 int8_tArray  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_get_ok(uint32_t arg) {
2605         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)(arg & ~1);
2606         CHECK(val->result_ok);
2607         int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2608         memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
2609         return res_arr;
2610 }
2611 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_get_err(uint32_t arg) {
2612         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)(arg & ~1);
2613         CHECK(!val->result_ok);
2614         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2615         return err_conv;
2616 }
2617 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_result_ok(uint32_t arg) {
2618         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
2619 }
2620 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_get_ok(uint32_t arg) {
2621         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)(arg & ~1);
2622         CHECK(val->result_ok);
2623         LDKTxCreationKeys res_var = (*val->contents.result);
2624         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2625         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2626         long res_ref = (long)res_var.inner & ~1;
2627         return res_ref;
2628 }
2629 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_get_err(uint32_t arg) {
2630         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)(arg & ~1);
2631         CHECK(!val->result_ok);
2632         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2633         return err_conv;
2634 }
2635 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
2636         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
2637 }
2638 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
2639         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
2640         CHECK(val->result_ok);
2641         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
2642         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2643         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2644         long res_ref = (long)res_var.inner & ~1;
2645         return res_ref;
2646 }
2647 void  __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
2648         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
2649         CHECK(!val->result_ok);
2650         return *val->contents.err;
2651 }
2652 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
2653         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
2654 }
2655 ptrArray  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
2656         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
2657         CHECK(val->result_ok);
2658         LDKCVec_SignatureZ res_var = (*val->contents.result);
2659         ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
2660         int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
2661         for (size_t m = 0; m < res_var.datalen; m++) {
2662                 int8_tArray arr_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
2663                 memcpy((uint8_t*)(arr_conv_12_arr + 4), res_var.data[m].compact_form, 64);
2664                 res_arr_ptr[m] = arr_conv_12_arr;
2665         }
2666         return res_arr;
2667 }
2668 void  __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
2669         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
2670         CHECK(!val->result_ok);
2671         return *val->contents.err;
2672 }
2673 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
2674         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2675         ret->datalen = *((uint32_t*)elems);
2676         if (ret->datalen == 0) {
2677                 ret->data = NULL;
2678         } else {
2679                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2680                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2681                 for (size_t i = 0; i < ret->datalen; i++) {
2682                         uint32_t arr_elem = java_elems[i];
2683                         LDKRouteHop arr_elem_conv;
2684                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2685                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2686                         arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2687                         ret->data[i] = arr_elem_conv;
2688                 }
2689         }
2690         return (long)ret;
2691 }
2692 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2693         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2694         for (size_t i = 0; i < ret.datalen; i++) {
2695                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2696         }
2697         return ret;
2698 }
2699 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2700         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2701         for (size_t i = 0; i < ret.datalen; i++) {
2702                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2703         }
2704         return ret;
2705 }
2706 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
2707         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2708 }
2709 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
2710         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2711         CHECK(val->result_ok);
2712         LDKRoute res_var = (*val->contents.result);
2713         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2714         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2715         long res_ref = (long)res_var.inner & ~1;
2716         return res_ref;
2717 }
2718 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
2719         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
2720         CHECK(!val->result_ok);
2721         LDKDecodeError err_var = (*val->contents.err);
2722         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2723         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2724         long err_ref = (long)err_var.inner & ~1;
2725         return err_ref;
2726 }
2727 uint32_t  __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
2728         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2729         ret->datalen = *((uint32_t*)elems);
2730         if (ret->datalen == 0) {
2731                 ret->data = NULL;
2732         } else {
2733                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2734                 uint32_t *java_elems = (uint32_t*)(elems + 4);
2735                 for (size_t i = 0; i < ret->datalen; i++) {
2736                         uint32_t arr_elem = java_elems[i];
2737                         LDKRouteHint arr_elem_conv;
2738                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2739                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2740                         arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2741                         ret->data[i] = arr_elem_conv;
2742                 }
2743         }
2744         return (long)ret;
2745 }
2746 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2747         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2748         for (size_t i = 0; i < ret.datalen; i++) {
2749                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2750         }
2751         return ret;
2752 }
2753 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
2754         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
2755 }
2756 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
2757         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
2758         CHECK(val->result_ok);
2759         LDKRoute 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_RouteLightningErrorZ_get_err(uint32_t arg) {
2766         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
2767         CHECK(!val->result_ok);
2768         LDKLightningError 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_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
2775         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
2776 }
2777 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
2778         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
2779         CHECK(val->result_ok);
2780         LDKRoutingFees res_var = (*val->contents.result);
2781         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2782         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2783         long res_ref = (long)res_var.inner & ~1;
2784         return res_ref;
2785 }
2786 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
2787         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
2788         CHECK(!val->result_ok);
2789         LDKDecodeError err_var = (*val->contents.err);
2790         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2791         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2792         long err_ref = (long)err_var.inner & ~1;
2793         return err_ref;
2794 }
2795 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
2796         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
2797 }
2798 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
2799         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
2800         CHECK(val->result_ok);
2801         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
2802         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2803         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2804         long res_ref = (long)res_var.inner & ~1;
2805         return res_ref;
2806 }
2807 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
2808         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
2809         CHECK(!val->result_ok);
2810         LDKDecodeError err_var = (*val->contents.err);
2811         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2812         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2813         long err_ref = (long)err_var.inner & ~1;
2814         return err_ref;
2815 }
2816 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
2817         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
2818 }
2819 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
2820         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
2821         CHECK(val->result_ok);
2822         LDKNodeInfo res_var = (*val->contents.result);
2823         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2824         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2825         long res_ref = (long)res_var.inner & ~1;
2826         return res_ref;
2827 }
2828 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
2829         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
2830         CHECK(!val->result_ok);
2831         LDKDecodeError err_var = (*val->contents.err);
2832         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2833         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2834         long err_ref = (long)err_var.inner & ~1;
2835         return err_ref;
2836 }
2837 jboolean  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
2838         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
2839 }
2840 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
2841         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
2842         CHECK(val->result_ok);
2843         LDKNetworkGraph res_var = (*val->contents.result);
2844         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2845         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2846         long res_ref = (long)res_var.inner & ~1;
2847         return res_ref;
2848 }
2849 uint32_t  __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
2850         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
2851         CHECK(!val->result_ok);
2852         LDKDecodeError err_var = (*val->contents.err);
2853         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2854         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2855         long err_ref = (long)err_var.inner & ~1;
2856         return err_ref;
2857 }
2858 typedef struct LDKMessageSendEventsProvider_JCalls {
2859         atomic_size_t refcnt;
2860         uint32_t get_and_clear_pending_msg_events_meth;
2861 } LDKMessageSendEventsProvider_JCalls;
2862 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
2863         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
2864         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2865                 js_free(j_calls->get_and_clear_pending_msg_events_meth);
2866                 FREE(j_calls);
2867         }
2868 }
2869 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
2870         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
2871         uint32_tArray arg = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
2872         LDKCVec_MessageSendEventZ arg_constr;
2873         arg_constr.datalen = *((uint32_t*)arg);
2874         if (arg_constr.datalen > 0)
2875                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
2876         else
2877                 arg_constr.data = NULL;
2878         uint32_t* arg_vals = (uint32_t*)(arg + 4);
2879         for (size_t s = 0; s < arg_constr.datalen; s++) {
2880                 uint32_t arr_conv_18 = arg_vals[s];
2881                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_conv_18) & ~1);
2882                 FREE((void*)arr_conv_18);
2883                 arg_constr.data[s] = arr_conv_18_conv;
2884         }
2885         return arg_constr;
2886 }
2887 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
2888         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
2889         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2890         return (void*) this_arg;
2891 }
2892 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
2893         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
2894         atomic_init(&calls->refcnt, 1);
2895         //TODO: Assign calls->o from o
2896
2897         LDKMessageSendEventsProvider ret = {
2898                 .this_arg = (void*) calls,
2899                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
2900                 .free = LDKMessageSendEventsProvider_JCalls_free,
2901         };
2902         return ret;
2903 }
2904 long  __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
2905         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
2906         *res_ptr = LDKMessageSendEventsProvider_init(o);
2907         return (long)res_ptr;
2908 }
2909 uint32_tArray  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
2910         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
2911         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
2912         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2913         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2914         for (size_t s = 0; s < ret_var.datalen; s++) {
2915                 LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
2916                 *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
2917                 long arr_conv_18_ref = (long)arr_conv_18_copy;
2918                 ret_arr_ptr[s] = arr_conv_18_ref;
2919         }
2920         FREE(ret_var.data);
2921         return ret_arr;
2922 }
2923
2924 typedef struct LDKEventsProvider_JCalls {
2925         atomic_size_t refcnt;
2926         uint32_t get_and_clear_pending_events_meth;
2927 } LDKEventsProvider_JCalls;
2928 static void LDKEventsProvider_JCalls_free(void* this_arg) {
2929         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
2930         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2931                 js_free(j_calls->get_and_clear_pending_events_meth);
2932                 FREE(j_calls);
2933         }
2934 }
2935 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
2936         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
2937         uint32_tArray arg = js_invoke_function_0(j_calls->get_and_clear_pending_events_meth);
2938         LDKCVec_EventZ arg_constr;
2939         arg_constr.datalen = *((uint32_t*)arg);
2940         if (arg_constr.datalen > 0)
2941                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
2942         else
2943                 arg_constr.data = NULL;
2944         uint32_t* arg_vals = (uint32_t*)(arg + 4);
2945         for (size_t h = 0; h < arg_constr.datalen; h++) {
2946                 uint32_t arr_conv_7 = arg_vals[h];
2947                 LDKEvent arr_conv_7_conv = *(LDKEvent*)(((uint64_t)arr_conv_7) & ~1);
2948                 FREE((void*)arr_conv_7);
2949                 arg_constr.data[h] = arr_conv_7_conv;
2950         }
2951         return arg_constr;
2952 }
2953 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
2954         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
2955         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2956         return (void*) this_arg;
2957 }
2958 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
2959         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
2960         atomic_init(&calls->refcnt, 1);
2961         //TODO: Assign calls->o from o
2962
2963         LDKEventsProvider ret = {
2964                 .this_arg = (void*) calls,
2965                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
2966                 .free = LDKEventsProvider_JCalls_free,
2967         };
2968         return ret;
2969 }
2970 long  __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
2971         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
2972         *res_ptr = LDKEventsProvider_init(o);
2973         return (long)res_ptr;
2974 }
2975 uint32_tArray  __attribute__((visibility("default"))) TS_EventsProvider_get_and_clear_pending_events(uint32_t this_arg) {
2976         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
2977         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
2978         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
2979         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
2980         for (size_t h = 0; h < ret_var.datalen; h++) {
2981                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
2982                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
2983                 long arr_conv_7_ref = (long)arr_conv_7_copy;
2984                 ret_arr_ptr[h] = arr_conv_7_ref;
2985         }
2986         FREE(ret_var.data);
2987         return ret_arr;
2988 }
2989
2990 typedef struct LDKAccess_JCalls {
2991         atomic_size_t refcnt;
2992         uint32_t get_utxo_meth;
2993 } LDKAccess_JCalls;
2994 static void LDKAccess_JCalls_free(void* this_arg) {
2995         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
2996         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2997                 js_free(j_calls->get_utxo_meth);
2998                 FREE(j_calls);
2999         }
3000 }
3001 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3002         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3003         int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3004         memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
3005         LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
3006         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1);
3007         ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)ret);
3008         return ret_conv;
3009 }
3010 static void* LDKAccess_JCalls_clone(const void* this_arg) {
3011         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3012         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3013         return (void*) this_arg;
3014 }
3015 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
3016         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3017         atomic_init(&calls->refcnt, 1);
3018         //TODO: Assign calls->o from o
3019
3020         LDKAccess ret = {
3021                 .this_arg = (void*) calls,
3022                 .get_utxo = get_utxo_jcall,
3023                 .free = LDKAccess_JCalls_free,
3024         };
3025         return ret;
3026 }
3027 long  __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
3028         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3029         *res_ptr = LDKAccess_init(o);
3030         return (long)res_ptr;
3031 }
3032 uint32_t  __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
3033         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
3034         unsigned char genesis_hash_arr[32];
3035         CHECK(*((uint32_t*)genesis_hash) == 32);
3036         memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
3037         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3038         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3039         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3040         return (long)ret_conv;
3041 }
3042
3043 typedef struct LDKFilter_JCalls {
3044         atomic_size_t refcnt;
3045         uint32_t register_tx_meth;
3046         uint32_t register_output_meth;
3047 } LDKFilter_JCalls;
3048 static void LDKFilter_JCalls_free(void* this_arg) {
3049         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3050         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3051                 js_free(j_calls->register_tx_meth);
3052                 js_free(j_calls->register_output_meth);
3053                 FREE(j_calls);
3054         }
3055 }
3056 void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
3057         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3058         int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3059         memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
3060         LDKu8slice script_pubkey_var = script_pubkey;
3061         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3062         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
3063         js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
3064 }
3065 void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
3066         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3067         LDKOutPoint outpoint_var = *outpoint;
3068         outpoint_var = OutPoint_clone(outpoint);
3069         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3070         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3071         long outpoint_ref = (long)outpoint_var.inner;
3072         if (outpoint_var.is_owned) {
3073                 outpoint_ref |= 1;
3074         }
3075         LDKu8slice script_pubkey_var = script_pubkey;
3076         int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3077         memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
3078         js_invoke_function_2(j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
3079 }
3080 static void* LDKFilter_JCalls_clone(const void* this_arg) {
3081         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3082         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3083         return (void*) this_arg;
3084 }
3085 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
3086         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
3087         atomic_init(&calls->refcnt, 1);
3088         //TODO: Assign calls->o from o
3089
3090         LDKFilter ret = {
3091                 .this_arg = (void*) calls,
3092                 .register_tx = register_tx_jcall,
3093                 .register_output = register_output_jcall,
3094                 .free = LDKFilter_JCalls_free,
3095         };
3096         return ret;
3097 }
3098 long  __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
3099         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
3100         *res_ptr = LDKFilter_init(o);
3101         return (long)res_ptr;
3102 }
3103 void  __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
3104         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
3105         unsigned char txid_arr[32];
3106         CHECK(*((uint32_t*)txid) == 32);
3107         memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
3108         unsigned char (*txid_ref)[32] = &txid_arr;
3109         LDKu8slice script_pubkey_ref;
3110         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
3111         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
3112         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
3113 }
3114
3115 void  __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t outpoint, int8_tArray script_pubkey) {
3116         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
3117         LDKOutPoint outpoint_conv;
3118         outpoint_conv.inner = (void*)(outpoint & (~1));
3119         outpoint_conv.is_owned = false;
3120         LDKu8slice script_pubkey_ref;
3121         script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
3122         script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
3123         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
3124 }
3125
3126 typedef struct LDKPersist_JCalls {
3127         atomic_size_t refcnt;
3128         uint32_t persist_new_channel_meth;
3129         uint32_t update_persisted_channel_meth;
3130 } LDKPersist_JCalls;
3131 static void LDKPersist_JCalls_free(void* this_arg) {
3132         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3133         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3134                 js_free(j_calls->persist_new_channel_meth);
3135                 js_free(j_calls->update_persisted_channel_meth);
3136                 FREE(j_calls);
3137         }
3138 }
3139 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
3140         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3141         LDKOutPoint id_var = id;
3142         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3143         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3144         long id_ref = (long)id_var.inner;
3145         if (id_var.is_owned) {
3146                 id_ref |= 1;
3147         }
3148         LDKChannelMonitor data_var = *data;
3149         data_var = ChannelMonitor_clone(data);
3150         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3151         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3152         long data_ref = (long)data_var.inner;
3153         if (data_var.is_owned) {
3154                 data_ref |= 1;
3155         }
3156         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
3157         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3158         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
3159         return ret_conv;
3160 }
3161 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
3162         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3163         LDKOutPoint id_var = id;
3164         CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3165         CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3166         long id_ref = (long)id_var.inner;
3167         if (id_var.is_owned) {
3168                 id_ref |= 1;
3169         }
3170         LDKChannelMonitorUpdate update_var = *update;
3171         update_var = ChannelMonitorUpdate_clone(update);
3172         CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3173         CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3174         long update_ref = (long)update_var.inner;
3175         if (update_var.is_owned) {
3176                 update_ref |= 1;
3177         }
3178         LDKChannelMonitor data_var = *data;
3179         data_var = ChannelMonitor_clone(data);
3180         CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3181         CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3182         long data_ref = (long)data_var.inner;
3183         if (data_var.is_owned) {
3184                 data_ref |= 1;
3185         }
3186         LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
3187         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1);
3188         ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)ret);
3189         return ret_conv;
3190 }
3191 static void* LDKPersist_JCalls_clone(const void* this_arg) {
3192         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3193         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3194         return (void*) this_arg;
3195 }
3196 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
3197         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
3198         atomic_init(&calls->refcnt, 1);
3199         //TODO: Assign calls->o from o
3200
3201         LDKPersist ret = {
3202                 .this_arg = (void*) calls,
3203                 .persist_new_channel = persist_new_channel_jcall,
3204                 .update_persisted_channel = update_persisted_channel_jcall,
3205                 .free = LDKPersist_JCalls_free,
3206         };
3207         return ret;
3208 }
3209 long  __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
3210         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
3211         *res_ptr = LDKPersist_init(o);
3212         return (long)res_ptr;
3213 }
3214 uint32_t  __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
3215         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
3216         LDKOutPoint id_conv;
3217         id_conv.inner = (void*)(id & (~1));
3218         id_conv.is_owned = (id & 1) || (id == 0);
3219         id_conv = OutPoint_clone(&id_conv);
3220         LDKChannelMonitor data_conv;
3221         data_conv.inner = (void*)(data & (~1));
3222         data_conv.is_owned = false;
3223         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3224         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
3225         return (long)ret_conv;
3226 }
3227
3228 uint32_t  __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
3229         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
3230         LDKOutPoint id_conv;
3231         id_conv.inner = (void*)(id & (~1));
3232         id_conv.is_owned = (id & 1) || (id == 0);
3233         id_conv = OutPoint_clone(&id_conv);
3234         LDKChannelMonitorUpdate update_conv;
3235         update_conv.inner = (void*)(update & (~1));
3236         update_conv.is_owned = false;
3237         LDKChannelMonitor data_conv;
3238         data_conv.inner = (void*)(data & (~1));
3239         data_conv.is_owned = false;
3240         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3241         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
3242         return (long)ret_conv;
3243 }
3244
3245 typedef struct LDKChannelMessageHandler_JCalls {
3246         atomic_size_t refcnt;
3247         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
3248         uint32_t handle_open_channel_meth;
3249         uint32_t handle_accept_channel_meth;
3250         uint32_t handle_funding_created_meth;
3251         uint32_t handle_funding_signed_meth;
3252         uint32_t handle_funding_locked_meth;
3253         uint32_t handle_shutdown_meth;
3254         uint32_t handle_closing_signed_meth;
3255         uint32_t handle_update_add_htlc_meth;
3256         uint32_t handle_update_fulfill_htlc_meth;
3257         uint32_t handle_update_fail_htlc_meth;
3258         uint32_t handle_update_fail_malformed_htlc_meth;
3259         uint32_t handle_commitment_signed_meth;
3260         uint32_t handle_revoke_and_ack_meth;
3261         uint32_t handle_update_fee_meth;
3262         uint32_t handle_announcement_signatures_meth;
3263         uint32_t peer_disconnected_meth;
3264         uint32_t peer_connected_meth;
3265         uint32_t handle_channel_reestablish_meth;
3266         uint32_t handle_error_meth;
3267 } LDKChannelMessageHandler_JCalls;
3268 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
3269         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3270         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3271                 js_free(j_calls->handle_open_channel_meth);
3272                 js_free(j_calls->handle_accept_channel_meth);
3273                 js_free(j_calls->handle_funding_created_meth);
3274                 js_free(j_calls->handle_funding_signed_meth);
3275                 js_free(j_calls->handle_funding_locked_meth);
3276                 js_free(j_calls->handle_shutdown_meth);
3277                 js_free(j_calls->handle_closing_signed_meth);
3278                 js_free(j_calls->handle_update_add_htlc_meth);
3279                 js_free(j_calls->handle_update_fulfill_htlc_meth);
3280                 js_free(j_calls->handle_update_fail_htlc_meth);
3281                 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
3282                 js_free(j_calls->handle_commitment_signed_meth);
3283                 js_free(j_calls->handle_revoke_and_ack_meth);
3284                 js_free(j_calls->handle_update_fee_meth);
3285                 js_free(j_calls->handle_announcement_signatures_meth);
3286                 js_free(j_calls->peer_disconnected_meth);
3287                 js_free(j_calls->peer_connected_meth);
3288                 js_free(j_calls->handle_channel_reestablish_meth);
3289                 js_free(j_calls->handle_error_meth);
3290                 FREE(j_calls);
3291         }
3292 }
3293 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
3294         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3295         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3296         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3297         LDKInitFeatures their_features_var = their_features;
3298         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3299         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3300         long their_features_ref = (long)their_features_var.inner;
3301         if (their_features_var.is_owned) {
3302                 their_features_ref |= 1;
3303         }
3304         LDKOpenChannel msg_var = *msg;
3305         msg_var = OpenChannel_clone(msg);
3306         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3307         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3308         long msg_ref = (long)msg_var.inner;
3309         if (msg_var.is_owned) {
3310                 msg_ref |= 1;
3311         }
3312         js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
3313 }
3314 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
3315         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3316         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3317         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3318         LDKInitFeatures their_features_var = their_features;
3319         CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3320         CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3321         long their_features_ref = (long)their_features_var.inner;
3322         if (their_features_var.is_owned) {
3323                 their_features_ref |= 1;
3324         }
3325         LDKAcceptChannel msg_var = *msg;
3326         msg_var = AcceptChannel_clone(msg);
3327         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3328         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3329         long msg_ref = (long)msg_var.inner;
3330         if (msg_var.is_owned) {
3331                 msg_ref |= 1;
3332         }
3333         js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
3334 }
3335 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
3336         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3337         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3338         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3339         LDKFundingCreated msg_var = *msg;
3340         msg_var = FundingCreated_clone(msg);
3341         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3342         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3343         long msg_ref = (long)msg_var.inner;
3344         if (msg_var.is_owned) {
3345                 msg_ref |= 1;
3346         }
3347         js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
3348 }
3349 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
3350         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3351         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3352         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3353         LDKFundingSigned msg_var = *msg;
3354         msg_var = FundingSigned_clone(msg);
3355         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3356         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3357         long msg_ref = (long)msg_var.inner;
3358         if (msg_var.is_owned) {
3359                 msg_ref |= 1;
3360         }
3361         js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
3362 }
3363 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
3364         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3365         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3366         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3367         LDKFundingLocked msg_var = *msg;
3368         msg_var = FundingLocked_clone(msg);
3369         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3370         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3371         long msg_ref = (long)msg_var.inner;
3372         if (msg_var.is_owned) {
3373                 msg_ref |= 1;
3374         }
3375         js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
3376 }
3377 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
3378         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3379         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3380         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3381         LDKShutdown msg_var = *msg;
3382         msg_var = Shutdown_clone(msg);
3383         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3384         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3385         long msg_ref = (long)msg_var.inner;
3386         if (msg_var.is_owned) {
3387                 msg_ref |= 1;
3388         }
3389         js_invoke_function_2(j_calls->handle_shutdown_meth, their_node_id_arr, msg_ref);
3390 }
3391 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
3392         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3393         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3394         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3395         LDKClosingSigned msg_var = *msg;
3396         msg_var = ClosingSigned_clone(msg);
3397         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3398         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3399         long msg_ref = (long)msg_var.inner;
3400         if (msg_var.is_owned) {
3401                 msg_ref |= 1;
3402         }
3403         js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
3404 }
3405 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
3406         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3407         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3408         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3409         LDKUpdateAddHTLC msg_var = *msg;
3410         msg_var = UpdateAddHTLC_clone(msg);
3411         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3412         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3413         long msg_ref = (long)msg_var.inner;
3414         if (msg_var.is_owned) {
3415                 msg_ref |= 1;
3416         }
3417         js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
3418 }
3419 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
3420         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3421         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3422         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3423         LDKUpdateFulfillHTLC msg_var = *msg;
3424         msg_var = UpdateFulfillHTLC_clone(msg);
3425         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3426         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3427         long msg_ref = (long)msg_var.inner;
3428         if (msg_var.is_owned) {
3429                 msg_ref |= 1;
3430         }
3431         js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
3432 }
3433 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
3434         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3435         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3436         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3437         LDKUpdateFailHTLC msg_var = *msg;
3438         msg_var = UpdateFailHTLC_clone(msg);
3439         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3440         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3441         long msg_ref = (long)msg_var.inner;
3442         if (msg_var.is_owned) {
3443                 msg_ref |= 1;
3444         }
3445         js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
3446 }
3447 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
3448         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3449         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3450         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3451         LDKUpdateFailMalformedHTLC msg_var = *msg;
3452         msg_var = UpdateFailMalformedHTLC_clone(msg);
3453         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3454         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3455         long msg_ref = (long)msg_var.inner;
3456         if (msg_var.is_owned) {
3457                 msg_ref |= 1;
3458         }
3459         js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
3460 }
3461 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
3462         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3463         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3464         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3465         LDKCommitmentSigned msg_var = *msg;
3466         msg_var = CommitmentSigned_clone(msg);
3467         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3468         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3469         long msg_ref = (long)msg_var.inner;
3470         if (msg_var.is_owned) {
3471                 msg_ref |= 1;
3472         }
3473         js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
3474 }
3475 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
3476         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3477         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3478         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3479         LDKRevokeAndACK msg_var = *msg;
3480         msg_var = RevokeAndACK_clone(msg);
3481         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3482         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3483         long msg_ref = (long)msg_var.inner;
3484         if (msg_var.is_owned) {
3485                 msg_ref |= 1;
3486         }
3487         js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
3488 }
3489 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
3490         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3491         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3492         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3493         LDKUpdateFee msg_var = *msg;
3494         msg_var = UpdateFee_clone(msg);
3495         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3496         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3497         long msg_ref = (long)msg_var.inner;
3498         if (msg_var.is_owned) {
3499                 msg_ref |= 1;
3500         }
3501         js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
3502 }
3503 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
3504         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3505         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3506         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3507         LDKAnnouncementSignatures msg_var = *msg;
3508         msg_var = AnnouncementSignatures_clone(msg);
3509         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3510         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3511         long msg_ref = (long)msg_var.inner;
3512         if (msg_var.is_owned) {
3513                 msg_ref |= 1;
3514         }
3515         js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
3516 }
3517 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
3518         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3519         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3520         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3521         js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
3522 }
3523 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
3524         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3525         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3526         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3527         LDKInit msg_var = *msg;
3528         msg_var = Init_clone(msg);
3529         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3530         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3531         long msg_ref = (long)msg_var.inner;
3532         if (msg_var.is_owned) {
3533                 msg_ref |= 1;
3534         }
3535         js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
3536 }
3537 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
3538         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3539         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3540         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3541         LDKChannelReestablish msg_var = *msg;
3542         msg_var = ChannelReestablish_clone(msg);
3543         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3544         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3545         long msg_ref = (long)msg_var.inner;
3546         if (msg_var.is_owned) {
3547                 msg_ref |= 1;
3548         }
3549         js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
3550 }
3551 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
3552         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3553         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3554         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3555         LDKErrorMessage msg_var = *msg;
3556         msg_var = ErrorMessage_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_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
3564 }
3565 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
3566         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3567         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3568         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
3569         return (void*) this_arg;
3570 }
3571 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
3572         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
3573         atomic_init(&calls->refcnt, 1);
3574         //TODO: Assign calls->o from o
3575
3576         LDKChannelMessageHandler ret = {
3577                 .this_arg = (void*) calls,
3578                 .handle_open_channel = handle_open_channel_jcall,
3579                 .handle_accept_channel = handle_accept_channel_jcall,
3580                 .handle_funding_created = handle_funding_created_jcall,
3581                 .handle_funding_signed = handle_funding_signed_jcall,
3582                 .handle_funding_locked = handle_funding_locked_jcall,
3583                 .handle_shutdown = handle_shutdown_jcall,
3584                 .handle_closing_signed = handle_closing_signed_jcall,
3585                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3586                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3587                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3588                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3589                 .handle_commitment_signed = handle_commitment_signed_jcall,
3590                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3591                 .handle_update_fee = handle_update_fee_jcall,
3592                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3593                 .peer_disconnected = peer_disconnected_jcall,
3594                 .peer_connected = peer_connected_jcall,
3595                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3596                 .handle_error = handle_error_jcall,
3597                 .free = LDKChannelMessageHandler_JCalls_free,
3598                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
3599         };
3600         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3601         return ret;
3602 }
3603 long  __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
3604         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3605         *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
3606         return (long)res_ptr;
3607 }
3608 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) {
3609         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3610         LDKPublicKey their_node_id_ref;
3611         CHECK(*((uint32_t*)their_node_id) == 33);
3612         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3613         LDKInitFeatures their_features_conv;
3614         their_features_conv.inner = (void*)(their_features & (~1));
3615         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3616         // Warning: we need a move here but no clone is available for LDKInitFeatures
3617         LDKOpenChannel msg_conv;
3618         msg_conv.inner = (void*)(msg & (~1));
3619         msg_conv.is_owned = false;
3620         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3621 }
3622
3623 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) {
3624         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3625         LDKPublicKey their_node_id_ref;
3626         CHECK(*((uint32_t*)their_node_id) == 33);
3627         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3628         LDKInitFeatures their_features_conv;
3629         their_features_conv.inner = (void*)(their_features & (~1));
3630         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3631         // Warning: we need a move here but no clone is available for LDKInitFeatures
3632         LDKAcceptChannel msg_conv;
3633         msg_conv.inner = (void*)(msg & (~1));
3634         msg_conv.is_owned = false;
3635         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3636 }
3637
3638 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3639         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3640         LDKPublicKey their_node_id_ref;
3641         CHECK(*((uint32_t*)their_node_id) == 33);
3642         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3643         LDKFundingCreated msg_conv;
3644         msg_conv.inner = (void*)(msg & (~1));
3645         msg_conv.is_owned = false;
3646         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3647 }
3648
3649 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3650         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3651         LDKPublicKey their_node_id_ref;
3652         CHECK(*((uint32_t*)their_node_id) == 33);
3653         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3654         LDKFundingSigned msg_conv;
3655         msg_conv.inner = (void*)(msg & (~1));
3656         msg_conv.is_owned = false;
3657         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3658 }
3659
3660 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3661         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3662         LDKPublicKey their_node_id_ref;
3663         CHECK(*((uint32_t*)their_node_id) == 33);
3664         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3665         LDKFundingLocked msg_conv;
3666         msg_conv.inner = (void*)(msg & (~1));
3667         msg_conv.is_owned = false;
3668         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3669 }
3670
3671 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3672         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3673         LDKPublicKey their_node_id_ref;
3674         CHECK(*((uint32_t*)their_node_id) == 33);
3675         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3676         LDKShutdown msg_conv;
3677         msg_conv.inner = (void*)(msg & (~1));
3678         msg_conv.is_owned = false;
3679         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3680 }
3681
3682 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3683         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3684         LDKPublicKey their_node_id_ref;
3685         CHECK(*((uint32_t*)their_node_id) == 33);
3686         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3687         LDKClosingSigned msg_conv;
3688         msg_conv.inner = (void*)(msg & (~1));
3689         msg_conv.is_owned = false;
3690         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3691 }
3692
3693 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3694         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3695         LDKPublicKey their_node_id_ref;
3696         CHECK(*((uint32_t*)their_node_id) == 33);
3697         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3698         LDKUpdateAddHTLC msg_conv;
3699         msg_conv.inner = (void*)(msg & (~1));
3700         msg_conv.is_owned = false;
3701         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3702 }
3703
3704 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3705         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3706         LDKPublicKey their_node_id_ref;
3707         CHECK(*((uint32_t*)their_node_id) == 33);
3708         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3709         LDKUpdateFulfillHTLC msg_conv;
3710         msg_conv.inner = (void*)(msg & (~1));
3711         msg_conv.is_owned = false;
3712         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3713 }
3714
3715 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3716         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3717         LDKPublicKey their_node_id_ref;
3718         CHECK(*((uint32_t*)their_node_id) == 33);
3719         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3720         LDKUpdateFailHTLC msg_conv;
3721         msg_conv.inner = (void*)(msg & (~1));
3722         msg_conv.is_owned = false;
3723         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3724 }
3725
3726 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3727         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3728         LDKPublicKey their_node_id_ref;
3729         CHECK(*((uint32_t*)their_node_id) == 33);
3730         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3731         LDKUpdateFailMalformedHTLC msg_conv;
3732         msg_conv.inner = (void*)(msg & (~1));
3733         msg_conv.is_owned = false;
3734         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3735 }
3736
3737 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3738         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3739         LDKPublicKey their_node_id_ref;
3740         CHECK(*((uint32_t*)their_node_id) == 33);
3741         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3742         LDKCommitmentSigned msg_conv;
3743         msg_conv.inner = (void*)(msg & (~1));
3744         msg_conv.is_owned = false;
3745         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3746 }
3747
3748 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3749         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3750         LDKPublicKey their_node_id_ref;
3751         CHECK(*((uint32_t*)their_node_id) == 33);
3752         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3753         LDKRevokeAndACK msg_conv;
3754         msg_conv.inner = (void*)(msg & (~1));
3755         msg_conv.is_owned = false;
3756         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3757 }
3758
3759 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3760         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3761         LDKPublicKey their_node_id_ref;
3762         CHECK(*((uint32_t*)their_node_id) == 33);
3763         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3764         LDKUpdateFee msg_conv;
3765         msg_conv.inner = (void*)(msg & (~1));
3766         msg_conv.is_owned = false;
3767         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3768 }
3769
3770 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3771         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3772         LDKPublicKey their_node_id_ref;
3773         CHECK(*((uint32_t*)their_node_id) == 33);
3774         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3775         LDKAnnouncementSignatures msg_conv;
3776         msg_conv.inner = (void*)(msg & (~1));
3777         msg_conv.is_owned = false;
3778         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3779 }
3780
3781 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
3782         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3783         LDKPublicKey their_node_id_ref;
3784         CHECK(*((uint32_t*)their_node_id) == 33);
3785         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3786         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
3787 }
3788
3789 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3790         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3791         LDKPublicKey their_node_id_ref;
3792         CHECK(*((uint32_t*)their_node_id) == 33);
3793         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3794         LDKInit msg_conv;
3795         msg_conv.inner = (void*)(msg & (~1));
3796         msg_conv.is_owned = false;
3797         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3798 }
3799
3800 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3801         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3802         LDKPublicKey their_node_id_ref;
3803         CHECK(*((uint32_t*)their_node_id) == 33);
3804         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3805         LDKChannelReestablish msg_conv;
3806         msg_conv.inner = (void*)(msg & (~1));
3807         msg_conv.is_owned = false;
3808         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3809 }
3810
3811 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3812         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3813         LDKPublicKey their_node_id_ref;
3814         CHECK(*((uint32_t*)their_node_id) == 33);
3815         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3816         LDKErrorMessage msg_conv;
3817         msg_conv.inner = (void*)(msg & (~1));
3818         msg_conv.is_owned = false;
3819         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3820 }
3821
3822 typedef struct LDKRoutingMessageHandler_JCalls {
3823         atomic_size_t refcnt;
3824         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
3825         uint32_t handle_node_announcement_meth;
3826         uint32_t handle_channel_announcement_meth;
3827         uint32_t handle_channel_update_meth;
3828         uint32_t handle_htlc_fail_channel_update_meth;
3829         uint32_t get_next_channel_announcements_meth;
3830         uint32_t get_next_node_announcements_meth;
3831         uint32_t sync_routing_table_meth;
3832         uint32_t handle_reply_channel_range_meth;
3833         uint32_t handle_reply_short_channel_ids_end_meth;
3834         uint32_t handle_query_channel_range_meth;
3835         uint32_t handle_query_short_channel_ids_meth;
3836 } LDKRoutingMessageHandler_JCalls;
3837 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
3838         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3839         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3840                 js_free(j_calls->handle_node_announcement_meth);
3841                 js_free(j_calls->handle_channel_announcement_meth);
3842                 js_free(j_calls->handle_channel_update_meth);
3843                 js_free(j_calls->handle_htlc_fail_channel_update_meth);
3844                 js_free(j_calls->get_next_channel_announcements_meth);
3845                 js_free(j_calls->get_next_node_announcements_meth);
3846                 js_free(j_calls->sync_routing_table_meth);
3847                 js_free(j_calls->handle_reply_channel_range_meth);
3848                 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
3849                 js_free(j_calls->handle_query_channel_range_meth);
3850                 js_free(j_calls->handle_query_short_channel_ids_meth);
3851                 FREE(j_calls);
3852         }
3853 }
3854 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
3855         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3856         LDKNodeAnnouncement msg_var = *msg;
3857         msg_var = NodeAnnouncement_clone(msg);
3858         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3859         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3860         long msg_ref = (long)msg_var.inner;
3861         if (msg_var.is_owned) {
3862                 msg_ref |= 1;
3863         }
3864         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
3865         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
3866         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
3867         return ret_conv;
3868 }
3869 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
3870         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3871         LDKChannelAnnouncement msg_var = *msg;
3872         msg_var = ChannelAnnouncement_clone(msg);
3873         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3874         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3875         long msg_ref = (long)msg_var.inner;
3876         if (msg_var.is_owned) {
3877                 msg_ref |= 1;
3878         }
3879         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
3880         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
3881         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
3882         return ret_conv;
3883 }
3884 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
3885         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3886         LDKChannelUpdate msg_var = *msg;
3887         msg_var = ChannelUpdate_clone(msg);
3888         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3889         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3890         long msg_ref = (long)msg_var.inner;
3891         if (msg_var.is_owned) {
3892                 msg_ref |= 1;
3893         }
3894         LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
3895         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)ret) & ~1);
3896         ret_conv = CResult_boolLightningErrorZ_clone((LDKCResult_boolLightningErrorZ*)ret);
3897         return ret_conv;
3898 }
3899 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
3900         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3901         long ret_update = (long)update;
3902         js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
3903 }
3904 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
3905         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3906         uint32_tArray arg = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
3907         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_constr;
3908         arg_constr.datalen = *((uint32_t*)arg);
3909         if (arg_constr.datalen > 0)
3910                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
3911         else
3912                 arg_constr.data = NULL;
3913         uint32_t* arg_vals = (uint32_t*)(arg + 4);
3914         for (size_t l = 0; l < arg_constr.datalen; l++) {
3915                 uint32_t arr_conv_63 = arg_vals[l];
3916                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_conv_63) & ~1);
3917                 FREE((void*)arr_conv_63);
3918                 arg_constr.data[l] = arr_conv_63_conv;
3919         }
3920         return arg_constr;
3921 }
3922 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
3923         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3924         int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3925         memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
3926         uint32_tArray arg = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
3927         LDKCVec_NodeAnnouncementZ arg_constr;
3928         arg_constr.datalen = *((uint32_t*)arg);
3929         if (arg_constr.datalen > 0)
3930                 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
3931         else
3932                 arg_constr.data = NULL;
3933         uint32_t* arg_vals = (uint32_t*)(arg + 4);
3934         for (size_t s = 0; s < arg_constr.datalen; s++) {
3935                 uint32_t arr_conv_18 = arg_vals[s];
3936                 LDKNodeAnnouncement arr_conv_18_conv;
3937                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
3938                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
3939                 arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv);
3940                 arg_constr.data[s] = arr_conv_18_conv;
3941         }
3942         return arg_constr;
3943 }
3944 void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
3945         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3946         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3947         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3948         LDKInit init_var = *init;
3949         init_var = Init_clone(init);
3950         CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3951         CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3952         long init_ref = (long)init_var.inner;
3953         if (init_var.is_owned) {
3954                 init_ref |= 1;
3955         }
3956         js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
3957 }
3958 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
3959         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3960         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3961         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3962         LDKReplyChannelRange msg_var = msg;
3963         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3964         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3965         long msg_ref = (long)msg_var.inner;
3966         if (msg_var.is_owned) {
3967                 msg_ref |= 1;
3968         }
3969         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
3970         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
3971         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
3972         return ret_conv;
3973 }
3974 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
3975         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3976         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3977         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3978         LDKReplyShortChannelIdsEnd msg_var = msg;
3979         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3980         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3981         long msg_ref = (long)msg_var.inner;
3982         if (msg_var.is_owned) {
3983                 msg_ref |= 1;
3984         }
3985         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
3986         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
3987         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
3988         return ret_conv;
3989 }
3990 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
3991         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3992         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3993         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3994         LDKQueryChannelRange msg_var = msg;
3995         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3996         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3997         long msg_ref = (long)msg_var.inner;
3998         if (msg_var.is_owned) {
3999                 msg_ref |= 1;
4000         }
4001         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
4002         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
4003         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
4004         return ret_conv;
4005 }
4006 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
4007         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4008         int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4009         memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4010         LDKQueryShortChannelIds msg_var = msg;
4011         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4012         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4013         long msg_ref = (long)msg_var.inner;
4014         if (msg_var.is_owned) {
4015                 msg_ref |= 1;
4016         }
4017         LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
4018         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)ret) & ~1);
4019         ret_conv = CResult_NoneLightningErrorZ_clone((LDKCResult_NoneLightningErrorZ*)ret);
4020         return ret_conv;
4021 }
4022 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
4023         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4024         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4025         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
4026         return (void*) this_arg;
4027 }
4028 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
4029         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
4030         atomic_init(&calls->refcnt, 1);
4031         //TODO: Assign calls->o from o
4032
4033         LDKRoutingMessageHandler ret = {
4034                 .this_arg = (void*) calls,
4035                 .handle_node_announcement = handle_node_announcement_jcall,
4036                 .handle_channel_announcement = handle_channel_announcement_jcall,
4037                 .handle_channel_update = handle_channel_update_jcall,
4038                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
4039                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
4040                 .get_next_node_announcements = get_next_node_announcements_jcall,
4041                 .sync_routing_table = sync_routing_table_jcall,
4042                 .handle_reply_channel_range = handle_reply_channel_range_jcall,
4043                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
4044                 .handle_query_channel_range = handle_query_channel_range_jcall,
4045                 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
4046                 .free = LDKRoutingMessageHandler_JCalls_free,
4047                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
4048         };
4049         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
4050         return ret;
4051 }
4052 long  __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
4053         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
4054         *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
4055         return (long)res_ptr;
4056 }
4057 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
4058         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4059         LDKNodeAnnouncement msg_conv;
4060         msg_conv.inner = (void*)(msg & (~1));
4061         msg_conv.is_owned = false;
4062         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4063         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
4064         return (long)ret_conv;
4065 }
4066
4067 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
4068         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4069         LDKChannelAnnouncement msg_conv;
4070         msg_conv.inner = (void*)(msg & (~1));
4071         msg_conv.is_owned = false;
4072         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4073         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4074         return (long)ret_conv;
4075 }
4076
4077 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
4078         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4079         LDKChannelUpdate msg_conv;
4080         msg_conv.inner = (void*)(msg & (~1));
4081         msg_conv.is_owned = false;
4082         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4083         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
4084         return (long)ret_conv;
4085 }
4086
4087 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
4088         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4089         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
4090         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
4091 }
4092
4093 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
4094         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4095         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
4096         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4097         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4098         for (size_t l = 0; l < ret_var.datalen; l++) {
4099                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arr_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4100                 *arr_conv_63_ref = ret_var.data[l];
4101                 ret_arr_ptr[l] = (long)arr_conv_63_ref;
4102         }
4103         FREE(ret_var.data);
4104         return ret_arr;
4105 }
4106
4107 uint32_tArray  __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
4108         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4109         LDKPublicKey starting_point_ref;
4110         CHECK(*((uint32_t*)starting_point) == 33);
4111         memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
4112         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
4113         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4114         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4115         for (size_t s = 0; s < ret_var.datalen; s++) {
4116                 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
4117                 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4118                 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4119                 long arr_conv_18_ref = (long)arr_conv_18_var.inner;
4120                 if (arr_conv_18_var.is_owned) {
4121                         arr_conv_18_ref |= 1;
4122                 }
4123                 ret_arr_ptr[s] = arr_conv_18_ref;
4124         }
4125         FREE(ret_var.data);
4126         return ret_arr;
4127 }
4128
4129 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
4130         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4131         LDKPublicKey their_node_id_ref;
4132         CHECK(*((uint32_t*)their_node_id) == 33);
4133         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4134         LDKInit init_conv;
4135         init_conv.inner = (void*)(init & (~1));
4136         init_conv.is_owned = false;
4137         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
4138 }
4139
4140 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4141         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4142         LDKPublicKey their_node_id_ref;
4143         CHECK(*((uint32_t*)their_node_id) == 33);
4144         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4145         LDKReplyChannelRange msg_conv;
4146         msg_conv.inner = (void*)(msg & (~1));
4147         msg_conv.is_owned = (msg & 1) || (msg == 0);
4148         msg_conv = ReplyChannelRange_clone(&msg_conv);
4149         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4150         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4151         return (long)ret_conv;
4152 }
4153
4154 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) {
4155         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4156         LDKPublicKey their_node_id_ref;
4157         CHECK(*((uint32_t*)their_node_id) == 33);
4158         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4159         LDKReplyShortChannelIdsEnd msg_conv;
4160         msg_conv.inner = (void*)(msg & (~1));
4161         msg_conv.is_owned = (msg & 1) || (msg == 0);
4162         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
4163         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4164         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4165         return (long)ret_conv;
4166 }
4167
4168 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4169         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4170         LDKPublicKey their_node_id_ref;
4171         CHECK(*((uint32_t*)their_node_id) == 33);
4172         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4173         LDKQueryChannelRange msg_conv;
4174         msg_conv.inner = (void*)(msg & (~1));
4175         msg_conv.is_owned = (msg & 1) || (msg == 0);
4176         msg_conv = QueryChannelRange_clone(&msg_conv);
4177         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4178         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4179         return (long)ret_conv;
4180 }
4181
4182 uint32_t  __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4183         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4184         LDKPublicKey their_node_id_ref;
4185         CHECK(*((uint32_t*)their_node_id) == 33);
4186         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4187         LDKQueryShortChannelIds msg_conv;
4188         msg_conv.inner = (void*)(msg & (~1));
4189         msg_conv.is_owned = (msg & 1) || (msg == 0);
4190         msg_conv = QueryShortChannelIds_clone(&msg_conv);
4191         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4192         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4193         return (long)ret_conv;
4194 }
4195
4196 typedef struct LDKSocketDescriptor_JCalls {
4197         atomic_size_t refcnt;
4198         uint32_t send_data_meth;
4199         uint32_t disconnect_socket_meth;
4200         uint32_t eq_meth;
4201         uint32_t hash_meth;
4202 } LDKSocketDescriptor_JCalls;
4203 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
4204         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4205         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4206                 js_free(j_calls->send_data_meth);
4207                 js_free(j_calls->disconnect_socket_meth);
4208                 js_free(j_calls->eq_meth);
4209                 js_free(j_calls->hash_meth);
4210                 FREE(j_calls);
4211         }
4212 }
4213 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
4214         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4215         LDKu8slice data_var = data;
4216         int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4217         memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
4218         return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
4219 }
4220 void disconnect_socket_jcall(void* this_arg) {
4221         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4222         js_invoke_function_0(j_calls->disconnect_socket_meth);
4223 }
4224 bool eq_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
4225         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4226         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
4227         *other_arg_clone = SocketDescriptor_clone(other_arg);
4228         return js_invoke_function_1(j_calls->eq_meth, (long)other_arg_clone);
4229 }
4230 uint64_t hash_jcall(const void* this_arg) {
4231         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4232         return js_invoke_function_0(j_calls->hash_meth);
4233 }
4234 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
4235         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4236         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4237         return (void*) this_arg;
4238 }
4239 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
4240         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
4241         atomic_init(&calls->refcnt, 1);
4242         //TODO: Assign calls->o from o
4243
4244         LDKSocketDescriptor ret = {
4245                 .this_arg = (void*) calls,
4246                 .send_data = send_data_jcall,
4247                 .disconnect_socket = disconnect_socket_jcall,
4248                 .eq = eq_jcall,
4249                 .hash = hash_jcall,
4250                 .clone = LDKSocketDescriptor_JCalls_clone,
4251                 .free = LDKSocketDescriptor_JCalls_free,
4252         };
4253         return ret;
4254 }
4255 long  __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
4256         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
4257         *res_ptr = LDKSocketDescriptor_init(o);
4258         return (long)res_ptr;
4259 }
4260 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
4261         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4262         LDKu8slice data_ref;
4263         data_ref.datalen = *((uint32_t*)data);
4264         data_ref.data = (int8_t*)(data + 4);
4265         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
4266         return ret_val;
4267 }
4268
4269 void  __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
4270         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4271         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
4272 }
4273
4274 int64_t  __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
4275         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4276         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
4277         return ret_val;
4278 }
4279
4280 void  __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
4281         LDKTransaction _res_ref;
4282         _res_ref.datalen = *((uint32_t*)_res);
4283         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
4284         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
4285         _res_ref.data_is_owned = true;
4286         Transaction_free(_res_ref);
4287 }
4288
4289 void  __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
4290         if ((_res & 1) != 0) return;
4291         LDKTxOut _res_conv = *(LDKTxOut*)(((uint64_t)_res) & ~1);
4292         FREE((void*)_res);
4293         TxOut_free(_res_conv);
4294 }
4295
4296 uint32_t  __attribute__((visibility("default"))) TS_TxOut_clone(uint32_t orig) {
4297         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
4298         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
4299         *ret_ref = TxOut_clone(orig_conv);
4300         return (long)ret_ref;
4301 }
4302
4303 void  __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
4304         LDKCVec_SpendableOutputDescriptorZ _res_constr;
4305         _res_constr.datalen = *((uint32_t*)_res);
4306         if (_res_constr.datalen > 0)
4307                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
4308         else
4309                 _res_constr.data = NULL;
4310         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4311         for (size_t b = 0; b < _res_constr.datalen; b++) {
4312                 uint32_t arr_conv_27 = _res_vals[b];
4313                 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_conv_27) & ~1);
4314                 FREE((void*)arr_conv_27);
4315                 _res_constr.data[b] = arr_conv_27_conv;
4316         }
4317         CVec_SpendableOutputDescriptorZ_free(_res_constr);
4318 }
4319
4320 void  __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
4321         LDKCVec_MessageSendEventZ _res_constr;
4322         _res_constr.datalen = *((uint32_t*)_res);
4323         if (_res_constr.datalen > 0)
4324                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4325         else
4326                 _res_constr.data = NULL;
4327         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4328         for (size_t s = 0; s < _res_constr.datalen; s++) {
4329                 uint32_t arr_conv_18 = _res_vals[s];
4330                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_conv_18) & ~1);
4331                 FREE((void*)arr_conv_18);
4332                 _res_constr.data[s] = arr_conv_18_conv;
4333         }
4334         CVec_MessageSendEventZ_free(_res_constr);
4335 }
4336
4337 void  __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
4338         LDKCVec_EventZ _res_constr;
4339         _res_constr.datalen = *((uint32_t*)_res);
4340         if (_res_constr.datalen > 0)
4341                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4342         else
4343                 _res_constr.data = NULL;
4344         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4345         for (size_t h = 0; h < _res_constr.datalen; h++) {
4346                 uint32_t arr_conv_7 = _res_vals[h];
4347                 LDKEvent arr_conv_7_conv = *(LDKEvent*)(((uint64_t)arr_conv_7) & ~1);
4348                 FREE((void*)arr_conv_7);
4349                 _res_constr.data[h] = arr_conv_7_conv;
4350         }
4351         CVec_EventZ_free(_res_constr);
4352 }
4353
4354 void  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
4355         if ((_res & 1) != 0) return;
4356         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)_res) & ~1);
4357         FREE((void*)_res);
4358         C2Tuple_usizeTransactionZ_free(_res_conv);
4359 }
4360
4361 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
4362         LDKTransaction b_ref;
4363         b_ref.datalen = *((uint32_t*)b);
4364         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
4365         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
4366         b_ref.data_is_owned = true;
4367         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4368         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
4369         return (long)ret_ref;
4370 }
4371
4372 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
4373         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
4374         _res_constr.datalen = *((uint32_t*)_res);
4375         if (_res_constr.datalen > 0)
4376                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
4377         else
4378                 _res_constr.data = NULL;
4379         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4380         for (size_t e = 0; e < _res_constr.datalen; e++) {
4381                 uint32_t arr_conv_30 = _res_vals[e];
4382                 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_conv_30) & ~1);
4383                 FREE((void*)arr_conv_30);
4384                 _res_constr.data[e] = arr_conv_30_conv;
4385         }
4386         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
4387 }
4388
4389 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
4390         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4391         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
4392         return (long)ret_conv;
4393 }
4394
4395 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
4396         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
4397         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4398         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
4399         return (long)ret_conv;
4400 }
4401
4402 void  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
4403         if ((_res & 1) != 0) return;
4404         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)_res) & ~1);
4405         FREE((void*)_res);
4406         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
4407 }
4408
4409 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_clone(uint32_t orig) {
4410         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
4411         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4412         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
4413         return (long)ret_conv;
4414 }
4415
4416 void  __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
4417         LDKCVec_MonitorEventZ _res_constr;
4418         _res_constr.datalen = *((uint32_t*)_res);
4419         if (_res_constr.datalen > 0)
4420                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4421         else
4422                 _res_constr.data = NULL;
4423         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4424         for (size_t o = 0; o < _res_constr.datalen; o++) {
4425                 uint32_t arr_conv_14 = _res_vals[o];
4426                 LDKMonitorEvent arr_conv_14_conv;
4427                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
4428                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
4429                 _res_constr.data[o] = arr_conv_14_conv;
4430         }
4431         CVec_MonitorEventZ_free(_res_constr);
4432 }
4433
4434 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
4435         LDKChannelMonitorUpdate o_conv;
4436         o_conv.inner = (void*)(o & (~1));
4437         o_conv.is_owned = (o & 1) || (o == 0);
4438         o_conv = ChannelMonitorUpdate_clone(&o_conv);
4439         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
4440         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
4441         return (long)ret_conv;
4442 }
4443
4444 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
4445         LDKDecodeError e_conv;
4446         e_conv.inner = (void*)(e & (~1));
4447         e_conv.is_owned = (e & 1) || (e == 0);
4448         e_conv = DecodeError_clone(&e_conv);
4449         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
4450         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
4451         return (long)ret_conv;
4452 }
4453
4454 void  __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
4455         if ((_res & 1) != 0) return;
4456         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
4457         FREE((void*)_res);
4458         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
4459 }
4460
4461 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
4462         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4463         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
4464         return (long)ret_conv;
4465 }
4466
4467 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
4468         LDKMonitorUpdateError e_conv;
4469         e_conv.inner = (void*)(e & (~1));
4470         e_conv.is_owned = (e & 1) || (e == 0);
4471         e_conv = MonitorUpdateError_clone(&e_conv);
4472         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4473         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
4474         return (long)ret_conv;
4475 }
4476
4477 void  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
4478         if ((_res & 1) != 0) return;
4479         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(((uint64_t)_res) & ~1);
4480         FREE((void*)_res);
4481         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
4482 }
4483
4484 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_clone(uint32_t orig) {
4485         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
4486         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4487         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
4488         return (long)ret_conv;
4489 }
4490
4491 void  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
4492         if ((_res & 1) != 0) return;
4493         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(((uint64_t)_res) & ~1);
4494         FREE((void*)_res);
4495         C2Tuple_OutPointScriptZ_free(_res_conv);
4496 }
4497
4498 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
4499         LDKOutPoint a_conv;
4500         a_conv.inner = (void*)(a & (~1));
4501         a_conv.is_owned = (a & 1) || (a == 0);
4502         a_conv = OutPoint_clone(&a_conv);
4503         LDKCVec_u8Z b_ref;
4504         b_ref.datalen = *((uint32_t*)b);
4505         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4506         memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
4507         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4508         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
4509         return (long)ret_ref;
4510 }
4511
4512 void  __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
4513         LDKCVec_TransactionZ _res_constr;
4514         _res_constr.datalen = *((uint32_t*)_res);
4515         if (_res_constr.datalen > 0)
4516                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
4517         else
4518                 _res_constr.data = NULL;
4519         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
4520         for (size_t m = 0; m < _res_constr.datalen; m++) {
4521                 int8_tArray arr_conv_12 = _res_vals[m];
4522                 LDKTransaction arr_conv_12_ref;
4523                 arr_conv_12_ref.datalen = *((uint32_t*)arr_conv_12);
4524                 arr_conv_12_ref.data = MALLOC(arr_conv_12_ref.datalen, "LDKTransaction Bytes");
4525                 memcpy(arr_conv_12_ref.data, (uint8_t*)(arr_conv_12 + 4), arr_conv_12_ref.datalen);
4526                 arr_conv_12_ref.data_is_owned = true;
4527                 _res_constr.data[m] = arr_conv_12_ref;
4528         }
4529         CVec_TransactionZ_free(_res_constr);
4530 }
4531
4532 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_clone(uint32_t orig) {
4533         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
4534         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4535         *ret_ref = C2Tuple_u32TxOutZ_clone(orig_conv);
4536         return (long)ret_ref;
4537 }
4538
4539 void  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
4540         if ((_res & 1) != 0) return;
4541         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)_res) & ~1);
4542         FREE((void*)_res);
4543         C2Tuple_u32TxOutZ_free(_res_conv);
4544 }
4545
4546 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
4547         LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
4548         FREE((void*)b);
4549         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4550         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
4551         return (long)ret_ref;
4552 }
4553
4554 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
4555         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
4556         _res_constr.datalen = *((uint32_t*)_res);
4557         if (_res_constr.datalen > 0)
4558                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4559         else
4560                 _res_constr.data = NULL;
4561         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4562         for (size_t z = 0; z < _res_constr.datalen; z++) {
4563                 uint32_t arr_conv_25 = _res_vals[z];
4564                 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_conv_25) & ~1);
4565                 FREE((void*)arr_conv_25);
4566                 _res_constr.data[z] = arr_conv_25_conv;
4567         }
4568         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
4569 }
4570
4571 void  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
4572         if ((_res & 1) != 0) return;
4573         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)_res) & ~1);
4574         FREE((void*)_res);
4575         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
4576 }
4577
4578 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
4579         LDKThirtyTwoBytes a_ref;
4580         CHECK(*((uint32_t*)a) == 32);
4581         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
4582         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4583         b_constr.datalen = *((uint32_t*)b);
4584         if (b_constr.datalen > 0)
4585                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4586         else
4587                 b_constr.data = NULL;
4588         uint32_t* b_vals = (uint32_t*)(b + 4);
4589         for (size_t z = 0; z < b_constr.datalen; z++) {
4590                 uint32_t arr_conv_25 = b_vals[z];
4591                 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_conv_25) & ~1);
4592                 FREE((void*)arr_conv_25);
4593                 b_constr.data[z] = arr_conv_25_conv;
4594         }
4595         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4596         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
4597         return (long)ret_ref;
4598 }
4599
4600 void  __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
4601         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
4602         _res_constr.datalen = *((uint32_t*)_res);
4603         if (_res_constr.datalen > 0)
4604                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
4605         else
4606                 _res_constr.data = NULL;
4607         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4608         for (size_t x = 0; x < _res_constr.datalen; x++) {
4609                 uint32_t arr_conv_49 = _res_vals[x];
4610                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_conv_49) & ~1);
4611                 FREE((void*)arr_conv_49);
4612                 _res_constr.data[x] = arr_conv_49_conv;
4613         }
4614         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
4615 }
4616
4617 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
4618         if ((_res & 1) != 0) return;
4619         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)_res) & ~1);
4620         FREE((void*)_res);
4621         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
4622 }
4623
4624 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
4625         LDKThirtyTwoBytes a_ref;
4626         CHECK(*((uint32_t*)a) == 32);
4627         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
4628         LDKChannelMonitor b_conv;
4629         b_conv.inner = (void*)(b & (~1));
4630         b_conv.is_owned = (b & 1) || (b == 0);
4631         b_conv = ChannelMonitor_clone(&b_conv);
4632         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4633         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
4634         return (long)ret_ref;
4635 }
4636
4637 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
4638         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1);
4639         FREE((void*)o);
4640         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
4641         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
4642         return (long)ret_conv;
4643 }
4644
4645 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
4646         LDKDecodeError e_conv;
4647         e_conv.inner = (void*)(e & (~1));
4648         e_conv.is_owned = (e & 1) || (e == 0);
4649         e_conv = DecodeError_clone(&e_conv);
4650         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
4651         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
4652         return (long)ret_conv;
4653 }
4654
4655 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
4656         if ((_res & 1) != 0) return;
4657         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(((uint64_t)_res) & ~1);
4658         FREE((void*)_res);
4659         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
4660 }
4661
4662 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u64u64Z_clone(uint32_t orig) {
4663         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)(orig & ~1);
4664         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4665         *ret_ref = C2Tuple_u64u64Z_clone(orig_conv);
4666         return (long)ret_ref;
4667 }
4668
4669 void  __attribute__((visibility("default"))) TS_C2Tuple_u64u64Z_free(uint32_t _res) {
4670         if ((_res & 1) != 0) return;
4671         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(((uint64_t)_res) & ~1);
4672         FREE((void*)_res);
4673         C2Tuple_u64u64Z_free(_res_conv);
4674 }
4675
4676 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
4677         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4678         *ret_ref = C2Tuple_u64u64Z_new(a, b);
4679         return (long)ret_ref;
4680 }
4681
4682 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
4683         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1);
4684         FREE((void*)o);
4685         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
4686         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
4687         return (long)ret_conv;
4688 }
4689
4690 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
4691         LDKDecodeError e_conv;
4692         e_conv.inner = (void*)(e & (~1));
4693         e_conv.is_owned = (e & 1) || (e == 0);
4694         e_conv = DecodeError_clone(&e_conv);
4695         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
4696         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
4697         return (long)ret_conv;
4698 }
4699
4700 void  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
4701         if ((_res & 1) != 0) return;
4702         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(((uint64_t)_res) & ~1);
4703         FREE((void*)_res);
4704         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
4705 }
4706
4707 uint32_t  __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_clone(uint32_t orig) {
4708         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
4709         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
4710         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
4711         return (long)ret_conv;
4712 }
4713
4714 void  __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
4715         LDKCVec_SignatureZ _res_constr;
4716         _res_constr.datalen = *((uint32_t*)_res);
4717         if (_res_constr.datalen > 0)
4718                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4719         else
4720                 _res_constr.data = NULL;
4721         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
4722         for (size_t m = 0; m < _res_constr.datalen; m++) {
4723                 int8_tArray arr_conv_12 = _res_vals[m];
4724                 LDKSignature arr_conv_12_ref;
4725                 CHECK(*((uint32_t*)arr_conv_12) == 64);
4726                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
4727                 _res_constr.data[m] = arr_conv_12_ref;
4728         }
4729         CVec_SignatureZ_free(_res_constr);
4730 }
4731
4732 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_clone(uint32_t orig) {
4733         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
4734         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4735         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
4736         return (long)ret_ref;
4737 }
4738
4739 void  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
4740         if ((_res & 1) != 0) return;
4741         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)_res) & ~1);
4742         FREE((void*)_res);
4743         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
4744 }
4745
4746 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
4747         LDKSignature a_ref;
4748         CHECK(*((uint32_t*)a) == 64);
4749         memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
4750         LDKCVec_SignatureZ b_constr;
4751         b_constr.datalen = *((uint32_t*)b);
4752         if (b_constr.datalen > 0)
4753                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4754         else
4755                 b_constr.data = NULL;
4756         int8_tArray* b_vals = (int8_tArray*)(b + 4);
4757         for (size_t m = 0; m < b_constr.datalen; m++) {
4758                 int8_tArray arr_conv_12 = b_vals[m];
4759                 LDKSignature arr_conv_12_ref;
4760                 CHECK(*((uint32_t*)arr_conv_12) == 64);
4761                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
4762                 b_constr.data[m] = arr_conv_12_ref;
4763         }
4764         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4765         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
4766         return (long)ret_ref;
4767 }
4768
4769 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
4770         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1);
4771         FREE((void*)o);
4772         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4773         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
4774         return (long)ret_conv;
4775 }
4776
4777 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
4778         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4779         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
4780         return (long)ret_conv;
4781 }
4782
4783 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
4784         if ((_res & 1) != 0) return;
4785         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)_res) & ~1);
4786         FREE((void*)_res);
4787         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
4788 }
4789
4790 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(uint32_t orig) {
4791         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
4792         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4793         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
4794         return (long)ret_conv;
4795 }
4796
4797 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
4798         LDKSignature o_ref;
4799         CHECK(*((uint32_t*)o) == 64);
4800         memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
4801         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4802         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
4803         return (long)ret_conv;
4804 }
4805
4806 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
4807         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4808         *ret_conv = CResult_SignatureNoneZ_err();
4809         return (long)ret_conv;
4810 }
4811
4812 void  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
4813         if ((_res & 1) != 0) return;
4814         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)_res) & ~1);
4815         FREE((void*)_res);
4816         CResult_SignatureNoneZ_free(_res_conv);
4817 }
4818
4819 uint32_t  __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_clone(uint32_t orig) {
4820         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
4821         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4822         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
4823         return (long)ret_conv;
4824 }
4825
4826 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_ok(uint32_t o) {
4827         LDKChannelKeys o_conv = *(LDKChannelKeys*)(((uint64_t)o) & ~1);
4828         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
4829         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_ok(o_conv);
4830         return (long)ret_conv;
4831 }
4832
4833 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_err(uint32_t e) {
4834         LDKDecodeError e_conv;
4835         e_conv.inner = (void*)(e & (~1));
4836         e_conv.is_owned = (e & 1) || (e == 0);
4837         e_conv = DecodeError_clone(&e_conv);
4838         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
4839         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_err(e_conv);
4840         return (long)ret_conv;
4841 }
4842
4843 void  __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_free(uint32_t _res) {
4844         if ((_res & 1) != 0) return;
4845         LDKCResult_ChanKeySignerDecodeErrorZ _res_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)(((uint64_t)_res) & ~1);
4846         FREE((void*)_res);
4847         CResult_ChanKeySignerDecodeErrorZ_free(_res_conv);
4848 }
4849
4850 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_clone(uint32_t orig) {
4851         LDKCResult_ChanKeySignerDecodeErrorZ* orig_conv = (LDKCResult_ChanKeySignerDecodeErrorZ*)(orig & ~1);
4852         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
4853         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_clone(orig_conv);
4854         return (long)ret_conv;
4855 }
4856
4857 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_ok(uint32_t o) {
4858         LDKInMemoryChannelKeys o_conv;
4859         o_conv.inner = (void*)(o & (~1));
4860         o_conv.is_owned = (o & 1) || (o == 0);
4861         o_conv = InMemoryChannelKeys_clone(&o_conv);
4862         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
4863         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_ok(o_conv);
4864         return (long)ret_conv;
4865 }
4866
4867 uint32_t  __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_err(uint32_t e) {
4868         LDKDecodeError e_conv;
4869         e_conv.inner = (void*)(e & (~1));
4870         e_conv.is_owned = (e & 1) || (e == 0);
4871         e_conv = DecodeError_clone(&e_conv);
4872         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
4873         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_err(e_conv);
4874         return (long)ret_conv;
4875 }
4876
4877 void  __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_free(uint32_t _res) {
4878         if ((_res & 1) != 0) return;
4879         LDKCResult_InMemoryChannelKeysDecodeErrorZ _res_conv = *(LDKCResult_InMemoryChannelKeysDecodeErrorZ*)(((uint64_t)_res) & ~1);
4880         FREE((void*)_res);
4881         CResult_InMemoryChannelKeysDecodeErrorZ_free(_res_conv);
4882 }
4883
4884 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
4885         LDKTxOut o_conv = *(LDKTxOut*)(((uint64_t)o) & ~1);
4886         FREE((void*)o);
4887         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4888         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
4889         return (long)ret_conv;
4890 }
4891
4892 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
4893         LDKAccessError e_conv = LDKAccessError_from_js(e);
4894         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4895         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
4896         return (long)ret_conv;
4897 }
4898
4899 void  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
4900         if ((_res & 1) != 0) return;
4901         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(((uint64_t)_res) & ~1);
4902         FREE((void*)_res);
4903         CResult_TxOutAccessErrorZ_free(_res_conv);
4904 }
4905
4906 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_clone(uint32_t orig) {
4907         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
4908         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4909         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
4910         return (long)ret_conv;
4911 }
4912
4913 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
4914         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4915         *ret_conv = CResult_NoneAPIErrorZ_ok();
4916         return (long)ret_conv;
4917 }
4918
4919 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
4920         LDKAPIError e_conv = *(LDKAPIError*)(((uint64_t)e) & ~1);
4921         FREE((void*)e);
4922         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4923         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
4924         return (long)ret_conv;
4925 }
4926
4927 void  __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
4928         if ((_res & 1) != 0) return;
4929         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(((uint64_t)_res) & ~1);
4930         FREE((void*)_res);
4931         CResult_NoneAPIErrorZ_free(_res_conv);
4932 }
4933
4934 void  __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
4935         LDKCVec_ChannelDetailsZ _res_constr;
4936         _res_constr.datalen = *((uint32_t*)_res);
4937         if (_res_constr.datalen > 0)
4938                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
4939         else
4940                 _res_constr.data = NULL;
4941         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4942         for (size_t q = 0; q < _res_constr.datalen; q++) {
4943                 uint32_t arr_conv_16 = _res_vals[q];
4944                 LDKChannelDetails arr_conv_16_conv;
4945                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4946                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4947                 _res_constr.data[q] = arr_conv_16_conv;
4948         }
4949         CVec_ChannelDetailsZ_free(_res_constr);
4950 }
4951
4952 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
4953         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4954         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
4955         return (long)ret_conv;
4956 }
4957
4958 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
4959         LDKPaymentSendFailure e_conv;
4960         e_conv.inner = (void*)(e & (~1));
4961         e_conv.is_owned = (e & 1) || (e == 0);
4962         e_conv = PaymentSendFailure_clone(&e_conv);
4963         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4964         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
4965         return (long)ret_conv;
4966 }
4967
4968 void  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
4969         if ((_res & 1) != 0) return;
4970         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(((uint64_t)_res) & ~1);
4971         FREE((void*)_res);
4972         CResult_NonePaymentSendFailureZ_free(_res_conv);
4973 }
4974
4975 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_clone(uint32_t orig) {
4976         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
4977         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4978         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
4979         return (long)ret_conv;
4980 }
4981
4982 void  __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
4983         LDKCVec_NetAddressZ _res_constr;
4984         _res_constr.datalen = *((uint32_t*)_res);
4985         if (_res_constr.datalen > 0)
4986                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
4987         else
4988                 _res_constr.data = NULL;
4989         uint32_t* _res_vals = (uint32_t*)(_res + 4);
4990         for (size_t m = 0; m < _res_constr.datalen; m++) {
4991                 uint32_t arr_conv_12 = _res_vals[m];
4992                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
4993                 FREE((void*)arr_conv_12);
4994                 _res_constr.data[m] = arr_conv_12_conv;
4995         }
4996         CVec_NetAddressZ_free(_res_constr);
4997 }
4998
4999 void  __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
5000         LDKCVec_ChannelMonitorZ _res_constr;
5001         _res_constr.datalen = *((uint32_t*)_res);
5002         if (_res_constr.datalen > 0)
5003                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
5004         else
5005                 _res_constr.data = NULL;
5006         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5007         for (size_t q = 0; q < _res_constr.datalen; q++) {
5008                 uint32_t arr_conv_16 = _res_vals[q];
5009                 LDKChannelMonitor arr_conv_16_conv;
5010                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5011                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5012                 _res_constr.data[q] = arr_conv_16_conv;
5013         }
5014         CVec_ChannelMonitorZ_free(_res_constr);
5015 }
5016
5017 void  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
5018         if ((_res & 1) != 0) return;
5019         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)_res) & ~1);
5020         FREE((void*)_res);
5021         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
5022 }
5023
5024 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
5025         LDKThirtyTwoBytes a_ref;
5026         CHECK(*((uint32_t*)a) == 32);
5027         memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
5028         LDKChannelManager b_conv;
5029         b_conv.inner = (void*)(b & (~1));
5030         b_conv.is_owned = (b & 1) || (b == 0);
5031         // Warning: we need a move here but no clone is available for LDKChannelManager
5032         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
5033         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
5034         return (long)ret_ref;
5035 }
5036
5037 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
5038         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(((uint64_t)o) & ~1);
5039         FREE((void*)o);
5040         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
5041         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
5042         return (long)ret_conv;
5043 }
5044
5045 uint32_t  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
5046         LDKDecodeError e_conv;
5047         e_conv.inner = (void*)(e & (~1));
5048         e_conv.is_owned = (e & 1) || (e == 0);
5049         e_conv = DecodeError_clone(&e_conv);
5050         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
5051         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
5052         return (long)ret_conv;
5053 }
5054
5055 void  __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
5056         if ((_res & 1) != 0) return;
5057         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(((uint64_t)_res) & ~1);
5058         FREE((void*)_res);
5059         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
5060 }
5061
5062 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
5063         LDKNetAddress o_conv = *(LDKNetAddress*)(((uint64_t)o) & ~1);
5064         FREE((void*)o);
5065         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5066         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
5067         return (long)ret_conv;
5068 }
5069
5070 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
5071         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5072         *ret_conv = CResult_NetAddressu8Z_err(e);
5073         return (long)ret_conv;
5074 }
5075
5076 void  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
5077         if ((_res & 1) != 0) return;
5078         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)_res) & ~1);
5079         FREE((void*)_res);
5080         CResult_NetAddressu8Z_free(_res_conv);
5081 }
5082
5083 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_clone(uint32_t orig) {
5084         LDKCResult_NetAddressu8Z* orig_conv = (LDKCResult_NetAddressu8Z*)(orig & ~1);
5085         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5086         *ret_conv = CResult_NetAddressu8Z_clone(orig_conv);
5087         return (long)ret_conv;
5088 }
5089
5090 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
5091         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)(((uint64_t)o) & ~1);
5092         FREE((void*)o);
5093         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
5094         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
5095         return (long)ret_conv;
5096 }
5097
5098 uint32_t  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
5099         LDKDecodeError e_conv;
5100         e_conv.inner = (void*)(e & (~1));
5101         e_conv.is_owned = (e & 1) || (e == 0);
5102         e_conv = DecodeError_clone(&e_conv);
5103         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
5104         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
5105         return (long)ret_conv;
5106 }
5107
5108 void  __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
5109         if ((_res & 1) != 0) return;
5110         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)(((uint64_t)_res) & ~1);
5111         FREE((void*)_res);
5112         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
5113 }
5114
5115 void  __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
5116         LDKCVec_u64Z _res_constr;
5117         _res_constr.datalen = *((uint32_t*)_res);
5118         if (_res_constr.datalen > 0)
5119                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
5120         else
5121                 _res_constr.data = NULL;
5122         int64_t* _res_vals = (int64_t*)(_res + 4);
5123         for (size_t i = 0; i < _res_constr.datalen; i++) {
5124                 int64_t arr_conv_8 = _res_vals[i];
5125                 _res_constr.data[i] = arr_conv_8;
5126         }
5127         CVec_u64Z_free(_res_constr);
5128 }
5129
5130 void  __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
5131         LDKCVec_UpdateAddHTLCZ _res_constr;
5132         _res_constr.datalen = *((uint32_t*)_res);
5133         if (_res_constr.datalen > 0)
5134                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
5135         else
5136                 _res_constr.data = NULL;
5137         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5138         for (size_t p = 0; p < _res_constr.datalen; p++) {
5139                 uint32_t arr_conv_15 = _res_vals[p];
5140                 LDKUpdateAddHTLC arr_conv_15_conv;
5141                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
5142                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
5143                 _res_constr.data[p] = arr_conv_15_conv;
5144         }
5145         CVec_UpdateAddHTLCZ_free(_res_constr);
5146 }
5147
5148 void  __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
5149         LDKCVec_UpdateFulfillHTLCZ _res_constr;
5150         _res_constr.datalen = *((uint32_t*)_res);
5151         if (_res_constr.datalen > 0)
5152                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
5153         else
5154                 _res_constr.data = NULL;
5155         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5156         for (size_t t = 0; t < _res_constr.datalen; t++) {
5157                 uint32_t arr_conv_19 = _res_vals[t];
5158                 LDKUpdateFulfillHTLC arr_conv_19_conv;
5159                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
5160                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
5161                 _res_constr.data[t] = arr_conv_19_conv;
5162         }
5163         CVec_UpdateFulfillHTLCZ_free(_res_constr);
5164 }
5165
5166 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
5167         LDKCVec_UpdateFailHTLCZ _res_constr;
5168         _res_constr.datalen = *((uint32_t*)_res);
5169         if (_res_constr.datalen > 0)
5170                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
5171         else
5172                 _res_constr.data = NULL;
5173         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5174         for (size_t q = 0; q < _res_constr.datalen; q++) {
5175                 uint32_t arr_conv_16 = _res_vals[q];
5176                 LDKUpdateFailHTLC arr_conv_16_conv;
5177                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5178                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5179                 _res_constr.data[q] = arr_conv_16_conv;
5180         }
5181         CVec_UpdateFailHTLCZ_free(_res_constr);
5182 }
5183
5184 void  __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
5185         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
5186         _res_constr.datalen = *((uint32_t*)_res);
5187         if (_res_constr.datalen > 0)
5188                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
5189         else
5190                 _res_constr.data = NULL;
5191         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5192         for (size_t z = 0; z < _res_constr.datalen; z++) {
5193                 uint32_t arr_conv_25 = _res_vals[z];
5194                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
5195                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
5196                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
5197                 _res_constr.data[z] = arr_conv_25_conv;
5198         }
5199         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
5200 }
5201
5202 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
5203         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5204         *ret_conv = CResult_boolLightningErrorZ_ok(o);
5205         return (long)ret_conv;
5206 }
5207
5208 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
5209         LDKLightningError e_conv;
5210         e_conv.inner = (void*)(e & (~1));
5211         e_conv.is_owned = (e & 1) || (e == 0);
5212         e_conv = LightningError_clone(&e_conv);
5213         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5214         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
5215         return (long)ret_conv;
5216 }
5217
5218 void  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
5219         if ((_res & 1) != 0) return;
5220         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(((uint64_t)_res) & ~1);
5221         FREE((void*)_res);
5222         CResult_boolLightningErrorZ_free(_res_conv);
5223 }
5224
5225 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_clone(uint32_t orig) {
5226         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
5227         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5228         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
5229         return (long)ret_conv;
5230 }
5231
5232 void  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
5233         if ((_res & 1) != 0) return;
5234         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)_res) & ~1);
5235         FREE((void*)_res);
5236         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
5237 }
5238
5239 uint32_t  __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
5240         LDKChannelAnnouncement a_conv;
5241         a_conv.inner = (void*)(a & (~1));
5242         a_conv.is_owned = (a & 1) || (a == 0);
5243         a_conv = ChannelAnnouncement_clone(&a_conv);
5244         LDKChannelUpdate b_conv;
5245         b_conv.inner = (void*)(b & (~1));
5246         b_conv.is_owned = (b & 1) || (b == 0);
5247         b_conv = ChannelUpdate_clone(&b_conv);
5248         LDKChannelUpdate c_conv;
5249         c_conv.inner = (void*)(c & (~1));
5250         c_conv.is_owned = (c & 1) || (c == 0);
5251         c_conv = ChannelUpdate_clone(&c_conv);
5252         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5253         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5254         return (long)ret_ref;
5255 }
5256
5257 void  __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
5258         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
5259         _res_constr.datalen = *((uint32_t*)_res);
5260         if (_res_constr.datalen > 0)
5261                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5262         else
5263                 _res_constr.data = NULL;
5264         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5265         for (size_t l = 0; l < _res_constr.datalen; l++) {
5266                 uint32_t arr_conv_63 = _res_vals[l];
5267                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_conv_63) & ~1);
5268                 FREE((void*)arr_conv_63);
5269                 _res_constr.data[l] = arr_conv_63_conv;
5270         }
5271         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
5272 }
5273
5274 void  __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
5275         LDKCVec_NodeAnnouncementZ _res_constr;
5276         _res_constr.datalen = *((uint32_t*)_res);
5277         if (_res_constr.datalen > 0)
5278                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5279         else
5280                 _res_constr.data = NULL;
5281         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5282         for (size_t s = 0; s < _res_constr.datalen; s++) {
5283                 uint32_t arr_conv_18 = _res_vals[s];
5284                 LDKNodeAnnouncement arr_conv_18_conv;
5285                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
5286                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
5287                 _res_constr.data[s] = arr_conv_18_conv;
5288         }
5289         CVec_NodeAnnouncementZ_free(_res_constr);
5290 }
5291
5292 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
5293         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5294         *ret_conv = CResult_NoneLightningErrorZ_ok();
5295         return (long)ret_conv;
5296 }
5297
5298 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
5299         LDKLightningError e_conv;
5300         e_conv.inner = (void*)(e & (~1));
5301         e_conv.is_owned = (e & 1) || (e == 0);
5302         e_conv = LightningError_clone(&e_conv);
5303         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5304         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
5305         return (long)ret_conv;
5306 }
5307
5308 void  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
5309         if ((_res & 1) != 0) return;
5310         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(((uint64_t)_res) & ~1);
5311         FREE((void*)_res);
5312         CResult_NoneLightningErrorZ_free(_res_conv);
5313 }
5314
5315 uint32_t  __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_clone(uint32_t orig) {
5316         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
5317         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5318         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
5319         return (long)ret_conv;
5320 }
5321
5322 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
5323         LDKChannelReestablish o_conv;
5324         o_conv.inner = (void*)(o & (~1));
5325         o_conv.is_owned = (o & 1) || (o == 0);
5326         o_conv = ChannelReestablish_clone(&o_conv);
5327         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
5328         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
5329         return (long)ret_conv;
5330 }
5331
5332 uint32_t  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
5333         LDKDecodeError e_conv;
5334         e_conv.inner = (void*)(e & (~1));
5335         e_conv.is_owned = (e & 1) || (e == 0);
5336         e_conv = DecodeError_clone(&e_conv);
5337         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
5338         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
5339         return (long)ret_conv;
5340 }
5341
5342 void  __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
5343         if ((_res & 1) != 0) return;
5344         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(((uint64_t)_res) & ~1);
5345         FREE((void*)_res);
5346         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
5347 }
5348
5349 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
5350         LDKInit o_conv;
5351         o_conv.inner = (void*)(o & (~1));
5352         o_conv.is_owned = (o & 1) || (o == 0);
5353         o_conv = Init_clone(&o_conv);
5354         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
5355         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
5356         return (long)ret_conv;
5357 }
5358
5359 uint32_t  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
5360         LDKDecodeError e_conv;
5361         e_conv.inner = (void*)(e & (~1));
5362         e_conv.is_owned = (e & 1) || (e == 0);
5363         e_conv = DecodeError_clone(&e_conv);
5364         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
5365         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
5366         return (long)ret_conv;
5367 }
5368
5369 void  __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
5370         if ((_res & 1) != 0) return;
5371         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(((uint64_t)_res) & ~1);
5372         FREE((void*)_res);
5373         CResult_InitDecodeErrorZ_free(_res_conv);
5374 }
5375
5376 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
5377         LDKPing o_conv;
5378         o_conv.inner = (void*)(o & (~1));
5379         o_conv.is_owned = (o & 1) || (o == 0);
5380         o_conv = Ping_clone(&o_conv);
5381         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
5382         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
5383         return (long)ret_conv;
5384 }
5385
5386 uint32_t  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
5387         LDKDecodeError e_conv;
5388         e_conv.inner = (void*)(e & (~1));
5389         e_conv.is_owned = (e & 1) || (e == 0);
5390         e_conv = DecodeError_clone(&e_conv);
5391         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
5392         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
5393         return (long)ret_conv;
5394 }
5395
5396 void  __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
5397         if ((_res & 1) != 0) return;
5398         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(((uint64_t)_res) & ~1);
5399         FREE((void*)_res);
5400         CResult_PingDecodeErrorZ_free(_res_conv);
5401 }
5402
5403 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
5404         LDKPong o_conv;
5405         o_conv.inner = (void*)(o & (~1));
5406         o_conv.is_owned = (o & 1) || (o == 0);
5407         o_conv = Pong_clone(&o_conv);
5408         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
5409         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
5410         return (long)ret_conv;
5411 }
5412
5413 uint32_t  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
5414         LDKDecodeError e_conv;
5415         e_conv.inner = (void*)(e & (~1));
5416         e_conv.is_owned = (e & 1) || (e == 0);
5417         e_conv = DecodeError_clone(&e_conv);
5418         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
5419         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
5420         return (long)ret_conv;
5421 }
5422
5423 void  __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
5424         if ((_res & 1) != 0) return;
5425         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(((uint64_t)_res) & ~1);
5426         FREE((void*)_res);
5427         CResult_PongDecodeErrorZ_free(_res_conv);
5428 }
5429
5430 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
5431         LDKUnsignedChannelAnnouncement o_conv;
5432         o_conv.inner = (void*)(o & (~1));
5433         o_conv.is_owned = (o & 1) || (o == 0);
5434         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
5435         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
5436         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
5437         return (long)ret_conv;
5438 }
5439
5440 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
5441         LDKDecodeError e_conv;
5442         e_conv.inner = (void*)(e & (~1));
5443         e_conv.is_owned = (e & 1) || (e == 0);
5444         e_conv = DecodeError_clone(&e_conv);
5445         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
5446         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
5447         return (long)ret_conv;
5448 }
5449
5450 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
5451         if ((_res & 1) != 0) return;
5452         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
5453         FREE((void*)_res);
5454         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
5455 }
5456
5457 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
5458         LDKUnsignedChannelUpdate o_conv;
5459         o_conv.inner = (void*)(o & (~1));
5460         o_conv.is_owned = (o & 1) || (o == 0);
5461         o_conv = UnsignedChannelUpdate_clone(&o_conv);
5462         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
5463         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
5464         return (long)ret_conv;
5465 }
5466
5467 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
5468         LDKDecodeError e_conv;
5469         e_conv.inner = (void*)(e & (~1));
5470         e_conv.is_owned = (e & 1) || (e == 0);
5471         e_conv = DecodeError_clone(&e_conv);
5472         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
5473         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
5474         return (long)ret_conv;
5475 }
5476
5477 void  __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
5478         if ((_res & 1) != 0) return;
5479         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(((uint64_t)_res) & ~1);
5480         FREE((void*)_res);
5481         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
5482 }
5483
5484 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
5485         LDKErrorMessage o_conv;
5486         o_conv.inner = (void*)(o & (~1));
5487         o_conv.is_owned = (o & 1) || (o == 0);
5488         o_conv = ErrorMessage_clone(&o_conv);
5489         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
5490         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
5491         return (long)ret_conv;
5492 }
5493
5494 uint32_t  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
5495         LDKDecodeError e_conv;
5496         e_conv.inner = (void*)(e & (~1));
5497         e_conv.is_owned = (e & 1) || (e == 0);
5498         e_conv = DecodeError_clone(&e_conv);
5499         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
5500         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
5501         return (long)ret_conv;
5502 }
5503
5504 void  __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
5505         if ((_res & 1) != 0) return;
5506         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(((uint64_t)_res) & ~1);
5507         FREE((void*)_res);
5508         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
5509 }
5510
5511 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
5512         LDKUnsignedNodeAnnouncement o_conv;
5513         o_conv.inner = (void*)(o & (~1));
5514         o_conv.is_owned = (o & 1) || (o == 0);
5515         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
5516         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
5517         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
5518         return (long)ret_conv;
5519 }
5520
5521 uint32_t  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
5522         LDKDecodeError e_conv;
5523         e_conv.inner = (void*)(e & (~1));
5524         e_conv.is_owned = (e & 1) || (e == 0);
5525         e_conv = DecodeError_clone(&e_conv);
5526         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
5527         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
5528         return (long)ret_conv;
5529 }
5530
5531 void  __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
5532         if ((_res & 1) != 0) return;
5533         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(((uint64_t)_res) & ~1);
5534         FREE((void*)_res);
5535         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
5536 }
5537
5538 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
5539         LDKQueryShortChannelIds o_conv;
5540         o_conv.inner = (void*)(o & (~1));
5541         o_conv.is_owned = (o & 1) || (o == 0);
5542         o_conv = QueryShortChannelIds_clone(&o_conv);
5543         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
5544         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
5545         return (long)ret_conv;
5546 }
5547
5548 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
5549         LDKDecodeError e_conv;
5550         e_conv.inner = (void*)(e & (~1));
5551         e_conv.is_owned = (e & 1) || (e == 0);
5552         e_conv = DecodeError_clone(&e_conv);
5553         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
5554         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
5555         return (long)ret_conv;
5556 }
5557
5558 void  __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
5559         if ((_res & 1) != 0) return;
5560         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(((uint64_t)_res) & ~1);
5561         FREE((void*)_res);
5562         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
5563 }
5564
5565 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
5566         LDKReplyShortChannelIdsEnd o_conv;
5567         o_conv.inner = (void*)(o & (~1));
5568         o_conv.is_owned = (o & 1) || (o == 0);
5569         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
5570         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
5571         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
5572         return (long)ret_conv;
5573 }
5574
5575 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
5576         LDKDecodeError e_conv;
5577         e_conv.inner = (void*)(e & (~1));
5578         e_conv.is_owned = (e & 1) || (e == 0);
5579         e_conv = DecodeError_clone(&e_conv);
5580         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
5581         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
5582         return (long)ret_conv;
5583 }
5584
5585 void  __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
5586         if ((_res & 1) != 0) return;
5587         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(((uint64_t)_res) & ~1);
5588         FREE((void*)_res);
5589         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
5590 }
5591
5592 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
5593         LDKQueryChannelRange o_conv;
5594         o_conv.inner = (void*)(o & (~1));
5595         o_conv.is_owned = (o & 1) || (o == 0);
5596         o_conv = QueryChannelRange_clone(&o_conv);
5597         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
5598         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
5599         return (long)ret_conv;
5600 }
5601
5602 uint32_t  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
5603         LDKDecodeError e_conv;
5604         e_conv.inner = (void*)(e & (~1));
5605         e_conv.is_owned = (e & 1) || (e == 0);
5606         e_conv = DecodeError_clone(&e_conv);
5607         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
5608         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
5609         return (long)ret_conv;
5610 }
5611
5612 void  __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
5613         if ((_res & 1) != 0) return;
5614         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
5615         FREE((void*)_res);
5616         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
5617 }
5618
5619 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
5620         LDKReplyChannelRange o_conv;
5621         o_conv.inner = (void*)(o & (~1));
5622         o_conv.is_owned = (o & 1) || (o == 0);
5623         o_conv = ReplyChannelRange_clone(&o_conv);
5624         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
5625         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
5626         return (long)ret_conv;
5627 }
5628
5629 uint32_t  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
5630         LDKDecodeError e_conv;
5631         e_conv.inner = (void*)(e & (~1));
5632         e_conv.is_owned = (e & 1) || (e == 0);
5633         e_conv = DecodeError_clone(&e_conv);
5634         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
5635         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
5636         return (long)ret_conv;
5637 }
5638
5639 void  __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
5640         if ((_res & 1) != 0) return;
5641         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(((uint64_t)_res) & ~1);
5642         FREE((void*)_res);
5643         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
5644 }
5645
5646 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
5647         LDKGossipTimestampFilter o_conv;
5648         o_conv.inner = (void*)(o & (~1));
5649         o_conv.is_owned = (o & 1) || (o == 0);
5650         o_conv = GossipTimestampFilter_clone(&o_conv);
5651         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
5652         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
5653         return (long)ret_conv;
5654 }
5655
5656 uint32_t  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
5657         LDKDecodeError e_conv;
5658         e_conv.inner = (void*)(e & (~1));
5659         e_conv.is_owned = (e & 1) || (e == 0);
5660         e_conv = DecodeError_clone(&e_conv);
5661         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
5662         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
5663         return (long)ret_conv;
5664 }
5665
5666 void  __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
5667         if ((_res & 1) != 0) return;
5668         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(((uint64_t)_res) & ~1);
5669         FREE((void*)_res);
5670         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
5671 }
5672
5673 void  __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
5674         LDKCVec_PublicKeyZ _res_constr;
5675         _res_constr.datalen = *((uint32_t*)_res);
5676         if (_res_constr.datalen > 0)
5677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
5678         else
5679                 _res_constr.data = NULL;
5680         int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5681         for (size_t m = 0; m < _res_constr.datalen; m++) {
5682                 int8_tArray arr_conv_12 = _res_vals[m];
5683                 LDKPublicKey arr_conv_12_ref;
5684                 CHECK(*((uint32_t*)arr_conv_12) == 33);
5685                 memcpy(arr_conv_12_ref.compressed_form, (uint8_t*)(arr_conv_12 + 4), 33);
5686                 _res_constr.data[m] = arr_conv_12_ref;
5687         }
5688         CVec_PublicKeyZ_free(_res_constr);
5689 }
5690
5691 void  __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
5692         LDKCVec_u8Z _res_ref;
5693         _res_ref.datalen = *((uint32_t*)_res);
5694         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
5695         memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5696         CVec_u8Z_free(_res_ref);
5697 }
5698
5699 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
5700         LDKCVec_u8Z o_ref;
5701         o_ref.datalen = *((uint32_t*)o);
5702         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
5703         memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
5704         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5705         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
5706         return (long)ret_conv;
5707 }
5708
5709 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
5710         LDKPeerHandleError e_conv;
5711         e_conv.inner = (void*)(e & (~1));
5712         e_conv.is_owned = (e & 1) || (e == 0);
5713         e_conv = PeerHandleError_clone(&e_conv);
5714         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5715         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
5716         return (long)ret_conv;
5717 }
5718
5719 void  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
5720         if ((_res & 1) != 0) return;
5721         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
5722         FREE((void*)_res);
5723         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
5724 }
5725
5726 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_clone(uint32_t orig) {
5727         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
5728         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5729         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
5730         return (long)ret_conv;
5731 }
5732
5733 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
5734         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5735         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
5736         return (long)ret_conv;
5737 }
5738
5739 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
5740         LDKPeerHandleError e_conv;
5741         e_conv.inner = (void*)(e & (~1));
5742         e_conv.is_owned = (e & 1) || (e == 0);
5743         e_conv = PeerHandleError_clone(&e_conv);
5744         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5745         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
5746         return (long)ret_conv;
5747 }
5748
5749 void  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
5750         if ((_res & 1) != 0) return;
5751         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(((uint64_t)_res) & ~1);
5752         FREE((void*)_res);
5753         CResult_NonePeerHandleErrorZ_free(_res_conv);
5754 }
5755
5756 uint32_t  __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_clone(uint32_t orig) {
5757         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
5758         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5759         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
5760         return (long)ret_conv;
5761 }
5762
5763 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
5764         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5765         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
5766         return (long)ret_conv;
5767 }
5768
5769 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
5770         LDKPeerHandleError e_conv;
5771         e_conv.inner = (void*)(e & (~1));
5772         e_conv.is_owned = (e & 1) || (e == 0);
5773         e_conv = PeerHandleError_clone(&e_conv);
5774         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5775         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
5776         return (long)ret_conv;
5777 }
5778
5779 void  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
5780         if ((_res & 1) != 0) return;
5781         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(((uint64_t)_res) & ~1);
5782         FREE((void*)_res);
5783         CResult_boolPeerHandleErrorZ_free(_res_conv);
5784 }
5785
5786 uint32_t  __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_clone(uint32_t orig) {
5787         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
5788         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5789         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
5790         return (long)ret_conv;
5791 }
5792
5793 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_ok(int8_tArray o) {
5794         LDKSecretKey o_ref;
5795         CHECK(*((uint32_t*)o) == 32);
5796         memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
5797         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
5798         *ret_conv = CResult_SecretKeySecpErrorZ_ok(o_ref);
5799         return (long)ret_conv;
5800 }
5801
5802 uint32_t  __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_err(uint32_t e) {
5803         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5804         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
5805         *ret_conv = CResult_SecretKeySecpErrorZ_err(e_conv);
5806         return (long)ret_conv;
5807 }
5808
5809 void  __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_free(uint32_t _res) {
5810         if ((_res & 1) != 0) return;
5811         LDKCResult_SecretKeySecpErrorZ _res_conv = *(LDKCResult_SecretKeySecpErrorZ*)(((uint64_t)_res) & ~1);
5812         FREE((void*)_res);
5813         CResult_SecretKeySecpErrorZ_free(_res_conv);
5814 }
5815
5816 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_ok(int8_tArray o) {
5817         LDKPublicKey o_ref;
5818         CHECK(*((uint32_t*)o) == 33);
5819         memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
5820         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
5821         *ret_conv = CResult_PublicKeySecpErrorZ_ok(o_ref);
5822         return (long)ret_conv;
5823 }
5824
5825 uint32_t  __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_err(uint32_t e) {
5826         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5827         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
5828         *ret_conv = CResult_PublicKeySecpErrorZ_err(e_conv);
5829         return (long)ret_conv;
5830 }
5831
5832 void  __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_free(uint32_t _res) {
5833         if ((_res & 1) != 0) return;
5834         LDKCResult_PublicKeySecpErrorZ _res_conv = *(LDKCResult_PublicKeySecpErrorZ*)(((uint64_t)_res) & ~1);
5835         FREE((void*)_res);
5836         CResult_PublicKeySecpErrorZ_free(_res_conv);
5837 }
5838
5839 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_ok(uint32_t o) {
5840         LDKTxCreationKeys o_conv;
5841         o_conv.inner = (void*)(o & (~1));
5842         o_conv.is_owned = (o & 1) || (o == 0);
5843         o_conv = TxCreationKeys_clone(&o_conv);
5844         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
5845         *ret_conv = CResult_TxCreationKeysSecpErrorZ_ok(o_conv);
5846         return (long)ret_conv;
5847 }
5848
5849 uint32_t  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_err(uint32_t e) {
5850         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5851         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
5852         *ret_conv = CResult_TxCreationKeysSecpErrorZ_err(e_conv);
5853         return (long)ret_conv;
5854 }
5855
5856 void  __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_free(uint32_t _res) {
5857         if ((_res & 1) != 0) return;
5858         LDKCResult_TxCreationKeysSecpErrorZ _res_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)(((uint64_t)_res) & ~1);
5859         FREE((void*)_res);
5860         CResult_TxCreationKeysSecpErrorZ_free(_res_conv);
5861 }
5862
5863 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
5864         LDKTrustedCommitmentTransaction o_conv;
5865         o_conv.inner = (void*)(o & (~1));
5866         o_conv.is_owned = (o & 1) || (o == 0);
5867         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
5868         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5869         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
5870         return (long)ret_conv;
5871 }
5872
5873 uint32_t  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
5874         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5875         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
5876         return (long)ret_conv;
5877 }
5878
5879 void  __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
5880         if ((_res & 1) != 0) return;
5881         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(((uint64_t)_res) & ~1);
5882         FREE((void*)_res);
5883         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
5884 }
5885
5886 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
5887         LDKCVec_SignatureZ o_constr;
5888         o_constr.datalen = *((uint32_t*)o);
5889         if (o_constr.datalen > 0)
5890                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
5891         else
5892                 o_constr.data = NULL;
5893         int8_tArray* o_vals = (int8_tArray*)(o + 4);
5894         for (size_t m = 0; m < o_constr.datalen; m++) {
5895                 int8_tArray arr_conv_12 = o_vals[m];
5896                 LDKSignature arr_conv_12_ref;
5897                 CHECK(*((uint32_t*)arr_conv_12) == 64);
5898                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
5899                 o_constr.data[m] = arr_conv_12_ref;
5900         }
5901         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5902         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
5903         return (long)ret_conv;
5904 }
5905
5906 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
5907         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5908         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
5909         return (long)ret_conv;
5910 }
5911
5912 void  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
5913         if ((_res & 1) != 0) return;
5914         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(((uint64_t)_res) & ~1);
5915         FREE((void*)_res);
5916         CResult_CVec_SignatureZNoneZ_free(_res_conv);
5917 }
5918
5919 uint32_t  __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_clone(uint32_t orig) {
5920         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
5921         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
5922         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
5923         return (long)ret_conv;
5924 }
5925
5926 void  __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
5927         LDKCVec_RouteHopZ _res_constr;
5928         _res_constr.datalen = *((uint32_t*)_res);
5929         if (_res_constr.datalen > 0)
5930                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
5931         else
5932                 _res_constr.data = NULL;
5933         uint32_t* _res_vals = (uint32_t*)(_res + 4);
5934         for (size_t k = 0; k < _res_constr.datalen; k++) {
5935                 uint32_t arr_conv_10 = _res_vals[k];
5936                 LDKRouteHop arr_conv_10_conv;
5937                 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
5938                 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
5939                 _res_constr.data[k] = arr_conv_10_conv;
5940         }
5941         CVec_RouteHopZ_free(_res_constr);
5942 }
5943
5944 void  __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
5945         LDKCVec_CVec_RouteHopZZ _res_constr;
5946         _res_constr.datalen = *((uint32_t*)_res);
5947         if (_res_constr.datalen > 0)
5948                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
5949         else
5950                 _res_constr.data = NULL;
5951         uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
5952         for (size_t m = 0; m < _res_constr.datalen; m++) {
5953                 uint32_tArray arr_conv_12 = _res_vals[m];
5954                 LDKCVec_RouteHopZ arr_conv_12_constr;
5955                 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
5956                 if (arr_conv_12_constr.datalen > 0)
5957                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
5958                 else
5959                         arr_conv_12_constr.data = NULL;
5960                 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
5961                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
5962                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
5963                         LDKRouteHop arr_conv_10_conv;
5964                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
5965                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
5966                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
5967                 }
5968                 _res_constr.data[m] = arr_conv_12_constr;
5969         }
5970         CVec_CVec_RouteHopZZ_free(_res_constr);
5971 }
5972
5973 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
5974         LDKRoute o_conv;
5975         o_conv.inner = (void*)(o & (~1));
5976         o_conv.is_owned = (o & 1) || (o == 0);
5977         o_conv = Route_clone(&o_conv);
5978         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
5979         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
5980         return (long)ret_conv;
5981 }
5982
5983 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
5984         LDKDecodeError e_conv;
5985         e_conv.inner = (void*)(e & (~1));
5986         e_conv.is_owned = (e & 1) || (e == 0);
5987         e_conv = DecodeError_clone(&e_conv);
5988         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
5989         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
5990         return (long)ret_conv;
5991 }
5992
5993 void  __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
5994         if ((_res & 1) != 0) return;
5995         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(((uint64_t)_res) & ~1);
5996         FREE((void*)_res);
5997         CResult_RouteDecodeErrorZ_free(_res_conv);
5998 }
5999
6000 void  __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
6001         LDKCVec_RouteHintZ _res_constr;
6002         _res_constr.datalen = *((uint32_t*)_res);
6003         if (_res_constr.datalen > 0)
6004                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
6005         else
6006                 _res_constr.data = NULL;
6007         uint32_t* _res_vals = (uint32_t*)(_res + 4);
6008         for (size_t l = 0; l < _res_constr.datalen; l++) {
6009                 uint32_t arr_conv_11 = _res_vals[l];
6010                 LDKRouteHint arr_conv_11_conv;
6011                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
6012                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
6013                 _res_constr.data[l] = arr_conv_11_conv;
6014         }
6015         CVec_RouteHintZ_free(_res_constr);
6016 }
6017
6018 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
6019         LDKRoute o_conv;
6020         o_conv.inner = (void*)(o & (~1));
6021         o_conv.is_owned = (o & 1) || (o == 0);
6022         o_conv = Route_clone(&o_conv);
6023         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6024         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
6025         return (long)ret_conv;
6026 }
6027
6028 uint32_t  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
6029         LDKLightningError e_conv;
6030         e_conv.inner = (void*)(e & (~1));
6031         e_conv.is_owned = (e & 1) || (e == 0);
6032         e_conv = LightningError_clone(&e_conv);
6033         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6034         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
6035         return (long)ret_conv;
6036 }
6037
6038 void  __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
6039         if ((_res & 1) != 0) return;
6040         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(((uint64_t)_res) & ~1);
6041         FREE((void*)_res);
6042         CResult_RouteLightningErrorZ_free(_res_conv);
6043 }
6044
6045 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
6046         LDKRoutingFees o_conv;
6047         o_conv.inner = (void*)(o & (~1));
6048         o_conv.is_owned = (o & 1) || (o == 0);
6049         o_conv = RoutingFees_clone(&o_conv);
6050         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6051         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
6052         return (long)ret_conv;
6053 }
6054
6055 uint32_t  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
6056         LDKDecodeError e_conv;
6057         e_conv.inner = (void*)(e & (~1));
6058         e_conv.is_owned = (e & 1) || (e == 0);
6059         e_conv = DecodeError_clone(&e_conv);
6060         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6061         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
6062         return (long)ret_conv;
6063 }
6064
6065 void  __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
6066         if ((_res & 1) != 0) return;
6067         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(((uint64_t)_res) & ~1);
6068         FREE((void*)_res);
6069         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
6070 }
6071
6072 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
6073         LDKNodeAnnouncementInfo o_conv;
6074         o_conv.inner = (void*)(o & (~1));
6075         o_conv.is_owned = (o & 1) || (o == 0);
6076         o_conv = NodeAnnouncementInfo_clone(&o_conv);
6077         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6078         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
6079         return (long)ret_conv;
6080 }
6081
6082 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
6083         LDKDecodeError e_conv;
6084         e_conv.inner = (void*)(e & (~1));
6085         e_conv.is_owned = (e & 1) || (e == 0);
6086         e_conv = DecodeError_clone(&e_conv);
6087         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6088         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
6089         return (long)ret_conv;
6090 }
6091
6092 void  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
6093         if ((_res & 1) != 0) return;
6094         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6095         FREE((void*)_res);
6096         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
6097 }
6098
6099 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_clone(uint32_t orig) {
6100         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
6101         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6102         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
6103         return (long)ret_conv;
6104 }
6105
6106 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
6107         LDKNodeInfo o_conv;
6108         o_conv.inner = (void*)(o & (~1));
6109         o_conv.is_owned = (o & 1) || (o == 0);
6110         o_conv = NodeInfo_clone(&o_conv);
6111         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6112         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
6113         return (long)ret_conv;
6114 }
6115
6116 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
6117         LDKDecodeError e_conv;
6118         e_conv.inner = (void*)(e & (~1));
6119         e_conv.is_owned = (e & 1) || (e == 0);
6120         e_conv = DecodeError_clone(&e_conv);
6121         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6122         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
6123         return (long)ret_conv;
6124 }
6125
6126 void  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
6127         if ((_res & 1) != 0) return;
6128         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(((uint64_t)_res) & ~1);
6129         FREE((void*)_res);
6130         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
6131 }
6132
6133 uint32_t  __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_clone(uint32_t orig) {
6134         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
6135         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6136         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
6137         return (long)ret_conv;
6138 }
6139
6140 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
6141         LDKNetworkGraph o_conv;
6142         o_conv.inner = (void*)(o & (~1));
6143         o_conv.is_owned = (o & 1) || (o == 0);
6144         // Warning: we need a move here but no clone is available for LDKNetworkGraph
6145         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6146         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
6147         return (long)ret_conv;
6148 }
6149
6150 uint32_t  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
6151         LDKDecodeError e_conv;
6152         e_conv.inner = (void*)(e & (~1));
6153         e_conv.is_owned = (e & 1) || (e == 0);
6154         e_conv = DecodeError_clone(&e_conv);
6155         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6156         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
6157         return (long)ret_conv;
6158 }
6159
6160 void  __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
6161         if ((_res & 1) != 0) return;
6162         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(((uint64_t)_res) & ~1);
6163         FREE((void*)_res);
6164         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
6165 }
6166
6167 void  __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
6168         if ((this_ptr & 1) != 0) return;
6169         LDKEvent this_ptr_conv = *(LDKEvent*)(((uint64_t)this_ptr) & ~1);
6170         FREE((void*)this_ptr);
6171         Event_free(this_ptr_conv);
6172 }
6173
6174 uint32_t  __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
6175         LDKEvent* orig_conv = (LDKEvent*)orig;
6176         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6177         *ret_copy = Event_clone(orig_conv);
6178         long ret_ref = (long)ret_copy;
6179         return ret_ref;
6180 }
6181
6182 int8_tArray  __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
6183         LDKEvent* obj_conv = (LDKEvent*)obj;
6184         LDKCVec_u8Z arg_var = Event_write(obj_conv);
6185         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6186         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
6187         CVec_u8Z_free(arg_var);
6188         return arg_arr;
6189 }
6190
6191 void  __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
6192         if ((this_ptr & 1) != 0) return;
6193         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(((uint64_t)this_ptr) & ~1);
6194         FREE((void*)this_ptr);
6195         MessageSendEvent_free(this_ptr_conv);
6196 }
6197
6198 uint32_t  __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
6199         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
6200         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6201         *ret_copy = MessageSendEvent_clone(orig_conv);
6202         long ret_ref = (long)ret_copy;
6203         return ret_ref;
6204 }
6205
6206 void  __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
6207         if ((this_ptr & 1) != 0) return;
6208         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(((uint64_t)this_ptr) & ~1);
6209         FREE((void*)this_ptr);
6210         MessageSendEventsProvider_free(this_ptr_conv);
6211 }
6212
6213 void  __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
6214         if ((this_ptr & 1) != 0) return;
6215         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(((uint64_t)this_ptr) & ~1);
6216         FREE((void*)this_ptr);
6217         EventsProvider_free(this_ptr_conv);
6218 }
6219
6220 void  __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
6221         if ((this_ptr & 1) != 0) return;
6222         LDKAPIError this_ptr_conv = *(LDKAPIError*)(((uint64_t)this_ptr) & ~1);
6223         FREE((void*)this_ptr);
6224         APIError_free(this_ptr_conv);
6225 }
6226
6227 uint32_t  __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
6228         LDKAPIError* orig_conv = (LDKAPIError*)orig;
6229         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6230         *ret_copy = APIError_clone(orig_conv);
6231         long ret_ref = (long)ret_copy;
6232         return ret_ref;
6233 }
6234
6235 uint32_t  __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
6236         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
6237         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
6238         return ret_conv;
6239 }
6240
6241 uint32_t  __attribute__((visibility("default"))) TS_Level_max() {
6242         uint32_t ret_conv = LDKLevel_to_js(Level_max());
6243         return ret_conv;
6244 }
6245
6246 void  __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
6247         if ((this_ptr & 1) != 0) return;
6248         LDKLogger this_ptr_conv = *(LDKLogger*)(((uint64_t)this_ptr) & ~1);
6249         FREE((void*)this_ptr);
6250         Logger_free(this_ptr_conv);
6251 }
6252
6253 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_ptr) {
6254         LDKChannelHandshakeConfig this_ptr_conv;
6255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6256         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6257         ChannelHandshakeConfig_free(this_ptr_conv);
6258 }
6259
6260 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
6261         LDKChannelHandshakeConfig orig_conv;
6262         orig_conv.inner = (void*)(orig & (~1));
6263         orig_conv.is_owned = false;
6264         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
6265         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6266         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6267         long ret_ref = (long)ret_var.inner;
6268         if (ret_var.is_owned) {
6269                 ret_ref |= 1;
6270         }
6271         return ret_ref;
6272 }
6273
6274 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
6275         LDKChannelHandshakeConfig this_ptr_conv;
6276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6277         this_ptr_conv.is_owned = false;
6278         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
6279         return ret_val;
6280 }
6281
6282 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
6283         LDKChannelHandshakeConfig this_ptr_conv;
6284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6285         this_ptr_conv.is_owned = false;
6286         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
6287 }
6288
6289 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
6290         LDKChannelHandshakeConfig this_ptr_conv;
6291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6292         this_ptr_conv.is_owned = false;
6293         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
6294         return ret_val;
6295 }
6296
6297 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
6298         LDKChannelHandshakeConfig this_ptr_conv;
6299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6300         this_ptr_conv.is_owned = false;
6301         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
6302 }
6303
6304 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
6305         LDKChannelHandshakeConfig this_ptr_conv;
6306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6307         this_ptr_conv.is_owned = false;
6308         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
6309         return ret_val;
6310 }
6311
6312 void  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
6313         LDKChannelHandshakeConfig this_ptr_conv;
6314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6315         this_ptr_conv.is_owned = false;
6316         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
6317 }
6318
6319 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) {
6320         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
6321         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6322         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6323         long ret_ref = (long)ret_var.inner;
6324         if (ret_var.is_owned) {
6325                 ret_ref |= 1;
6326         }
6327         return ret_ref;
6328 }
6329
6330 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
6331         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
6332         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6333         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6334         long ret_ref = (long)ret_var.inner;
6335         if (ret_var.is_owned) {
6336                 ret_ref |= 1;
6337         }
6338         return ret_ref;
6339 }
6340
6341 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_ptr) {
6342         LDKChannelHandshakeLimits this_ptr_conv;
6343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6344         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6345         ChannelHandshakeLimits_free(this_ptr_conv);
6346 }
6347
6348 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
6349         LDKChannelHandshakeLimits orig_conv;
6350         orig_conv.inner = (void*)(orig & (~1));
6351         orig_conv.is_owned = false;
6352         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
6353         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6354         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6355         long ret_ref = (long)ret_var.inner;
6356         if (ret_var.is_owned) {
6357                 ret_ref |= 1;
6358         }
6359         return ret_ref;
6360 }
6361
6362 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
6363         LDKChannelHandshakeLimits this_ptr_conv;
6364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6365         this_ptr_conv.is_owned = false;
6366         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
6367         return ret_val;
6368 }
6369
6370 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
6371         LDKChannelHandshakeLimits this_ptr_conv;
6372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6373         this_ptr_conv.is_owned = false;
6374         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
6375 }
6376
6377 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
6378         LDKChannelHandshakeLimits this_ptr_conv;
6379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6380         this_ptr_conv.is_owned = false;
6381         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
6382         return ret_val;
6383 }
6384
6385 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
6386         LDKChannelHandshakeLimits this_ptr_conv;
6387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6388         this_ptr_conv.is_owned = false;
6389         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
6390 }
6391
6392 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
6393         LDKChannelHandshakeLimits this_ptr_conv;
6394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6395         this_ptr_conv.is_owned = false;
6396         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
6397         return ret_val;
6398 }
6399
6400 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
6401         LDKChannelHandshakeLimits this_ptr_conv;
6402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6403         this_ptr_conv.is_owned = false;
6404         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6405 }
6406
6407 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
6408         LDKChannelHandshakeLimits this_ptr_conv;
6409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6410         this_ptr_conv.is_owned = false;
6411         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
6412         return ret_val;
6413 }
6414
6415 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
6416         LDKChannelHandshakeLimits this_ptr_conv;
6417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6418         this_ptr_conv.is_owned = false;
6419         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
6420 }
6421
6422 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
6423         LDKChannelHandshakeLimits this_ptr_conv;
6424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6425         this_ptr_conv.is_owned = false;
6426         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
6427         return ret_val;
6428 }
6429
6430 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
6431         LDKChannelHandshakeLimits this_ptr_conv;
6432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6433         this_ptr_conv.is_owned = false;
6434         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
6435 }
6436
6437 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_dust_limit_satoshis(uint32_t this_ptr) {
6438         LDKChannelHandshakeLimits this_ptr_conv;
6439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6440         this_ptr_conv.is_owned = false;
6441         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
6442         return ret_val;
6443 }
6444
6445 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
6446         LDKChannelHandshakeLimits this_ptr_conv;
6447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6448         this_ptr_conv.is_owned = false;
6449         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
6450 }
6451
6452 int64_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_dust_limit_satoshis(uint32_t this_ptr) {
6453         LDKChannelHandshakeLimits this_ptr_conv;
6454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6455         this_ptr_conv.is_owned = false;
6456         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
6457         return ret_val;
6458 }
6459
6460 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
6461         LDKChannelHandshakeLimits this_ptr_conv;
6462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6463         this_ptr_conv.is_owned = false;
6464         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
6465 }
6466
6467 int32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
6468         LDKChannelHandshakeLimits this_ptr_conv;
6469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6470         this_ptr_conv.is_owned = false;
6471         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
6472         return ret_val;
6473 }
6474
6475 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
6476         LDKChannelHandshakeLimits this_ptr_conv;
6477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6478         this_ptr_conv.is_owned = false;
6479         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
6480 }
6481
6482 jboolean  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
6483         LDKChannelHandshakeLimits this_ptr_conv;
6484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6485         this_ptr_conv.is_owned = false;
6486         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
6487         return ret_val;
6488 }
6489
6490 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
6491         LDKChannelHandshakeLimits this_ptr_conv;
6492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6493         this_ptr_conv.is_owned = false;
6494         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
6495 }
6496
6497 int16_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
6498         LDKChannelHandshakeLimits this_ptr_conv;
6499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6500         this_ptr_conv.is_owned = false;
6501         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
6502         return ret_val;
6503 }
6504
6505 void  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
6506         LDKChannelHandshakeLimits this_ptr_conv;
6507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6508         this_ptr_conv.is_owned = false;
6509         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
6510 }
6511
6512 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) {
6513         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);
6514         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6515         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6516         long ret_ref = (long)ret_var.inner;
6517         if (ret_var.is_owned) {
6518                 ret_ref |= 1;
6519         }
6520         return ret_ref;
6521 }
6522
6523 uint32_t  __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
6524         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
6525         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6526         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6527         long ret_ref = (long)ret_var.inner;
6528         if (ret_var.is_owned) {
6529                 ret_ref |= 1;
6530         }
6531         return ret_ref;
6532 }
6533
6534 void  __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_ptr) {
6535         LDKChannelConfig this_ptr_conv;
6536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6537         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6538         ChannelConfig_free(this_ptr_conv);
6539 }
6540
6541 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
6542         LDKChannelConfig orig_conv;
6543         orig_conv.inner = (void*)(orig & (~1));
6544         orig_conv.is_owned = false;
6545         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
6546         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6547         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6548         long ret_ref = (long)ret_var.inner;
6549         if (ret_var.is_owned) {
6550                 ret_ref |= 1;
6551         }
6552         return ret_ref;
6553 }
6554
6555 int32_t  __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
6556         LDKChannelConfig this_ptr_conv;
6557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6558         this_ptr_conv.is_owned = false;
6559         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
6560         return ret_val;
6561 }
6562
6563 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
6564         LDKChannelConfig this_ptr_conv;
6565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6566         this_ptr_conv.is_owned = false;
6567         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
6568 }
6569
6570 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
6571         LDKChannelConfig this_ptr_conv;
6572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6573         this_ptr_conv.is_owned = false;
6574         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
6575         return ret_val;
6576 }
6577
6578 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
6579         LDKChannelConfig this_ptr_conv;
6580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6581         this_ptr_conv.is_owned = false;
6582         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
6583 }
6584
6585 jboolean  __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
6586         LDKChannelConfig this_ptr_conv;
6587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6588         this_ptr_conv.is_owned = false;
6589         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
6590         return ret_val;
6591 }
6592
6593 void  __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
6594         LDKChannelConfig this_ptr_conv;
6595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6596         this_ptr_conv.is_owned = false;
6597         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
6598 }
6599
6600 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
6601         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
6602         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6603         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6604         long ret_ref = (long)ret_var.inner;
6605         if (ret_var.is_owned) {
6606                 ret_ref |= 1;
6607         }
6608         return ret_ref;
6609 }
6610
6611 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_default() {
6612         LDKChannelConfig ret_var = ChannelConfig_default();
6613         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6614         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6615         long ret_ref = (long)ret_var.inner;
6616         if (ret_var.is_owned) {
6617                 ret_ref |= 1;
6618         }
6619         return ret_ref;
6620 }
6621
6622 int8_tArray  __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
6623         LDKChannelConfig obj_conv;
6624         obj_conv.inner = (void*)(obj & (~1));
6625         obj_conv.is_owned = false;
6626         LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
6627         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6628         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
6629         CVec_u8Z_free(arg_var);
6630         return arg_arr;
6631 }
6632
6633 uint32_t  __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
6634         LDKu8slice ser_ref;
6635         ser_ref.datalen = *((uint32_t*)ser);
6636         ser_ref.data = (int8_t*)(ser + 4);
6637         LDKChannelConfig ret_var = ChannelConfig_read(ser_ref);
6638         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6639         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6640         long ret_ref = (long)ret_var.inner;
6641         if (ret_var.is_owned) {
6642                 ret_ref |= 1;
6643         }
6644         return ret_ref;
6645 }
6646
6647 void  __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_ptr) {
6648         LDKUserConfig this_ptr_conv;
6649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6650         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6651         UserConfig_free(this_ptr_conv);
6652 }
6653
6654 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
6655         LDKUserConfig orig_conv;
6656         orig_conv.inner = (void*)(orig & (~1));
6657         orig_conv.is_owned = false;
6658         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
6659         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6660         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6661         long ret_ref = (long)ret_var.inner;
6662         if (ret_var.is_owned) {
6663                 ret_ref |= 1;
6664         }
6665         return ret_ref;
6666 }
6667
6668 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
6669         LDKUserConfig this_ptr_conv;
6670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6671         this_ptr_conv.is_owned = false;
6672         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
6673         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6674         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6675         long ret_ref = (long)ret_var.inner;
6676         if (ret_var.is_owned) {
6677                 ret_ref |= 1;
6678         }
6679         return ret_ref;
6680 }
6681
6682 void  __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
6683         LDKUserConfig this_ptr_conv;
6684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6685         this_ptr_conv.is_owned = false;
6686         LDKChannelHandshakeConfig val_conv;
6687         val_conv.inner = (void*)(val & (~1));
6688         val_conv.is_owned = (val & 1) || (val == 0);
6689         val_conv = ChannelHandshakeConfig_clone(&val_conv);
6690         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
6691 }
6692
6693 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
6694         LDKUserConfig this_ptr_conv;
6695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6696         this_ptr_conv.is_owned = false;
6697         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
6698         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6699         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6700         long ret_ref = (long)ret_var.inner;
6701         if (ret_var.is_owned) {
6702                 ret_ref |= 1;
6703         }
6704         return ret_ref;
6705 }
6706
6707 void  __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
6708         LDKUserConfig this_ptr_conv;
6709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6710         this_ptr_conv.is_owned = false;
6711         LDKChannelHandshakeLimits val_conv;
6712         val_conv.inner = (void*)(val & (~1));
6713         val_conv.is_owned = (val & 1) || (val == 0);
6714         val_conv = ChannelHandshakeLimits_clone(&val_conv);
6715         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
6716 }
6717
6718 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
6719         LDKUserConfig this_ptr_conv;
6720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6721         this_ptr_conv.is_owned = false;
6722         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
6723         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6724         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6725         long ret_ref = (long)ret_var.inner;
6726         if (ret_var.is_owned) {
6727                 ret_ref |= 1;
6728         }
6729         return ret_ref;
6730 }
6731
6732 void  __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
6733         LDKUserConfig this_ptr_conv;
6734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6735         this_ptr_conv.is_owned = false;
6736         LDKChannelConfig val_conv;
6737         val_conv.inner = (void*)(val & (~1));
6738         val_conv.is_owned = (val & 1) || (val == 0);
6739         val_conv = ChannelConfig_clone(&val_conv);
6740         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
6741 }
6742
6743 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) {
6744         LDKChannelHandshakeConfig own_channel_config_arg_conv;
6745         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
6746         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
6747         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
6748         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
6749         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
6750         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
6751         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
6752         LDKChannelConfig channel_options_arg_conv;
6753         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
6754         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
6755         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
6756         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
6757         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6758         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6759         long ret_ref = (long)ret_var.inner;
6760         if (ret_var.is_owned) {
6761                 ret_ref |= 1;
6762         }
6763         return ret_ref;
6764 }
6765
6766 uint32_t  __attribute__((visibility("default"))) TS_UserConfig_default() {
6767         LDKUserConfig ret_var = UserConfig_default();
6768         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6769         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6770         long ret_ref = (long)ret_var.inner;
6771         if (ret_var.is_owned) {
6772                 ret_ref |= 1;
6773         }
6774         return ret_ref;
6775 }
6776
6777 uint32_t  __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
6778         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
6779         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
6780         return ret_conv;
6781 }
6782
6783 void  __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
6784         if ((this_ptr & 1) != 0) return;
6785         LDKAccess this_ptr_conv = *(LDKAccess*)(((uint64_t)this_ptr) & ~1);
6786         FREE((void*)this_ptr);
6787         Access_free(this_ptr_conv);
6788 }
6789
6790 void  __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
6791         if ((this_ptr & 1) != 0) return;
6792         LDKWatch this_ptr_conv = *(LDKWatch*)(((uint64_t)this_ptr) & ~1);
6793         FREE((void*)this_ptr);
6794         Watch_free(this_ptr_conv);
6795 }
6796
6797 void  __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
6798         if ((this_ptr & 1) != 0) return;
6799         LDKFilter this_ptr_conv = *(LDKFilter*)(((uint64_t)this_ptr) & ~1);
6800         FREE((void*)this_ptr);
6801         Filter_free(this_ptr_conv);
6802 }
6803
6804 void  __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
6805         if ((this_ptr & 1) != 0) return;
6806         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(((uint64_t)this_ptr) & ~1);
6807         FREE((void*)this_ptr);
6808         BroadcasterInterface_free(this_ptr_conv);
6809 }
6810
6811 uint32_t  __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
6812         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
6813         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
6814         return ret_conv;
6815 }
6816
6817 void  __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
6818         if ((this_ptr & 1) != 0) return;
6819         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(((uint64_t)this_ptr) & ~1);
6820         FREE((void*)this_ptr);
6821         FeeEstimator_free(this_ptr_conv);
6822 }
6823
6824 void  __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_ptr) {
6825         LDKChainMonitor this_ptr_conv;
6826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6827         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6828         ChainMonitor_free(this_ptr_conv);
6829 }
6830
6831 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
6832         LDKChainMonitor this_arg_conv;
6833         this_arg_conv.inner = (void*)(this_arg & (~1));
6834         this_arg_conv.is_owned = false;
6835         unsigned char header_arr[80];
6836         CHECK(*((uint32_t*)header) == 80);
6837         memcpy(header_arr, (uint8_t*)(header + 4), 80);
6838         unsigned char (*header_ref)[80] = &header_arr;
6839         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6840         txdata_constr.datalen = *((uint32_t*)txdata);
6841         if (txdata_constr.datalen > 0)
6842                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6843         else
6844                 txdata_constr.data = NULL;
6845         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
6846         for (size_t e = 0; e < txdata_constr.datalen; e++) {
6847                 uint32_t arr_conv_30 = txdata_vals[e];
6848                 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_conv_30) & ~1);
6849                 FREE((void*)arr_conv_30);
6850                 txdata_constr.data[e] = arr_conv_30_conv;
6851         }
6852         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
6853 }
6854
6855 void  __attribute__((visibility("default"))) TS_ChainMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
6856         LDKChainMonitor this_arg_conv;
6857         this_arg_conv.inner = (void*)(this_arg & (~1));
6858         this_arg_conv.is_owned = false;
6859         unsigned char header_arr[80];
6860         CHECK(*((uint32_t*)header) == 80);
6861         memcpy(header_arr, (uint8_t*)(header + 4), 80);
6862         unsigned char (*header_ref)[80] = &header_arr;
6863         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
6864 }
6865
6866 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
6867         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
6868         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
6869         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
6870         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(((uint64_t)feeest) & ~1);
6871         LDKPersist persister_conv = *(LDKPersist*)(((uint64_t)persister) & ~1);
6872         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
6873         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6874         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6875         long ret_ref = (long)ret_var.inner;
6876         if (ret_var.is_owned) {
6877                 ret_ref |= 1;
6878         }
6879         return ret_ref;
6880 }
6881
6882 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
6883         LDKChainMonitor this_arg_conv;
6884         this_arg_conv.inner = (void*)(this_arg & (~1));
6885         this_arg_conv.is_owned = false;
6886         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
6887         *ret = ChainMonitor_as_Watch(&this_arg_conv);
6888         return (long)ret;
6889 }
6890
6891 uint32_t  __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
6892         LDKChainMonitor this_arg_conv;
6893         this_arg_conv.inner = (void*)(this_arg & (~1));
6894         this_arg_conv.is_owned = false;
6895         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6896         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
6897         return (long)ret;
6898 }
6899
6900 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_ptr) {
6901         LDKChannelMonitorUpdate this_ptr_conv;
6902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6903         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6904         ChannelMonitorUpdate_free(this_ptr_conv);
6905 }
6906
6907 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
6908         LDKChannelMonitorUpdate orig_conv;
6909         orig_conv.inner = (void*)(orig & (~1));
6910         orig_conv.is_owned = false;
6911         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
6912         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6913         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6914         long ret_ref = (long)ret_var.inner;
6915         if (ret_var.is_owned) {
6916                 ret_ref |= 1;
6917         }
6918         return ret_ref;
6919 }
6920
6921 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
6922         LDKChannelMonitorUpdate this_ptr_conv;
6923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6924         this_ptr_conv.is_owned = false;
6925         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
6926         return ret_val;
6927 }
6928
6929 void  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
6930         LDKChannelMonitorUpdate this_ptr_conv;
6931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6932         this_ptr_conv.is_owned = false;
6933         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
6934 }
6935
6936 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
6937         LDKChannelMonitorUpdate obj_conv;
6938         obj_conv.inner = (void*)(obj & (~1));
6939         obj_conv.is_owned = false;
6940         LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
6941         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6942         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
6943         CVec_u8Z_free(arg_var);
6944         return arg_arr;
6945 }
6946
6947 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
6948         LDKu8slice ser_ref;
6949         ser_ref.datalen = *((uint32_t*)ser);
6950         ser_ref.data = (int8_t*)(ser + 4);
6951         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6952         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
6953         return (long)ret_conv;
6954 }
6955
6956 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
6957         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
6958         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
6959         return ret_conv;
6960 }
6961
6962 void  __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_ptr) {
6963         LDKMonitorUpdateError this_ptr_conv;
6964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6965         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6966         MonitorUpdateError_free(this_ptr_conv);
6967 }
6968
6969 uint32_t  __attribute__((visibility("default"))) TS_MonitorUpdateError_clone(uint32_t orig) {
6970         LDKMonitorUpdateError orig_conv;
6971         orig_conv.inner = (void*)(orig & (~1));
6972         orig_conv.is_owned = false;
6973         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
6974         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6975         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6976         long ret_ref = (long)ret_var.inner;
6977         if (ret_var.is_owned) {
6978                 ret_ref |= 1;
6979         }
6980         return ret_ref;
6981 }
6982
6983 void  __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
6984         LDKMonitorEvent this_ptr_conv;
6985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6986         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6987         MonitorEvent_free(this_ptr_conv);
6988 }
6989
6990 uint32_t  __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
6991         LDKMonitorEvent orig_conv;
6992         orig_conv.inner = (void*)(orig & (~1));
6993         orig_conv.is_owned = false;
6994         LDKMonitorEvent ret_var = MonitorEvent_clone(&orig_conv);
6995         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6996         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6997         long ret_ref = (long)ret_var.inner;
6998         if (ret_var.is_owned) {
6999                 ret_ref |= 1;
7000         }
7001         return ret_ref;
7002 }
7003
7004 void  __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_ptr) {
7005         LDKHTLCUpdate this_ptr_conv;
7006         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7007         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7008         HTLCUpdate_free(this_ptr_conv);
7009 }
7010
7011 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
7012         LDKHTLCUpdate orig_conv;
7013         orig_conv.inner = (void*)(orig & (~1));
7014         orig_conv.is_owned = false;
7015         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
7016         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7017         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7018         long ret_ref = (long)ret_var.inner;
7019         if (ret_var.is_owned) {
7020                 ret_ref |= 1;
7021         }
7022         return ret_ref;
7023 }
7024
7025 int8_tArray  __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
7026         LDKHTLCUpdate obj_conv;
7027         obj_conv.inner = (void*)(obj & (~1));
7028         obj_conv.is_owned = false;
7029         LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
7030         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7031         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7032         CVec_u8Z_free(arg_var);
7033         return arg_arr;
7034 }
7035
7036 uint32_t  __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
7037         LDKu8slice ser_ref;
7038         ser_ref.datalen = *((uint32_t*)ser);
7039         ser_ref.data = (int8_t*)(ser + 4);
7040         LDKHTLCUpdate ret_var = HTLCUpdate_read(ser_ref);
7041         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7042         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7043         long ret_ref = (long)ret_var.inner;
7044         if (ret_var.is_owned) {
7045                 ret_ref |= 1;
7046         }
7047         return ret_ref;
7048 }
7049
7050 void  __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_ptr) {
7051         LDKChannelMonitor this_ptr_conv;
7052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7053         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7054         ChannelMonitor_free(this_ptr_conv);
7055 }
7056
7057 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_clone(uint32_t orig) {
7058         LDKChannelMonitor orig_conv;
7059         orig_conv.inner = (void*)(orig & (~1));
7060         orig_conv.is_owned = false;
7061         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
7062         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7063         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7064         long ret_ref = (long)ret_var.inner;
7065         if (ret_var.is_owned) {
7066                 ret_ref |= 1;
7067         }
7068         return ret_ref;
7069 }
7070
7071 int8_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
7072         LDKChannelMonitor obj_conv;
7073         obj_conv.inner = (void*)(obj & (~1));
7074         obj_conv.is_owned = false;
7075         LDKCVec_u8Z arg_var = ChannelMonitor_write(&obj_conv);
7076         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7077         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7078         CVec_u8Z_free(arg_var);
7079         return arg_arr;
7080 }
7081
7082 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) {
7083         LDKChannelMonitor this_arg_conv;
7084         this_arg_conv.inner = (void*)(this_arg & (~1));
7085         this_arg_conv.is_owned = false;
7086         LDKChannelMonitorUpdate updates_conv;
7087         updates_conv.inner = (void*)(updates & (~1));
7088         updates_conv.is_owned = false;
7089         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
7090         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator;
7091         LDKLogger* logger_conv = (LDKLogger*)logger;
7092         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7093         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
7094         return (long)ret_conv;
7095 }
7096
7097 int64_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
7098         LDKChannelMonitor this_arg_conv;
7099         this_arg_conv.inner = (void*)(this_arg & (~1));
7100         this_arg_conv.is_owned = false;
7101         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
7102         return ret_val;
7103 }
7104
7105 uint32_t  __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
7106         LDKChannelMonitor this_arg_conv;
7107         this_arg_conv.inner = (void*)(this_arg & (~1));
7108         this_arg_conv.is_owned = false;
7109         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7110         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
7111         return (long)ret_ref;
7112 }
7113
7114 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
7115         LDKChannelMonitor this_arg_conv;
7116         this_arg_conv.inner = (void*)(this_arg & (~1));
7117         this_arg_conv.is_owned = false;
7118         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
7119         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7120         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7121         for (size_t o = 0; o < ret_var.datalen; o++) {
7122                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
7123                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7124                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7125                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
7126                 if (arr_conv_14_var.is_owned) {
7127                         arr_conv_14_ref |= 1;
7128                 }
7129                 ret_arr_ptr[o] = arr_conv_14_ref;
7130         }
7131         FREE(ret_var.data);
7132         return ret_arr;
7133 }
7134
7135 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
7136         LDKChannelMonitor this_arg_conv;
7137         this_arg_conv.inner = (void*)(this_arg & (~1));
7138         this_arg_conv.is_owned = false;
7139         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
7140         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7141         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7142         for (size_t h = 0; h < ret_var.datalen; h++) {
7143                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
7144                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
7145                 long arr_conv_7_ref = (long)arr_conv_7_copy;
7146                 ret_arr_ptr[h] = arr_conv_7_ref;
7147         }
7148         FREE(ret_var.data);
7149         return ret_arr;
7150 }
7151
7152 ptrArray  __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
7153         LDKChannelMonitor this_arg_conv;
7154         this_arg_conv.inner = (void*)(this_arg & (~1));
7155         this_arg_conv.is_owned = false;
7156         LDKLogger* logger_conv = (LDKLogger*)logger;
7157         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
7158         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
7159         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
7160         for (size_t m = 0; m < ret_var.datalen; m++) {
7161                 LDKTransaction arr_conv_12_var = ret_var.data[m];
7162                 int8_tArray arr_conv_12_arr = init_arr(arr_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7163                 memcpy((uint8_t*)(arr_conv_12_arr + 4), arr_conv_12_var.data, arr_conv_12_var.datalen);
7164                 Transaction_free(arr_conv_12_var);
7165                 ret_arr_ptr[m] = arr_conv_12_arr;
7166         }
7167         FREE(ret_var.data);
7168         return ret_arr;
7169 }
7170
7171 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) {
7172         LDKChannelMonitor this_arg_conv;
7173         this_arg_conv.inner = (void*)(this_arg & (~1));
7174         this_arg_conv.is_owned = false;
7175         unsigned char header_arr[80];
7176         CHECK(*((uint32_t*)header) == 80);
7177         memcpy(header_arr, (uint8_t*)(header + 4), 80);
7178         unsigned char (*header_ref)[80] = &header_arr;
7179         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7180         txdata_constr.datalen = *((uint32_t*)txdata);
7181         if (txdata_constr.datalen > 0)
7182                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7183         else
7184                 txdata_constr.data = NULL;
7185         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
7186         for (size_t e = 0; e < txdata_constr.datalen; e++) {
7187                 uint32_t arr_conv_30 = txdata_vals[e];
7188                 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_conv_30) & ~1);
7189                 FREE((void*)arr_conv_30);
7190                 txdata_constr.data[e] = arr_conv_30_conv;
7191         }
7192         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
7193         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
7194         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
7195         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);
7196         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7197         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7198         for (size_t x = 0; x < ret_var.datalen; x++) {
7199                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arr_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
7200                 *arr_conv_49_ref = ret_var.data[x];
7201                 ret_arr_ptr[x] = (long)arr_conv_49_ref;
7202         }
7203         FREE(ret_var.data);
7204         return ret_arr;
7205 }
7206
7207 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) {
7208         LDKChannelMonitor this_arg_conv;
7209         this_arg_conv.inner = (void*)(this_arg & (~1));
7210         this_arg_conv.is_owned = false;
7211         unsigned char header_arr[80];
7212         CHECK(*((uint32_t*)header) == 80);
7213         memcpy(header_arr, (uint8_t*)(header + 4), 80);
7214         unsigned char (*header_ref)[80] = &header_arr;
7215         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)broadcaster) & ~1);
7216         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
7217         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
7218         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
7219 }
7220
7221 void  __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
7222         if ((this_ptr & 1) != 0) return;
7223         LDKPersist this_ptr_conv = *(LDKPersist*)(((uint64_t)this_ptr) & ~1);
7224         FREE((void*)this_ptr);
7225         Persist_free(this_ptr_conv);
7226 }
7227
7228 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
7229         LDKu8slice ser_ref;
7230         ser_ref.datalen = *((uint32_t*)ser);
7231         ser_ref.data = (int8_t*)(ser + 4);
7232         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
7233         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7234         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
7235         return (long)ret_conv;
7236 }
7237
7238 void  __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_ptr) {
7239         LDKOutPoint this_ptr_conv;
7240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7241         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7242         OutPoint_free(this_ptr_conv);
7243 }
7244
7245 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
7246         LDKOutPoint orig_conv;
7247         orig_conv.inner = (void*)(orig & (~1));
7248         orig_conv.is_owned = false;
7249         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
7250         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7251         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7252         long ret_ref = (long)ret_var.inner;
7253         if (ret_var.is_owned) {
7254                 ret_ref |= 1;
7255         }
7256         return ret_ref;
7257 }
7258
7259 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
7260         LDKOutPoint this_ptr_conv;
7261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7262         this_ptr_conv.is_owned = false;
7263         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7264         memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
7265         return ret_arr;
7266 }
7267
7268 void  __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
7269         LDKOutPoint this_ptr_conv;
7270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7271         this_ptr_conv.is_owned = false;
7272         LDKThirtyTwoBytes val_ref;
7273         CHECK(*((uint32_t*)val) == 32);
7274         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7275         OutPoint_set_txid(&this_ptr_conv, val_ref);
7276 }
7277
7278 int16_t  __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
7279         LDKOutPoint this_ptr_conv;
7280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7281         this_ptr_conv.is_owned = false;
7282         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
7283         return ret_val;
7284 }
7285
7286 void  __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
7287         LDKOutPoint this_ptr_conv;
7288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7289         this_ptr_conv.is_owned = false;
7290         OutPoint_set_index(&this_ptr_conv, val);
7291 }
7292
7293 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
7294         LDKThirtyTwoBytes txid_arg_ref;
7295         CHECK(*((uint32_t*)txid_arg) == 32);
7296         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
7297         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
7298         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7299         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7300         long ret_ref = (long)ret_var.inner;
7301         if (ret_var.is_owned) {
7302                 ret_ref |= 1;
7303         }
7304         return ret_ref;
7305 }
7306
7307 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
7308         LDKOutPoint this_arg_conv;
7309         this_arg_conv.inner = (void*)(this_arg & (~1));
7310         this_arg_conv.is_owned = false;
7311         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7312         memcpy((uint8_t*)(arg_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
7313         return arg_arr;
7314 }
7315
7316 int8_tArray  __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
7317         LDKOutPoint obj_conv;
7318         obj_conv.inner = (void*)(obj & (~1));
7319         obj_conv.is_owned = false;
7320         LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
7321         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7322         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7323         CVec_u8Z_free(arg_var);
7324         return arg_arr;
7325 }
7326
7327 uint32_t  __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
7328         LDKu8slice ser_ref;
7329         ser_ref.datalen = *((uint32_t*)ser);
7330         ser_ref.data = (int8_t*)(ser + 4);
7331         LDKOutPoint ret_var = OutPoint_read(ser_ref);
7332         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7333         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7334         long ret_ref = (long)ret_var.inner;
7335         if (ret_var.is_owned) {
7336                 ret_ref |= 1;
7337         }
7338         return ret_ref;
7339 }
7340
7341 void  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
7342         if ((this_ptr & 1) != 0) return;
7343         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)this_ptr) & ~1);
7344         FREE((void*)this_ptr);
7345         SpendableOutputDescriptor_free(this_ptr_conv);
7346 }
7347
7348 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
7349         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
7350         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
7351         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
7352         long ret_ref = (long)ret_copy;
7353         return ret_ref;
7354 }
7355
7356 int8_tArray  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
7357         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
7358         LDKCVec_u8Z arg_var = SpendableOutputDescriptor_write(obj_conv);
7359         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7360         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7361         CVec_u8Z_free(arg_var);
7362         return arg_arr;
7363 }
7364
7365 uint32_t  __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
7366         LDKu8slice ser_ref;
7367         ser_ref.datalen = *((uint32_t*)ser);
7368         ser_ref.data = (int8_t*)(ser + 4);
7369         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7370         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
7371         return (long)ret_conv;
7372 }
7373
7374 uint32_t  __attribute__((visibility("default"))) TS_ChannelKeys_clone(uint32_t orig) {
7375         LDKChannelKeys* orig_conv = (LDKChannelKeys*)orig;
7376         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
7377         *ret = ChannelKeys_clone(orig_conv);
7378         return (long)ret;
7379 }
7380
7381 void  __attribute__((visibility("default"))) TS_ChannelKeys_free(uint32_t this_ptr) {
7382         if ((this_ptr & 1) != 0) return;
7383         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)(((uint64_t)this_ptr) & ~1);
7384         FREE((void*)this_ptr);
7385         ChannelKeys_free(this_ptr_conv);
7386 }
7387
7388 void  __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
7389         if ((this_ptr & 1) != 0) return;
7390         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(((uint64_t)this_ptr) & ~1);
7391         FREE((void*)this_ptr);
7392         KeysInterface_free(this_ptr_conv);
7393 }
7394
7395 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_free(uint32_t this_ptr) {
7396         LDKInMemoryChannelKeys this_ptr_conv;
7397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7398         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7399         InMemoryChannelKeys_free(this_ptr_conv);
7400 }
7401
7402 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_clone(uint32_t orig) {
7403         LDKInMemoryChannelKeys orig_conv;
7404         orig_conv.inner = (void*)(orig & (~1));
7405         orig_conv.is_owned = false;
7406         LDKInMemoryChannelKeys ret_var = InMemoryChannelKeys_clone(&orig_conv);
7407         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7408         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7409         long ret_ref = (long)ret_var.inner;
7410         if (ret_var.is_owned) {
7411                 ret_ref |= 1;
7412         }
7413         return ret_ref;
7414 }
7415
7416 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_funding_key(uint32_t this_ptr) {
7417         LDKInMemoryChannelKeys this_ptr_conv;
7418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7419         this_ptr_conv.is_owned = false;
7420         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7421         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_funding_key(&this_ptr_conv), 32);
7422         return ret_arr;
7423 }
7424
7425 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_funding_key(uint32_t this_ptr, int8_tArray val) {
7426         LDKInMemoryChannelKeys this_ptr_conv;
7427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7428         this_ptr_conv.is_owned = false;
7429         LDKSecretKey val_ref;
7430         CHECK(*((uint32_t*)val) == 32);
7431         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7432         InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
7433 }
7434
7435 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_revocation_base_key(uint32_t this_ptr) {
7436         LDKInMemoryChannelKeys this_ptr_conv;
7437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7438         this_ptr_conv.is_owned = false;
7439         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7440         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv), 32);
7441         return ret_arr;
7442 }
7443
7444 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
7445         LDKInMemoryChannelKeys this_ptr_conv;
7446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7447         this_ptr_conv.is_owned = false;
7448         LDKSecretKey val_ref;
7449         CHECK(*((uint32_t*)val) == 32);
7450         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7451         InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
7452 }
7453
7454 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_payment_key(uint32_t this_ptr) {
7455         LDKInMemoryChannelKeys this_ptr_conv;
7456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7457         this_ptr_conv.is_owned = false;
7458         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7459         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_payment_key(&this_ptr_conv), 32);
7460         return ret_arr;
7461 }
7462
7463 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_payment_key(uint32_t this_ptr, int8_tArray val) {
7464         LDKInMemoryChannelKeys this_ptr_conv;
7465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7466         this_ptr_conv.is_owned = false;
7467         LDKSecretKey val_ref;
7468         CHECK(*((uint32_t*)val) == 32);
7469         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7470         InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
7471 }
7472
7473 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_delayed_payment_base_key(uint32_t this_ptr) {
7474         LDKInMemoryChannelKeys this_ptr_conv;
7475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7476         this_ptr_conv.is_owned = false;
7477         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7478         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv), 32);
7479         return ret_arr;
7480 }
7481
7482 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
7483         LDKInMemoryChannelKeys this_ptr_conv;
7484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7485         this_ptr_conv.is_owned = false;
7486         LDKSecretKey val_ref;
7487         CHECK(*((uint32_t*)val) == 32);
7488         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7489         InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
7490 }
7491
7492 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_htlc_base_key(uint32_t this_ptr) {
7493         LDKInMemoryChannelKeys this_ptr_conv;
7494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7495         this_ptr_conv.is_owned = false;
7496         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7497         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv), 32);
7498         return ret_arr;
7499 }
7500
7501 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
7502         LDKInMemoryChannelKeys this_ptr_conv;
7503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7504         this_ptr_conv.is_owned = false;
7505         LDKSecretKey val_ref;
7506         CHECK(*((uint32_t*)val) == 32);
7507         memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7508         InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
7509 }
7510
7511 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_commitment_seed(uint32_t this_ptr) {
7512         LDKInMemoryChannelKeys this_ptr_conv;
7513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7514         this_ptr_conv.is_owned = false;
7515         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7516         memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv), 32);
7517         return ret_arr;
7518 }
7519
7520 void  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
7521         LDKInMemoryChannelKeys this_ptr_conv;
7522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7523         this_ptr_conv.is_owned = false;
7524         LDKThirtyTwoBytes val_ref;
7525         CHECK(*((uint32_t*)val) == 32);
7526         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7527         InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
7528 }
7529
7530 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) {
7531         LDKSecretKey funding_key_ref;
7532         CHECK(*((uint32_t*)funding_key) == 32);
7533         memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
7534         LDKSecretKey revocation_base_key_ref;
7535         CHECK(*((uint32_t*)revocation_base_key) == 32);
7536         memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
7537         LDKSecretKey payment_key_ref;
7538         CHECK(*((uint32_t*)payment_key) == 32);
7539         memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
7540         LDKSecretKey delayed_payment_base_key_ref;
7541         CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
7542         memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
7543         LDKSecretKey htlc_base_key_ref;
7544         CHECK(*((uint32_t*)htlc_base_key) == 32);
7545         memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
7546         LDKThirtyTwoBytes commitment_seed_ref;
7547         CHECK(*((uint32_t*)commitment_seed) == 32);
7548         memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
7549         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)(((uint64_t)key_derivation_params) & ~1);
7550         FREE((void*)key_derivation_params);
7551         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);
7552         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7553         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7554         long ret_ref = (long)ret_var.inner;
7555         if (ret_var.is_owned) {
7556                 ret_ref |= 1;
7557         }
7558         return ret_ref;
7559 }
7560
7561 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_counterparty_pubkeys(uint32_t this_arg) {
7562         LDKInMemoryChannelKeys this_arg_conv;
7563         this_arg_conv.inner = (void*)(this_arg & (~1));
7564         this_arg_conv.is_owned = false;
7565         LDKChannelPublicKeys ret_var = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
7566         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7567         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7568         long ret_ref = (long)ret_var.inner;
7569         if (ret_var.is_owned) {
7570                 ret_ref |= 1;
7571         }
7572         return ret_ref;
7573 }
7574
7575 int16_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_counterparty_selected_contest_delay(uint32_t this_arg) {
7576         LDKInMemoryChannelKeys this_arg_conv;
7577         this_arg_conv.inner = (void*)(this_arg & (~1));
7578         this_arg_conv.is_owned = false;
7579         int16_t ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
7580         return ret_val;
7581 }
7582
7583 int16_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_holder_selected_contest_delay(uint32_t this_arg) {
7584         LDKInMemoryChannelKeys this_arg_conv;
7585         this_arg_conv.inner = (void*)(this_arg & (~1));
7586         this_arg_conv.is_owned = false;
7587         int16_t ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
7588         return ret_val;
7589 }
7590
7591 jboolean  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_is_outbound(uint32_t this_arg) {
7592         LDKInMemoryChannelKeys this_arg_conv;
7593         this_arg_conv.inner = (void*)(this_arg & (~1));
7594         this_arg_conv.is_owned = false;
7595         jboolean ret_val = InMemoryChannelKeys_is_outbound(&this_arg_conv);
7596         return ret_val;
7597 }
7598
7599 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_funding_outpoint(uint32_t this_arg) {
7600         LDKInMemoryChannelKeys this_arg_conv;
7601         this_arg_conv.inner = (void*)(this_arg & (~1));
7602         this_arg_conv.is_owned = false;
7603         LDKOutPoint ret_var = InMemoryChannelKeys_funding_outpoint(&this_arg_conv);
7604         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7605         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7606         long ret_ref = (long)ret_var.inner;
7607         if (ret_var.is_owned) {
7608                 ret_ref |= 1;
7609         }
7610         return ret_ref;
7611 }
7612
7613 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_channel_parameters(uint32_t this_arg) {
7614         LDKInMemoryChannelKeys this_arg_conv;
7615         this_arg_conv.inner = (void*)(this_arg & (~1));
7616         this_arg_conv.is_owned = false;
7617         LDKChannelTransactionParameters ret_var = InMemoryChannelKeys_get_channel_parameters(&this_arg_conv);
7618         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7619         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7620         long ret_ref = (long)ret_var.inner;
7621         if (ret_var.is_owned) {
7622                 ret_ref |= 1;
7623         }
7624         return ret_ref;
7625 }
7626
7627 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_as_ChannelKeys(uint32_t this_arg) {
7628         LDKInMemoryChannelKeys this_arg_conv;
7629         this_arg_conv.inner = (void*)(this_arg & (~1));
7630         this_arg_conv.is_owned = false;
7631         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
7632         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
7633         return (long)ret;
7634 }
7635
7636 int8_tArray  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_write(uint32_t obj) {
7637         LDKInMemoryChannelKeys obj_conv;
7638         obj_conv.inner = (void*)(obj & (~1));
7639         obj_conv.is_owned = false;
7640         LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
7641         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7642         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7643         CVec_u8Z_free(arg_var);
7644         return arg_arr;
7645 }
7646
7647 uint32_t  __attribute__((visibility("default"))) TS_InMemoryChannelKeys_read(int8_tArray ser) {
7648         LDKu8slice ser_ref;
7649         ser_ref.datalen = *((uint32_t*)ser);
7650         ser_ref.data = (int8_t*)(ser + 4);
7651         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
7652         *ret_conv = InMemoryChannelKeys_read(ser_ref);
7653         return (long)ret_conv;
7654 }
7655
7656 void  __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_ptr) {
7657         LDKKeysManager this_ptr_conv;
7658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7659         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7660         KeysManager_free(this_ptr_conv);
7661 }
7662
7663 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, uint32_t network, int64_t starting_time_secs, int32_t starting_time_nanos) {
7664         unsigned char seed_arr[32];
7665         CHECK(*((uint32_t*)seed) == 32);
7666         memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
7667         unsigned char (*seed_ref)[32] = &seed_arr;
7668         LDKNetwork network_conv = LDKNetwork_from_js(network);
7669         LDKKeysManager ret_var = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
7670         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7671         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7672         long ret_ref = (long)ret_var.inner;
7673         if (ret_var.is_owned) {
7674                 ret_ref |= 1;
7675         }
7676         return ret_ref;
7677 }
7678
7679 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) {
7680         LDKKeysManager this_arg_conv;
7681         this_arg_conv.inner = (void*)(this_arg & (~1));
7682         this_arg_conv.is_owned = false;
7683         LDKInMemoryChannelKeys ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
7684         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7685         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7686         long ret_ref = (long)ret_var.inner;
7687         if (ret_var.is_owned) {
7688                 ret_ref |= 1;
7689         }
7690         return ret_ref;
7691 }
7692
7693 uint32_t  __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
7694         LDKKeysManager this_arg_conv;
7695         this_arg_conv.inner = (void*)(this_arg & (~1));
7696         this_arg_conv.is_owned = false;
7697         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7698         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
7699         return (long)ret;
7700 }
7701
7702 void  __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_ptr) {
7703         LDKChannelManager this_ptr_conv;
7704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7705         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7706         ChannelManager_free(this_ptr_conv);
7707 }
7708
7709 void  __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_ptr) {
7710         LDKChannelDetails this_ptr_conv;
7711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7712         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7713         ChannelDetails_free(this_ptr_conv);
7714 }
7715
7716 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
7717         LDKChannelDetails orig_conv;
7718         orig_conv.inner = (void*)(orig & (~1));
7719         orig_conv.is_owned = false;
7720         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
7721         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7722         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7723         long ret_ref = (long)ret_var.inner;
7724         if (ret_var.is_owned) {
7725                 ret_ref |= 1;
7726         }
7727         return ret_ref;
7728 }
7729
7730 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
7731         LDKChannelDetails this_ptr_conv;
7732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7733         this_ptr_conv.is_owned = false;
7734         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7735         memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
7736         return ret_arr;
7737 }
7738
7739 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
7740         LDKChannelDetails this_ptr_conv;
7741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7742         this_ptr_conv.is_owned = false;
7743         LDKThirtyTwoBytes val_ref;
7744         CHECK(*((uint32_t*)val) == 32);
7745         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7746         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
7747 }
7748
7749 int8_tArray  __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
7750         LDKChannelDetails this_ptr_conv;
7751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7752         this_ptr_conv.is_owned = false;
7753         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7754         memcpy((uint8_t*)(arg_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
7755         return arg_arr;
7756 }
7757
7758 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
7759         LDKChannelDetails this_ptr_conv;
7760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7761         this_ptr_conv.is_owned = false;
7762         LDKPublicKey val_ref;
7763         CHECK(*((uint32_t*)val) == 33);
7764         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
7765         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
7766 }
7767
7768 uint32_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
7769         LDKChannelDetails this_ptr_conv;
7770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7771         this_ptr_conv.is_owned = false;
7772         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
7773         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7774         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7775         long ret_ref = (long)ret_var.inner;
7776         if (ret_var.is_owned) {
7777                 ret_ref |= 1;
7778         }
7779         return ret_ref;
7780 }
7781
7782 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
7783         LDKChannelDetails this_ptr_conv;
7784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7785         this_ptr_conv.is_owned = false;
7786         LDKInitFeatures val_conv;
7787         val_conv.inner = (void*)(val & (~1));
7788         val_conv.is_owned = (val & 1) || (val == 0);
7789         // Warning: we need a move here but no clone is available for LDKInitFeatures
7790         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
7791 }
7792
7793 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
7794         LDKChannelDetails this_ptr_conv;
7795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7796         this_ptr_conv.is_owned = false;
7797         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
7798         return ret_val;
7799 }
7800
7801 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
7802         LDKChannelDetails this_ptr_conv;
7803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7804         this_ptr_conv.is_owned = false;
7805         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
7806 }
7807
7808 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
7809         LDKChannelDetails this_ptr_conv;
7810         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7811         this_ptr_conv.is_owned = false;
7812         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
7813         return ret_val;
7814 }
7815
7816 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
7817         LDKChannelDetails this_ptr_conv;
7818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7819         this_ptr_conv.is_owned = false;
7820         ChannelDetails_set_user_id(&this_ptr_conv, val);
7821 }
7822
7823 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
7824         LDKChannelDetails this_ptr_conv;
7825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7826         this_ptr_conv.is_owned = false;
7827         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
7828         return ret_val;
7829 }
7830
7831 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
7832         LDKChannelDetails this_ptr_conv;
7833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7834         this_ptr_conv.is_owned = false;
7835         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
7836 }
7837
7838 int64_t  __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
7839         LDKChannelDetails this_ptr_conv;
7840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7841         this_ptr_conv.is_owned = false;
7842         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
7843         return ret_val;
7844 }
7845
7846 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
7847         LDKChannelDetails this_ptr_conv;
7848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7849         this_ptr_conv.is_owned = false;
7850         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
7851 }
7852
7853 jboolean  __attribute__((visibility("default"))) TS_ChannelDetails_get_is_live(uint32_t this_ptr) {
7854         LDKChannelDetails this_ptr_conv;
7855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7856         this_ptr_conv.is_owned = false;
7857         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
7858         return ret_val;
7859 }
7860
7861 void  __attribute__((visibility("default"))) TS_ChannelDetails_set_is_live(uint32_t this_ptr, jboolean val) {
7862         LDKChannelDetails this_ptr_conv;
7863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7864         this_ptr_conv.is_owned = false;
7865         ChannelDetails_set_is_live(&this_ptr_conv, val);
7866 }
7867
7868 void  __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
7869         LDKPaymentSendFailure this_ptr_conv;
7870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7871         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7872         PaymentSendFailure_free(this_ptr_conv);
7873 }
7874
7875 uint32_t  __attribute__((visibility("default"))) TS_PaymentSendFailure_clone(uint32_t orig) {
7876         LDKPaymentSendFailure orig_conv;
7877         orig_conv.inner = (void*)(orig & (~1));
7878         orig_conv.is_owned = false;
7879         LDKPaymentSendFailure ret_var = PaymentSendFailure_clone(&orig_conv);
7880         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7881         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7882         long ret_ref = (long)ret_var.inner;
7883         if (ret_var.is_owned) {
7884                 ret_ref |= 1;
7885         }
7886         return ret_ref;
7887 }
7888
7889 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, int64_t current_blockchain_height) {
7890         LDKNetwork network_conv = LDKNetwork_from_js(network);
7891         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(((uint64_t)fee_est) & ~1);
7892         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
7893         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
7894         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
7895         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
7896         LDKUserConfig config_conv;
7897         config_conv.inner = (void*)(config & (~1));
7898         config_conv.is_owned = (config & 1) || (config == 0);
7899         config_conv = UserConfig_clone(&config_conv);
7900         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);
7901         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7902         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7903         long ret_ref = (long)ret_var.inner;
7904         if (ret_var.is_owned) {
7905                 ret_ref |= 1;
7906         }
7907         return ret_ref;
7908 }
7909
7910 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) {
7911         LDKChannelManager this_arg_conv;
7912         this_arg_conv.inner = (void*)(this_arg & (~1));
7913         this_arg_conv.is_owned = false;
7914         LDKPublicKey their_network_key_ref;
7915         CHECK(*((uint32_t*)their_network_key) == 33);
7916         memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
7917         LDKUserConfig override_config_conv;
7918         override_config_conv.inner = (void*)(override_config & (~1));
7919         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
7920         override_config_conv = UserConfig_clone(&override_config_conv);
7921         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7922         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
7923         return (long)ret_conv;
7924 }
7925
7926 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
7927         LDKChannelManager this_arg_conv;
7928         this_arg_conv.inner = (void*)(this_arg & (~1));
7929         this_arg_conv.is_owned = false;
7930         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
7931         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7932         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7933         for (size_t q = 0; q < ret_var.datalen; q++) {
7934                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
7935                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7936                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7937                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
7938                 if (arr_conv_16_var.is_owned) {
7939                         arr_conv_16_ref |= 1;
7940                 }
7941                 ret_arr_ptr[q] = arr_conv_16_ref;
7942         }
7943         FREE(ret_var.data);
7944         return ret_arr;
7945 }
7946
7947 uint32_tArray  __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
7948         LDKChannelManager this_arg_conv;
7949         this_arg_conv.inner = (void*)(this_arg & (~1));
7950         this_arg_conv.is_owned = false;
7951         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
7952         uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7953         uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7954         for (size_t q = 0; q < ret_var.datalen; q++) {
7955                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
7956                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7957                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7958                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
7959                 if (arr_conv_16_var.is_owned) {
7960                         arr_conv_16_ref |= 1;
7961                 }
7962                 ret_arr_ptr[q] = arr_conv_16_ref;
7963         }
7964         FREE(ret_var.data);
7965         return ret_arr;
7966 }
7967
7968 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
7969         LDKChannelManager this_arg_conv;
7970         this_arg_conv.inner = (void*)(this_arg & (~1));
7971         this_arg_conv.is_owned = false;
7972         unsigned char channel_id_arr[32];
7973         CHECK(*((uint32_t*)channel_id) == 32);
7974         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
7975         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
7976         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7977         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
7978         return (long)ret_conv;
7979 }
7980
7981 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
7982         LDKChannelManager this_arg_conv;
7983         this_arg_conv.inner = (void*)(this_arg & (~1));
7984         this_arg_conv.is_owned = false;
7985         unsigned char channel_id_arr[32];
7986         CHECK(*((uint32_t*)channel_id) == 32);
7987         memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
7988         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
7989         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7990         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
7991         return (long)ret_conv;
7992 }
7993
7994 void  __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
7995         LDKChannelManager this_arg_conv;
7996         this_arg_conv.inner = (void*)(this_arg & (~1));
7997         this_arg_conv.is_owned = false;
7998         ChannelManager_force_close_all_channels(&this_arg_conv);
7999 }
8000
8001 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
8002         LDKChannelManager this_arg_conv;
8003         this_arg_conv.inner = (void*)(this_arg & (~1));
8004         this_arg_conv.is_owned = false;
8005         LDKRoute route_conv;
8006         route_conv.inner = (void*)(route & (~1));
8007         route_conv.is_owned = false;
8008         LDKThirtyTwoBytes payment_hash_ref;
8009         CHECK(*((uint32_t*)payment_hash) == 32);
8010         memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
8011         LDKThirtyTwoBytes payment_secret_ref;
8012         CHECK(*((uint32_t*)payment_secret) == 32);
8013         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8014         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8015         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
8016         return (long)ret_conv;
8017 }
8018
8019 void  __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, uint32_t funding_txo) {
8020         LDKChannelManager this_arg_conv;
8021         this_arg_conv.inner = (void*)(this_arg & (~1));
8022         this_arg_conv.is_owned = false;
8023         unsigned char temporary_channel_id_arr[32];
8024         CHECK(*((uint32_t*)temporary_channel_id) == 32);
8025         memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
8026         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
8027         LDKOutPoint funding_txo_conv;
8028         funding_txo_conv.inner = (void*)(funding_txo & (~1));
8029         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
8030         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
8031         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
8032 }
8033
8034 void  __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
8035         LDKChannelManager this_arg_conv;
8036         this_arg_conv.inner = (void*)(this_arg & (~1));
8037         this_arg_conv.is_owned = false;
8038         LDKThreeBytes rgb_ref;
8039         CHECK(*((uint32_t*)rgb) == 3);
8040         memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
8041         LDKThirtyTwoBytes alias_ref;
8042         CHECK(*((uint32_t*)alias) == 32);
8043         memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
8044         LDKCVec_NetAddressZ addresses_constr;
8045         addresses_constr.datalen = *((uint32_t*)addresses);
8046         if (addresses_constr.datalen > 0)
8047                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8048         else
8049                 addresses_constr.data = NULL;
8050         uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
8051         for (size_t m = 0; m < addresses_constr.datalen; m++) {
8052                 uint32_t arr_conv_12 = addresses_vals[m];
8053                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
8054                 FREE((void*)arr_conv_12);
8055                 addresses_constr.data[m] = arr_conv_12_conv;
8056         }
8057         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
8058 }
8059
8060 void  __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
8061         LDKChannelManager this_arg_conv;
8062         this_arg_conv.inner = (void*)(this_arg & (~1));
8063         this_arg_conv.is_owned = false;
8064         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
8065 }
8066
8067 void  __attribute__((visibility("default"))) TS_ChannelManager_timer_chan_freshness_every_min(uint32_t this_arg) {
8068         LDKChannelManager this_arg_conv;
8069         this_arg_conv.inner = (void*)(this_arg & (~1));
8070         this_arg_conv.is_owned = false;
8071         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
8072 }
8073
8074 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
8075         LDKChannelManager this_arg_conv;
8076         this_arg_conv.inner = (void*)(this_arg & (~1));
8077         this_arg_conv.is_owned = false;
8078         unsigned char payment_hash_arr[32];
8079         CHECK(*((uint32_t*)payment_hash) == 32);
8080         memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
8081         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
8082         LDKThirtyTwoBytes payment_secret_ref;
8083         CHECK(*((uint32_t*)payment_secret) == 32);
8084         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8085         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
8086         return ret_val;
8087 }
8088
8089 jboolean  __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
8090         LDKChannelManager this_arg_conv;
8091         this_arg_conv.inner = (void*)(this_arg & (~1));
8092         this_arg_conv.is_owned = false;
8093         LDKThirtyTwoBytes payment_preimage_ref;
8094         CHECK(*((uint32_t*)payment_preimage) == 32);
8095         memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
8096         LDKThirtyTwoBytes payment_secret_ref;
8097         CHECK(*((uint32_t*)payment_secret) == 32);
8098         memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8099         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
8100         return ret_val;
8101 }
8102
8103 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
8104         LDKChannelManager this_arg_conv;
8105         this_arg_conv.inner = (void*)(this_arg & (~1));
8106         this_arg_conv.is_owned = false;
8107         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8108         memcpy((uint8_t*)(arg_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
8109         return arg_arr;
8110 }
8111
8112 void  __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
8113         LDKChannelManager this_arg_conv;
8114         this_arg_conv.inner = (void*)(this_arg & (~1));
8115         this_arg_conv.is_owned = false;
8116         LDKOutPoint funding_txo_conv;
8117         funding_txo_conv.inner = (void*)(funding_txo & (~1));
8118         funding_txo_conv.is_owned = false;
8119         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
8120 }
8121
8122 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
8123         LDKChannelManager this_arg_conv;
8124         this_arg_conv.inner = (void*)(this_arg & (~1));
8125         this_arg_conv.is_owned = false;
8126         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8127         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
8128         return (long)ret;
8129 }
8130
8131 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
8132         LDKChannelManager this_arg_conv;
8133         this_arg_conv.inner = (void*)(this_arg & (~1));
8134         this_arg_conv.is_owned = false;
8135         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8136         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
8137         return (long)ret;
8138 }
8139
8140 void  __attribute__((visibility("default"))) TS_ChannelManager_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
8141         LDKChannelManager this_arg_conv;
8142         this_arg_conv.inner = (void*)(this_arg & (~1));
8143         this_arg_conv.is_owned = false;
8144         unsigned char header_arr[80];
8145         CHECK(*((uint32_t*)header) == 80);
8146         memcpy(header_arr, (uint8_t*)(header + 4), 80);
8147         unsigned char (*header_ref)[80] = &header_arr;
8148         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8149         txdata_constr.datalen = *((uint32_t*)txdata);
8150         if (txdata_constr.datalen > 0)
8151                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8152         else
8153                 txdata_constr.data = NULL;
8154         uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
8155         for (size_t e = 0; e < txdata_constr.datalen; e++) {
8156                 uint32_t arr_conv_30 = txdata_vals[e];
8157                 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_conv_30) & ~1);
8158                 FREE((void*)arr_conv_30);
8159                 txdata_constr.data[e] = arr_conv_30_conv;
8160         }
8161         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
8162 }
8163
8164 void  __attribute__((visibility("default"))) TS_ChannelManager_block_disconnected(uint32_t this_arg, int8_tArray header) {
8165         LDKChannelManager this_arg_conv;
8166         this_arg_conv.inner = (void*)(this_arg & (~1));
8167         this_arg_conv.is_owned = false;
8168         unsigned char header_arr[80];
8169         CHECK(*((uint32_t*)header) == 80);
8170         memcpy(header_arr, (uint8_t*)(header + 4), 80);
8171         unsigned char (*header_ref)[80] = &header_arr;
8172         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
8173 }
8174
8175 uint32_t  __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
8176         LDKChannelManager this_arg_conv;
8177         this_arg_conv.inner = (void*)(this_arg & (~1));
8178         this_arg_conv.is_owned = false;
8179         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8180         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
8181         return (long)ret;
8182 }
8183
8184 int8_tArray  __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
8185         LDKChannelManager obj_conv;
8186         obj_conv.inner = (void*)(obj & (~1));
8187         obj_conv.is_owned = false;
8188         LDKCVec_u8Z arg_var = ChannelManager_write(&obj_conv);
8189         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
8190         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
8191         CVec_u8Z_free(arg_var);
8192         return arg_arr;
8193 }
8194
8195 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_ptr) {
8196         LDKChannelManagerReadArgs this_ptr_conv;
8197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8198         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8199         ChannelManagerReadArgs_free(this_ptr_conv);
8200 }
8201
8202 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
8203         LDKChannelManagerReadArgs this_ptr_conv;
8204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8205         this_ptr_conv.is_owned = false;
8206         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
8207         return ret_ret;
8208 }
8209
8210 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
8211         LDKChannelManagerReadArgs this_ptr_conv;
8212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8213         this_ptr_conv.is_owned = false;
8214         LDKKeysInterface val_conv = *(LDKKeysInterface*)(((uint64_t)val) & ~1);
8215         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
8216 }
8217
8218 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
8219         LDKChannelManagerReadArgs this_ptr_conv;
8220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8221         this_ptr_conv.is_owned = false;
8222         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
8223         return ret_ret;
8224 }
8225
8226 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
8227         LDKChannelManagerReadArgs this_ptr_conv;
8228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8229         this_ptr_conv.is_owned = false;
8230         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(((uint64_t)val) & ~1);
8231         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
8232 }
8233
8234 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
8235         LDKChannelManagerReadArgs this_ptr_conv;
8236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8237         this_ptr_conv.is_owned = false;
8238         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
8239         return ret_ret;
8240 }
8241
8242 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
8243         LDKChannelManagerReadArgs this_ptr_conv;
8244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8245         this_ptr_conv.is_owned = false;
8246         LDKWatch val_conv = *(LDKWatch*)(((uint64_t)val) & ~1);
8247         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
8248 }
8249
8250 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
8251         LDKChannelManagerReadArgs this_ptr_conv;
8252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8253         this_ptr_conv.is_owned = false;
8254         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
8255         return ret_ret;
8256 }
8257
8258 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
8259         LDKChannelManagerReadArgs this_ptr_conv;
8260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8261         this_ptr_conv.is_owned = false;
8262         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(((uint64_t)val) & ~1);
8263         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
8264 }
8265
8266 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
8267         LDKChannelManagerReadArgs this_ptr_conv;
8268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8269         this_ptr_conv.is_owned = false;
8270         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
8271         return ret_ret;
8272 }
8273
8274 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
8275         LDKChannelManagerReadArgs this_ptr_conv;
8276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8277         this_ptr_conv.is_owned = false;
8278         LDKLogger val_conv = *(LDKLogger*)(((uint64_t)val) & ~1);
8279         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
8280 }
8281
8282 uint32_t  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
8283         LDKChannelManagerReadArgs this_ptr_conv;
8284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8285         this_ptr_conv.is_owned = false;
8286         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
8287         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8288         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8289         long ret_ref = (long)ret_var.inner;
8290         if (ret_var.is_owned) {
8291                 ret_ref |= 1;
8292         }
8293         return ret_ref;
8294 }
8295
8296 void  __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
8297         LDKChannelManagerReadArgs this_ptr_conv;
8298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8299         this_ptr_conv.is_owned = false;
8300         LDKUserConfig val_conv;
8301         val_conv.inner = (void*)(val & (~1));
8302         val_conv.is_owned = (val & 1) || (val == 0);
8303         val_conv = UserConfig_clone(&val_conv);
8304         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
8305 }
8306
8307 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) {
8308         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(((uint64_t)keys_manager) & ~1);
8309         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(((uint64_t)fee_estimator) & ~1);
8310         LDKWatch chain_monitor_conv = *(LDKWatch*)(((uint64_t)chain_monitor) & ~1);
8311         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(((uint64_t)tx_broadcaster) & ~1);
8312         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
8313         LDKUserConfig default_config_conv;
8314         default_config_conv.inner = (void*)(default_config & (~1));
8315         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
8316         default_config_conv = UserConfig_clone(&default_config_conv);
8317         LDKCVec_ChannelMonitorZ channel_monitors_constr;
8318         channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
8319         if (channel_monitors_constr.datalen > 0)
8320                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8321         else
8322                 channel_monitors_constr.data = NULL;
8323         uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
8324         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
8325                 uint32_t arr_conv_16 = channel_monitors_vals[q];
8326                 LDKChannelMonitor arr_conv_16_conv;
8327                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
8328                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
8329                 channel_monitors_constr.data[q] = arr_conv_16_conv;
8330         }
8331         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);
8332         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8333         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8334         long ret_ref = (long)ret_var.inner;
8335         if (ret_var.is_owned) {
8336                 ret_ref |= 1;
8337         }
8338         return ret_ref;
8339 }
8340
8341 uint32_t  __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
8342         LDKu8slice ser_ref;
8343         ser_ref.datalen = *((uint32_t*)ser);
8344         ser_ref.data = (int8_t*)(ser + 4);
8345         LDKChannelManagerReadArgs arg_conv;
8346         arg_conv.inner = (void*)(arg & (~1));
8347         arg_conv.is_owned = (arg & 1) || (arg == 0);
8348         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
8349         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8350         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
8351         return (long)ret_conv;
8352 }
8353
8354 void  __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_ptr) {
8355         LDKDecodeError this_ptr_conv;
8356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8357         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8358         DecodeError_free(this_ptr_conv);
8359 }
8360
8361 uint32_t  __attribute__((visibility("default"))) TS_DecodeError_clone(uint32_t orig) {
8362         LDKDecodeError orig_conv;
8363         orig_conv.inner = (void*)(orig & (~1));
8364         orig_conv.is_owned = false;
8365         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
8366         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8367         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8368         long ret_ref = (long)ret_var.inner;
8369         if (ret_var.is_owned) {
8370                 ret_ref |= 1;
8371         }
8372         return ret_ref;
8373 }
8374
8375 void  __attribute__((visibility("default"))) TS_Init_free(uint32_t this_ptr) {
8376         LDKInit this_ptr_conv;
8377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8378         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8379         Init_free(this_ptr_conv);
8380 }
8381
8382 uint32_t  __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
8383         LDKInit orig_conv;
8384         orig_conv.inner = (void*)(orig & (~1));
8385         orig_conv.is_owned = false;
8386         LDKInit ret_var = Init_clone(&orig_conv);
8387         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8388         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8389         long ret_ref = (long)ret_var.inner;
8390         if (ret_var.is_owned) {
8391                 ret_ref |= 1;
8392         }
8393         return ret_ref;
8394 }
8395
8396 void  __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_ptr) {
8397         LDKErrorMessage this_ptr_conv;
8398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8399         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8400         ErrorMessage_free(this_ptr_conv);
8401 }
8402
8403 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
8404         LDKErrorMessage orig_conv;
8405         orig_conv.inner = (void*)(orig & (~1));
8406         orig_conv.is_owned = false;
8407         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
8408         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8409         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8410         long ret_ref = (long)ret_var.inner;
8411         if (ret_var.is_owned) {
8412                 ret_ref |= 1;
8413         }
8414         return ret_ref;
8415 }
8416
8417 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
8418         LDKErrorMessage this_ptr_conv;
8419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8420         this_ptr_conv.is_owned = false;
8421         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8422         memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
8423         return ret_arr;
8424 }
8425
8426 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
8427         LDKErrorMessage this_ptr_conv;
8428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8429         this_ptr_conv.is_owned = false;
8430         LDKThirtyTwoBytes val_ref;
8431         CHECK(*((uint32_t*)val) == 32);
8432         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8433         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
8434 }
8435
8436 jstring  __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
8437         LDKErrorMessage this_ptr_conv;
8438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8439         this_ptr_conv.is_owned = false;
8440         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
8441         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
8442         return _conv;
8443 }
8444
8445 void  __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, int8_tArray val) {
8446         LDKErrorMessage this_ptr_conv;
8447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8448         this_ptr_conv.is_owned = false;
8449         LDKCVec_u8Z val_ref;
8450         val_ref.datalen = *((uint32_t*)val);
8451         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
8452         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
8453         ErrorMessage_set_data(&this_ptr_conv, val_ref);
8454 }
8455
8456 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
8457         LDKThirtyTwoBytes channel_id_arg_ref;
8458         CHECK(*((uint32_t*)channel_id_arg) == 32);
8459         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
8460         LDKCVec_u8Z data_arg_ref;
8461         data_arg_ref.datalen = *((uint32_t*)data_arg);
8462         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
8463         memcpy(data_arg_ref.data, (uint8_t*)(data_arg + 4), data_arg_ref.datalen);
8464         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
8465         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8466         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8467         long ret_ref = (long)ret_var.inner;
8468         if (ret_var.is_owned) {
8469                 ret_ref |= 1;
8470         }
8471         return ret_ref;
8472 }
8473
8474 void  __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_ptr) {
8475         LDKPing this_ptr_conv;
8476         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8477         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8478         Ping_free(this_ptr_conv);
8479 }
8480
8481 uint32_t  __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
8482         LDKPing orig_conv;
8483         orig_conv.inner = (void*)(orig & (~1));
8484         orig_conv.is_owned = false;
8485         LDKPing ret_var = Ping_clone(&orig_conv);
8486         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8487         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8488         long ret_ref = (long)ret_var.inner;
8489         if (ret_var.is_owned) {
8490                 ret_ref |= 1;
8491         }
8492         return ret_ref;
8493 }
8494
8495 int16_t  __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
8496         LDKPing this_ptr_conv;
8497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8498         this_ptr_conv.is_owned = false;
8499         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
8500         return ret_val;
8501 }
8502
8503 void  __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
8504         LDKPing this_ptr_conv;
8505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8506         this_ptr_conv.is_owned = false;
8507         Ping_set_ponglen(&this_ptr_conv, val);
8508 }
8509
8510 int16_t  __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
8511         LDKPing this_ptr_conv;
8512         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8513         this_ptr_conv.is_owned = false;
8514         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
8515         return ret_val;
8516 }
8517
8518 void  __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
8519         LDKPing this_ptr_conv;
8520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8521         this_ptr_conv.is_owned = false;
8522         Ping_set_byteslen(&this_ptr_conv, val);
8523 }
8524
8525 uint32_t  __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
8526         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
8527         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8528         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8529         long ret_ref = (long)ret_var.inner;
8530         if (ret_var.is_owned) {
8531                 ret_ref |= 1;
8532         }
8533         return ret_ref;
8534 }
8535
8536 void  __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_ptr) {
8537         LDKPong this_ptr_conv;
8538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8539         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8540         Pong_free(this_ptr_conv);
8541 }
8542
8543 uint32_t  __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
8544         LDKPong orig_conv;
8545         orig_conv.inner = (void*)(orig & (~1));
8546         orig_conv.is_owned = false;
8547         LDKPong ret_var = Pong_clone(&orig_conv);
8548         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8549         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8550         long ret_ref = (long)ret_var.inner;
8551         if (ret_var.is_owned) {
8552                 ret_ref |= 1;
8553         }
8554         return ret_ref;
8555 }
8556
8557 int16_t  __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
8558         LDKPong this_ptr_conv;
8559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8560         this_ptr_conv.is_owned = false;
8561         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
8562         return ret_val;
8563 }
8564
8565 void  __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
8566         LDKPong this_ptr_conv;
8567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8568         this_ptr_conv.is_owned = false;
8569         Pong_set_byteslen(&this_ptr_conv, val);
8570 }
8571
8572 uint32_t  __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
8573         LDKPong ret_var = Pong_new(byteslen_arg);
8574         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8575         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8576         long ret_ref = (long)ret_var.inner;
8577         if (ret_var.is_owned) {
8578                 ret_ref |= 1;
8579         }
8580         return ret_ref;
8581 }
8582
8583 void  __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_ptr) {
8584         LDKOpenChannel this_ptr_conv;
8585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8586         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8587         OpenChannel_free(this_ptr_conv);
8588 }
8589
8590 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
8591         LDKOpenChannel orig_conv;
8592         orig_conv.inner = (void*)(orig & (~1));
8593         orig_conv.is_owned = false;
8594         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
8595         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8596         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8597         long ret_ref = (long)ret_var.inner;
8598         if (ret_var.is_owned) {
8599                 ret_ref |= 1;
8600         }
8601         return ret_ref;
8602 }
8603
8604 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
8605         LDKOpenChannel this_ptr_conv;
8606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8607         this_ptr_conv.is_owned = false;
8608         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8609         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
8610         return ret_arr;
8611 }
8612
8613 void  __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
8614         LDKOpenChannel this_ptr_conv;
8615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8616         this_ptr_conv.is_owned = false;
8617         LDKThirtyTwoBytes val_ref;
8618         CHECK(*((uint32_t*)val) == 32);
8619         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8620         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
8621 }
8622
8623 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
8624         LDKOpenChannel this_ptr_conv;
8625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8626         this_ptr_conv.is_owned = false;
8627         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8628         memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
8629         return ret_arr;
8630 }
8631
8632 void  __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
8633         LDKOpenChannel this_ptr_conv;
8634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8635         this_ptr_conv.is_owned = false;
8636         LDKThirtyTwoBytes val_ref;
8637         CHECK(*((uint32_t*)val) == 32);
8638         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8639         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
8640 }
8641
8642 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
8643         LDKOpenChannel this_ptr_conv;
8644         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8645         this_ptr_conv.is_owned = false;
8646         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
8647         return ret_val;
8648 }
8649
8650 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
8651         LDKOpenChannel this_ptr_conv;
8652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8653         this_ptr_conv.is_owned = false;
8654         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
8655 }
8656
8657 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
8658         LDKOpenChannel this_ptr_conv;
8659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8660         this_ptr_conv.is_owned = false;
8661         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
8662         return ret_val;
8663 }
8664
8665 void  __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
8666         LDKOpenChannel this_ptr_conv;
8667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8668         this_ptr_conv.is_owned = false;
8669         OpenChannel_set_push_msat(&this_ptr_conv, val);
8670 }
8671
8672 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
8673         LDKOpenChannel this_ptr_conv;
8674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8675         this_ptr_conv.is_owned = false;
8676         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
8677         return ret_val;
8678 }
8679
8680 void  __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8681         LDKOpenChannel this_ptr_conv;
8682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8683         this_ptr_conv.is_owned = false;
8684         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
8685 }
8686
8687 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
8688         LDKOpenChannel this_ptr_conv;
8689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8690         this_ptr_conv.is_owned = false;
8691         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
8692         return ret_val;
8693 }
8694
8695 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
8696         LDKOpenChannel this_ptr_conv;
8697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8698         this_ptr_conv.is_owned = false;
8699         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
8700 }
8701
8702 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
8703         LDKOpenChannel this_ptr_conv;
8704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8705         this_ptr_conv.is_owned = false;
8706         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
8707         return ret_val;
8708 }
8709
8710 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
8711         LDKOpenChannel this_ptr_conv;
8712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8713         this_ptr_conv.is_owned = false;
8714         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
8715 }
8716
8717 int64_t  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
8718         LDKOpenChannel this_ptr_conv;
8719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8720         this_ptr_conv.is_owned = false;
8721         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
8722         return ret_val;
8723 }
8724
8725 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
8726         LDKOpenChannel this_ptr_conv;
8727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8728         this_ptr_conv.is_owned = false;
8729         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
8730 }
8731
8732 int32_t  __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
8733         LDKOpenChannel this_ptr_conv;
8734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8735         this_ptr_conv.is_owned = false;
8736         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
8737         return ret_val;
8738 }
8739
8740 void  __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
8741         LDKOpenChannel this_ptr_conv;
8742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8743         this_ptr_conv.is_owned = false;
8744         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
8745 }
8746
8747 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
8748         LDKOpenChannel this_ptr_conv;
8749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8750         this_ptr_conv.is_owned = false;
8751         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
8752         return ret_val;
8753 }
8754
8755 void  __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
8756         LDKOpenChannel this_ptr_conv;
8757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8758         this_ptr_conv.is_owned = false;
8759         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
8760 }
8761
8762 int16_t  __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
8763         LDKOpenChannel this_ptr_conv;
8764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8765         this_ptr_conv.is_owned = false;
8766         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
8767         return ret_val;
8768 }
8769
8770 void  __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
8771         LDKOpenChannel this_ptr_conv;
8772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8773         this_ptr_conv.is_owned = false;
8774         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
8775 }
8776
8777 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
8778         LDKOpenChannel this_ptr_conv;
8779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8780         this_ptr_conv.is_owned = false;
8781         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8782         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
8783         return arg_arr;
8784 }
8785
8786 void  __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
8787         LDKOpenChannel this_ptr_conv;
8788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8789         this_ptr_conv.is_owned = false;
8790         LDKPublicKey val_ref;
8791         CHECK(*((uint32_t*)val) == 33);
8792         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8793         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
8794 }
8795
8796 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
8797         LDKOpenChannel this_ptr_conv;
8798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8799         this_ptr_conv.is_owned = false;
8800         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8801         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
8802         return arg_arr;
8803 }
8804
8805 void  __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
8806         LDKOpenChannel this_ptr_conv;
8807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8808         this_ptr_conv.is_owned = false;
8809         LDKPublicKey val_ref;
8810         CHECK(*((uint32_t*)val) == 33);
8811         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8812         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
8813 }
8814
8815 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
8816         LDKOpenChannel this_ptr_conv;
8817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8818         this_ptr_conv.is_owned = false;
8819         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8820         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
8821         return arg_arr;
8822 }
8823
8824 void  __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
8825         LDKOpenChannel this_ptr_conv;
8826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8827         this_ptr_conv.is_owned = false;
8828         LDKPublicKey val_ref;
8829         CHECK(*((uint32_t*)val) == 33);
8830         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8831         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
8832 }
8833
8834 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
8835         LDKOpenChannel this_ptr_conv;
8836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8837         this_ptr_conv.is_owned = false;
8838         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8839         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
8840         return arg_arr;
8841 }
8842
8843 void  __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
8844         LDKOpenChannel this_ptr_conv;
8845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8846         this_ptr_conv.is_owned = false;
8847         LDKPublicKey val_ref;
8848         CHECK(*((uint32_t*)val) == 33);
8849         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8850         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
8851 }
8852
8853 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
8854         LDKOpenChannel this_ptr_conv;
8855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8856         this_ptr_conv.is_owned = false;
8857         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8858         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
8859         return arg_arr;
8860 }
8861
8862 void  __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
8863         LDKOpenChannel this_ptr_conv;
8864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8865         this_ptr_conv.is_owned = false;
8866         LDKPublicKey val_ref;
8867         CHECK(*((uint32_t*)val) == 33);
8868         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8869         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
8870 }
8871
8872 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
8873         LDKOpenChannel this_ptr_conv;
8874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8875         this_ptr_conv.is_owned = false;
8876         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8877         memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
8878         return arg_arr;
8879 }
8880
8881 void  __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
8882         LDKOpenChannel this_ptr_conv;
8883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8884         this_ptr_conv.is_owned = false;
8885         LDKPublicKey val_ref;
8886         CHECK(*((uint32_t*)val) == 33);
8887         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8888         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
8889 }
8890
8891 int8_t  __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
8892         LDKOpenChannel this_ptr_conv;
8893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8894         this_ptr_conv.is_owned = false;
8895         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
8896         return ret_val;
8897 }
8898
8899 void  __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
8900         LDKOpenChannel this_ptr_conv;
8901         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8902         this_ptr_conv.is_owned = false;
8903         OpenChannel_set_channel_flags(&this_ptr_conv, val);
8904 }
8905
8906 void  __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_ptr) {
8907         LDKAcceptChannel this_ptr_conv;
8908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8909         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8910         AcceptChannel_free(this_ptr_conv);
8911 }
8912
8913 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
8914         LDKAcceptChannel orig_conv;
8915         orig_conv.inner = (void*)(orig & (~1));
8916         orig_conv.is_owned = false;
8917         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
8918         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8919         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8920         long ret_ref = (long)ret_var.inner;
8921         if (ret_var.is_owned) {
8922                 ret_ref |= 1;
8923         }
8924         return ret_ref;
8925 }
8926
8927 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
8928         LDKAcceptChannel this_ptr_conv;
8929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8930         this_ptr_conv.is_owned = false;
8931         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8932         memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
8933         return ret_arr;
8934 }
8935
8936 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
8937         LDKAcceptChannel this_ptr_conv;
8938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8939         this_ptr_conv.is_owned = false;
8940         LDKThirtyTwoBytes val_ref;
8941         CHECK(*((uint32_t*)val) == 32);
8942         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8943         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
8944 }
8945
8946 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
8947         LDKAcceptChannel this_ptr_conv;
8948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8949         this_ptr_conv.is_owned = false;
8950         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
8951         return ret_val;
8952 }
8953
8954 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8955         LDKAcceptChannel this_ptr_conv;
8956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8957         this_ptr_conv.is_owned = false;
8958         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
8959 }
8960
8961 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
8962         LDKAcceptChannel this_ptr_conv;
8963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8964         this_ptr_conv.is_owned = false;
8965         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
8966         return ret_val;
8967 }
8968
8969 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
8970         LDKAcceptChannel this_ptr_conv;
8971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8972         this_ptr_conv.is_owned = false;
8973         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
8974 }
8975
8976 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
8977         LDKAcceptChannel this_ptr_conv;
8978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8979         this_ptr_conv.is_owned = false;
8980         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
8981         return ret_val;
8982 }
8983
8984 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
8985         LDKAcceptChannel this_ptr_conv;
8986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8987         this_ptr_conv.is_owned = false;
8988         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
8989 }
8990
8991 int64_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
8992         LDKAcceptChannel this_ptr_conv;
8993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8994         this_ptr_conv.is_owned = false;
8995         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
8996         return ret_val;
8997 }
8998
8999 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
9000         LDKAcceptChannel this_ptr_conv;
9001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9002         this_ptr_conv.is_owned = false;
9003         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
9004 }
9005
9006 int32_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
9007         LDKAcceptChannel this_ptr_conv;
9008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9009         this_ptr_conv.is_owned = false;
9010         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
9011         return ret_val;
9012 }
9013
9014 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
9015         LDKAcceptChannel this_ptr_conv;
9016         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9017         this_ptr_conv.is_owned = false;
9018         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
9019 }
9020
9021 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
9022         LDKAcceptChannel this_ptr_conv;
9023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9024         this_ptr_conv.is_owned = false;
9025         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
9026         return ret_val;
9027 }
9028
9029 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
9030         LDKAcceptChannel this_ptr_conv;
9031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9032         this_ptr_conv.is_owned = false;
9033         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
9034 }
9035
9036 int16_t  __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
9037         LDKAcceptChannel this_ptr_conv;
9038         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9039         this_ptr_conv.is_owned = false;
9040         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
9041         return ret_val;
9042 }
9043
9044 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
9045         LDKAcceptChannel this_ptr_conv;
9046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9047         this_ptr_conv.is_owned = false;
9048         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
9049 }
9050
9051 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
9052         LDKAcceptChannel this_ptr_conv;
9053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9054         this_ptr_conv.is_owned = false;
9055         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9056         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
9057         return arg_arr;
9058 }
9059
9060 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
9061         LDKAcceptChannel this_ptr_conv;
9062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9063         this_ptr_conv.is_owned = false;
9064         LDKPublicKey val_ref;
9065         CHECK(*((uint32_t*)val) == 33);
9066         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9067         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
9068 }
9069
9070 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
9071         LDKAcceptChannel this_ptr_conv;
9072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9073         this_ptr_conv.is_owned = false;
9074         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9075         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
9076         return arg_arr;
9077 }
9078
9079 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
9080         LDKAcceptChannel this_ptr_conv;
9081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9082         this_ptr_conv.is_owned = false;
9083         LDKPublicKey val_ref;
9084         CHECK(*((uint32_t*)val) == 33);
9085         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9086         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
9087 }
9088
9089 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
9090         LDKAcceptChannel this_ptr_conv;
9091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9092         this_ptr_conv.is_owned = false;
9093         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9094         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
9095         return arg_arr;
9096 }
9097
9098 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
9099         LDKAcceptChannel this_ptr_conv;
9100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9101         this_ptr_conv.is_owned = false;
9102         LDKPublicKey val_ref;
9103         CHECK(*((uint32_t*)val) == 33);
9104         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9105         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
9106 }
9107
9108 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
9109         LDKAcceptChannel this_ptr_conv;
9110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9111         this_ptr_conv.is_owned = false;
9112         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9113         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
9114         return arg_arr;
9115 }
9116
9117 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
9118         LDKAcceptChannel this_ptr_conv;
9119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9120         this_ptr_conv.is_owned = false;
9121         LDKPublicKey val_ref;
9122         CHECK(*((uint32_t*)val) == 33);
9123         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9124         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
9125 }
9126
9127 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
9128         LDKAcceptChannel this_ptr_conv;
9129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9130         this_ptr_conv.is_owned = false;
9131         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9132         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
9133         return arg_arr;
9134 }
9135
9136 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
9137         LDKAcceptChannel this_ptr_conv;
9138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9139         this_ptr_conv.is_owned = false;
9140         LDKPublicKey val_ref;
9141         CHECK(*((uint32_t*)val) == 33);
9142         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9143         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
9144 }
9145
9146 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
9147         LDKAcceptChannel this_ptr_conv;
9148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9149         this_ptr_conv.is_owned = false;
9150         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9151         memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9152         return arg_arr;
9153 }
9154
9155 void  __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
9156         LDKAcceptChannel this_ptr_conv;
9157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9158         this_ptr_conv.is_owned = false;
9159         LDKPublicKey val_ref;
9160         CHECK(*((uint32_t*)val) == 33);
9161         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9162         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
9163 }
9164
9165 void  __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_ptr) {
9166         LDKFundingCreated this_ptr_conv;
9167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9168         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9169         FundingCreated_free(this_ptr_conv);
9170 }
9171
9172 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
9173         LDKFundingCreated orig_conv;
9174         orig_conv.inner = (void*)(orig & (~1));
9175         orig_conv.is_owned = false;
9176         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
9177         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9178         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9179         long ret_ref = (long)ret_var.inner;
9180         if (ret_var.is_owned) {
9181                 ret_ref |= 1;
9182         }
9183         return ret_ref;
9184 }
9185
9186 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
9187         LDKFundingCreated this_ptr_conv;
9188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9189         this_ptr_conv.is_owned = false;
9190         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9191         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
9192         return ret_arr;
9193 }
9194
9195 void  __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
9196         LDKFundingCreated this_ptr_conv;
9197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9198         this_ptr_conv.is_owned = false;
9199         LDKThirtyTwoBytes val_ref;
9200         CHECK(*((uint32_t*)val) == 32);
9201         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9202         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
9203 }
9204
9205 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
9206         LDKFundingCreated this_ptr_conv;
9207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9208         this_ptr_conv.is_owned = false;
9209         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9210         memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
9211         return ret_arr;
9212 }
9213
9214 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
9215         LDKFundingCreated this_ptr_conv;
9216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9217         this_ptr_conv.is_owned = false;
9218         LDKThirtyTwoBytes val_ref;
9219         CHECK(*((uint32_t*)val) == 32);
9220         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9221         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
9222 }
9223
9224 int16_t  __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
9225         LDKFundingCreated this_ptr_conv;
9226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9227         this_ptr_conv.is_owned = false;
9228         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
9229         return ret_val;
9230 }
9231
9232 void  __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
9233         LDKFundingCreated this_ptr_conv;
9234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9235         this_ptr_conv.is_owned = false;
9236         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
9237 }
9238
9239 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
9240         LDKFundingCreated this_ptr_conv;
9241         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9242         this_ptr_conv.is_owned = false;
9243         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9244         memcpy((uint8_t*)(arg_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
9245         return arg_arr;
9246 }
9247
9248 void  __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
9249         LDKFundingCreated this_ptr_conv;
9250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9251         this_ptr_conv.is_owned = false;
9252         LDKSignature val_ref;
9253         CHECK(*((uint32_t*)val) == 64);
9254         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9255         FundingCreated_set_signature(&this_ptr_conv, val_ref);
9256 }
9257
9258 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) {
9259         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
9260         CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
9261         memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
9262         LDKThirtyTwoBytes funding_txid_arg_ref;
9263         CHECK(*((uint32_t*)funding_txid_arg) == 32);
9264         memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
9265         LDKSignature signature_arg_ref;
9266         CHECK(*((uint32_t*)signature_arg) == 64);
9267         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9268         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
9269         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9270         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9271         long ret_ref = (long)ret_var.inner;
9272         if (ret_var.is_owned) {
9273                 ret_ref |= 1;
9274         }
9275         return ret_ref;
9276 }
9277
9278 void  __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_ptr) {
9279         LDKFundingSigned this_ptr_conv;
9280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9281         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9282         FundingSigned_free(this_ptr_conv);
9283 }
9284
9285 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
9286         LDKFundingSigned orig_conv;
9287         orig_conv.inner = (void*)(orig & (~1));
9288         orig_conv.is_owned = false;
9289         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
9290         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9291         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9292         long ret_ref = (long)ret_var.inner;
9293         if (ret_var.is_owned) {
9294                 ret_ref |= 1;
9295         }
9296         return ret_ref;
9297 }
9298
9299 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
9300         LDKFundingSigned this_ptr_conv;
9301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9302         this_ptr_conv.is_owned = false;
9303         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9304         memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
9305         return ret_arr;
9306 }
9307
9308 void  __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9309         LDKFundingSigned this_ptr_conv;
9310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9311         this_ptr_conv.is_owned = false;
9312         LDKThirtyTwoBytes val_ref;
9313         CHECK(*((uint32_t*)val) == 32);
9314         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9315         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
9316 }
9317
9318 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
9319         LDKFundingSigned this_ptr_conv;
9320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9321         this_ptr_conv.is_owned = false;
9322         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9323         memcpy((uint8_t*)(arg_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
9324         return arg_arr;
9325 }
9326
9327 void  __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
9328         LDKFundingSigned this_ptr_conv;
9329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9330         this_ptr_conv.is_owned = false;
9331         LDKSignature val_ref;
9332         CHECK(*((uint32_t*)val) == 64);
9333         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9334         FundingSigned_set_signature(&this_ptr_conv, val_ref);
9335 }
9336
9337 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
9338         LDKThirtyTwoBytes channel_id_arg_ref;
9339         CHECK(*((uint32_t*)channel_id_arg) == 32);
9340         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9341         LDKSignature signature_arg_ref;
9342         CHECK(*((uint32_t*)signature_arg) == 64);
9343         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9344         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
9345         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9346         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9347         long ret_ref = (long)ret_var.inner;
9348         if (ret_var.is_owned) {
9349                 ret_ref |= 1;
9350         }
9351         return ret_ref;
9352 }
9353
9354 void  __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_ptr) {
9355         LDKFundingLocked this_ptr_conv;
9356         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9357         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9358         FundingLocked_free(this_ptr_conv);
9359 }
9360
9361 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
9362         LDKFundingLocked orig_conv;
9363         orig_conv.inner = (void*)(orig & (~1));
9364         orig_conv.is_owned = false;
9365         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
9366         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9367         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9368         long ret_ref = (long)ret_var.inner;
9369         if (ret_var.is_owned) {
9370                 ret_ref |= 1;
9371         }
9372         return ret_ref;
9373 }
9374
9375 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
9376         LDKFundingLocked this_ptr_conv;
9377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9378         this_ptr_conv.is_owned = false;
9379         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9380         memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
9381         return ret_arr;
9382 }
9383
9384 void  __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9385         LDKFundingLocked this_ptr_conv;
9386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9387         this_ptr_conv.is_owned = false;
9388         LDKThirtyTwoBytes val_ref;
9389         CHECK(*((uint32_t*)val) == 32);
9390         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9391         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
9392 }
9393
9394 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
9395         LDKFundingLocked this_ptr_conv;
9396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9397         this_ptr_conv.is_owned = false;
9398         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9399         memcpy((uint8_t*)(arg_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9400         return arg_arr;
9401 }
9402
9403 void  __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
9404         LDKFundingLocked this_ptr_conv;
9405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9406         this_ptr_conv.is_owned = false;
9407         LDKPublicKey val_ref;
9408         CHECK(*((uint32_t*)val) == 33);
9409         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9410         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
9411 }
9412
9413 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
9414         LDKThirtyTwoBytes channel_id_arg_ref;
9415         CHECK(*((uint32_t*)channel_id_arg) == 32);
9416         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9417         LDKPublicKey next_per_commitment_point_arg_ref;
9418         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
9419         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
9420         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
9421         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9422         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9423         long ret_ref = (long)ret_var.inner;
9424         if (ret_var.is_owned) {
9425                 ret_ref |= 1;
9426         }
9427         return ret_ref;
9428 }
9429
9430 void  __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_ptr) {
9431         LDKShutdown this_ptr_conv;
9432         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9433         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9434         Shutdown_free(this_ptr_conv);
9435 }
9436
9437 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
9438         LDKShutdown orig_conv;
9439         orig_conv.inner = (void*)(orig & (~1));
9440         orig_conv.is_owned = false;
9441         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
9442         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9443         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9444         long ret_ref = (long)ret_var.inner;
9445         if (ret_var.is_owned) {
9446                 ret_ref |= 1;
9447         }
9448         return ret_ref;
9449 }
9450
9451 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
9452         LDKShutdown this_ptr_conv;
9453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9454         this_ptr_conv.is_owned = false;
9455         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9456         memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
9457         return ret_arr;
9458 }
9459
9460 void  __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9461         LDKShutdown this_ptr_conv;
9462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9463         this_ptr_conv.is_owned = false;
9464         LDKThirtyTwoBytes val_ref;
9465         CHECK(*((uint32_t*)val) == 32);
9466         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9467         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
9468 }
9469
9470 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
9471         LDKShutdown this_ptr_conv;
9472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9473         this_ptr_conv.is_owned = false;
9474         LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
9475         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9476         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
9477         return arg_arr;
9478 }
9479
9480 void  __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
9481         LDKShutdown this_ptr_conv;
9482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9483         this_ptr_conv.is_owned = false;
9484         LDKCVec_u8Z val_ref;
9485         val_ref.datalen = *((uint32_t*)val);
9486         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
9487         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
9488         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
9489 }
9490
9491 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
9492         LDKThirtyTwoBytes channel_id_arg_ref;
9493         CHECK(*((uint32_t*)channel_id_arg) == 32);
9494         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9495         LDKCVec_u8Z scriptpubkey_arg_ref;
9496         scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
9497         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
9498         memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
9499         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
9500         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9501         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9502         long ret_ref = (long)ret_var.inner;
9503         if (ret_var.is_owned) {
9504                 ret_ref |= 1;
9505         }
9506         return ret_ref;
9507 }
9508
9509 void  __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_ptr) {
9510         LDKClosingSigned this_ptr_conv;
9511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9512         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9513         ClosingSigned_free(this_ptr_conv);
9514 }
9515
9516 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
9517         LDKClosingSigned orig_conv;
9518         orig_conv.inner = (void*)(orig & (~1));
9519         orig_conv.is_owned = false;
9520         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
9521         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9522         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9523         long ret_ref = (long)ret_var.inner;
9524         if (ret_var.is_owned) {
9525                 ret_ref |= 1;
9526         }
9527         return ret_ref;
9528 }
9529
9530 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
9531         LDKClosingSigned this_ptr_conv;
9532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9533         this_ptr_conv.is_owned = false;
9534         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9535         memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
9536         return ret_arr;
9537 }
9538
9539 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9540         LDKClosingSigned this_ptr_conv;
9541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9542         this_ptr_conv.is_owned = false;
9543         LDKThirtyTwoBytes val_ref;
9544         CHECK(*((uint32_t*)val) == 32);
9545         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9546         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
9547 }
9548
9549 int64_t  __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
9550         LDKClosingSigned this_ptr_conv;
9551         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9552         this_ptr_conv.is_owned = false;
9553         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
9554         return ret_val;
9555 }
9556
9557 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
9558         LDKClosingSigned this_ptr_conv;
9559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9560         this_ptr_conv.is_owned = false;
9561         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
9562 }
9563
9564 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
9565         LDKClosingSigned this_ptr_conv;
9566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9567         this_ptr_conv.is_owned = false;
9568         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9569         memcpy((uint8_t*)(arg_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
9570         return arg_arr;
9571 }
9572
9573 void  __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
9574         LDKClosingSigned this_ptr_conv;
9575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9576         this_ptr_conv.is_owned = false;
9577         LDKSignature val_ref;
9578         CHECK(*((uint32_t*)val) == 64);
9579         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9580         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
9581 }
9582
9583 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
9584         LDKThirtyTwoBytes channel_id_arg_ref;
9585         CHECK(*((uint32_t*)channel_id_arg) == 32);
9586         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9587         LDKSignature signature_arg_ref;
9588         CHECK(*((uint32_t*)signature_arg) == 64);
9589         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9590         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
9591         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9592         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9593         long ret_ref = (long)ret_var.inner;
9594         if (ret_var.is_owned) {
9595                 ret_ref |= 1;
9596         }
9597         return ret_ref;
9598 }
9599
9600 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_ptr) {
9601         LDKUpdateAddHTLC this_ptr_conv;
9602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9603         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9604         UpdateAddHTLC_free(this_ptr_conv);
9605 }
9606
9607 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
9608         LDKUpdateAddHTLC orig_conv;
9609         orig_conv.inner = (void*)(orig & (~1));
9610         orig_conv.is_owned = false;
9611         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
9612         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9613         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9614         long ret_ref = (long)ret_var.inner;
9615         if (ret_var.is_owned) {
9616                 ret_ref |= 1;
9617         }
9618         return ret_ref;
9619 }
9620
9621 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
9622         LDKUpdateAddHTLC this_ptr_conv;
9623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9624         this_ptr_conv.is_owned = false;
9625         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9626         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
9627         return ret_arr;
9628 }
9629
9630 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9631         LDKUpdateAddHTLC this_ptr_conv;
9632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9633         this_ptr_conv.is_owned = false;
9634         LDKThirtyTwoBytes val_ref;
9635         CHECK(*((uint32_t*)val) == 32);
9636         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9637         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
9638 }
9639
9640 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
9641         LDKUpdateAddHTLC this_ptr_conv;
9642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9643         this_ptr_conv.is_owned = false;
9644         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
9645         return ret_val;
9646 }
9647
9648 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9649         LDKUpdateAddHTLC this_ptr_conv;
9650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9651         this_ptr_conv.is_owned = false;
9652         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
9653 }
9654
9655 int64_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
9656         LDKUpdateAddHTLC this_ptr_conv;
9657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9658         this_ptr_conv.is_owned = false;
9659         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
9660         return ret_val;
9661 }
9662
9663 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
9664         LDKUpdateAddHTLC this_ptr_conv;
9665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9666         this_ptr_conv.is_owned = false;
9667         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
9668 }
9669
9670 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
9671         LDKUpdateAddHTLC this_ptr_conv;
9672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9673         this_ptr_conv.is_owned = false;
9674         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9675         memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
9676         return ret_arr;
9677 }
9678
9679 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
9680         LDKUpdateAddHTLC this_ptr_conv;
9681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9682         this_ptr_conv.is_owned = false;
9683         LDKThirtyTwoBytes val_ref;
9684         CHECK(*((uint32_t*)val) == 32);
9685         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9686         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
9687 }
9688
9689 int32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
9690         LDKUpdateAddHTLC this_ptr_conv;
9691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9692         this_ptr_conv.is_owned = false;
9693         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
9694         return ret_val;
9695 }
9696
9697 void  __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
9698         LDKUpdateAddHTLC this_ptr_conv;
9699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9700         this_ptr_conv.is_owned = false;
9701         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
9702 }
9703
9704 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_ptr) {
9705         LDKUpdateFulfillHTLC this_ptr_conv;
9706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9707         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9708         UpdateFulfillHTLC_free(this_ptr_conv);
9709 }
9710
9711 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
9712         LDKUpdateFulfillHTLC orig_conv;
9713         orig_conv.inner = (void*)(orig & (~1));
9714         orig_conv.is_owned = false;
9715         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
9716         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9717         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9718         long ret_ref = (long)ret_var.inner;
9719         if (ret_var.is_owned) {
9720                 ret_ref |= 1;
9721         }
9722         return ret_ref;
9723 }
9724
9725 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
9726         LDKUpdateFulfillHTLC this_ptr_conv;
9727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9728         this_ptr_conv.is_owned = false;
9729         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9730         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
9731         return ret_arr;
9732 }
9733
9734 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9735         LDKUpdateFulfillHTLC this_ptr_conv;
9736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9737         this_ptr_conv.is_owned = false;
9738         LDKThirtyTwoBytes val_ref;
9739         CHECK(*((uint32_t*)val) == 32);
9740         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9741         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
9742 }
9743
9744 int64_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
9745         LDKUpdateFulfillHTLC this_ptr_conv;
9746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9747         this_ptr_conv.is_owned = false;
9748         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
9749         return ret_val;
9750 }
9751
9752 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9753         LDKUpdateFulfillHTLC this_ptr_conv;
9754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9755         this_ptr_conv.is_owned = false;
9756         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
9757 }
9758
9759 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
9760         LDKUpdateFulfillHTLC this_ptr_conv;
9761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9762         this_ptr_conv.is_owned = false;
9763         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9764         memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
9765         return ret_arr;
9766 }
9767
9768 void  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
9769         LDKUpdateFulfillHTLC this_ptr_conv;
9770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9771         this_ptr_conv.is_owned = false;
9772         LDKThirtyTwoBytes val_ref;
9773         CHECK(*((uint32_t*)val) == 32);
9774         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9775         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
9776 }
9777
9778 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
9779         LDKThirtyTwoBytes channel_id_arg_ref;
9780         CHECK(*((uint32_t*)channel_id_arg) == 32);
9781         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9782         LDKThirtyTwoBytes payment_preimage_arg_ref;
9783         CHECK(*((uint32_t*)payment_preimage_arg) == 32);
9784         memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
9785         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
9786         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9787         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9788         long ret_ref = (long)ret_var.inner;
9789         if (ret_var.is_owned) {
9790                 ret_ref |= 1;
9791         }
9792         return ret_ref;
9793 }
9794
9795 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_ptr) {
9796         LDKUpdateFailHTLC this_ptr_conv;
9797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9798         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9799         UpdateFailHTLC_free(this_ptr_conv);
9800 }
9801
9802 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
9803         LDKUpdateFailHTLC orig_conv;
9804         orig_conv.inner = (void*)(orig & (~1));
9805         orig_conv.is_owned = false;
9806         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
9807         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9808         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9809         long ret_ref = (long)ret_var.inner;
9810         if (ret_var.is_owned) {
9811                 ret_ref |= 1;
9812         }
9813         return ret_ref;
9814 }
9815
9816 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
9817         LDKUpdateFailHTLC this_ptr_conv;
9818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9819         this_ptr_conv.is_owned = false;
9820         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9821         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
9822         return ret_arr;
9823 }
9824
9825 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9826         LDKUpdateFailHTLC this_ptr_conv;
9827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9828         this_ptr_conv.is_owned = false;
9829         LDKThirtyTwoBytes val_ref;
9830         CHECK(*((uint32_t*)val) == 32);
9831         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9832         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
9833 }
9834
9835 int64_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
9836         LDKUpdateFailHTLC this_ptr_conv;
9837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9838         this_ptr_conv.is_owned = false;
9839         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
9840         return ret_val;
9841 }
9842
9843 void  __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9844         LDKUpdateFailHTLC this_ptr_conv;
9845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9846         this_ptr_conv.is_owned = false;
9847         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
9848 }
9849
9850 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_ptr) {
9851         LDKUpdateFailMalformedHTLC this_ptr_conv;
9852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9853         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9854         UpdateFailMalformedHTLC_free(this_ptr_conv);
9855 }
9856
9857 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
9858         LDKUpdateFailMalformedHTLC orig_conv;
9859         orig_conv.inner = (void*)(orig & (~1));
9860         orig_conv.is_owned = false;
9861         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
9862         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9863         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9864         long ret_ref = (long)ret_var.inner;
9865         if (ret_var.is_owned) {
9866                 ret_ref |= 1;
9867         }
9868         return ret_ref;
9869 }
9870
9871 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
9872         LDKUpdateFailMalformedHTLC this_ptr_conv;
9873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9874         this_ptr_conv.is_owned = false;
9875         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9876         memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
9877         return ret_arr;
9878 }
9879
9880 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9881         LDKUpdateFailMalformedHTLC this_ptr_conv;
9882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9883         this_ptr_conv.is_owned = false;
9884         LDKThirtyTwoBytes val_ref;
9885         CHECK(*((uint32_t*)val) == 32);
9886         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9887         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
9888 }
9889
9890 int64_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
9891         LDKUpdateFailMalformedHTLC this_ptr_conv;
9892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9893         this_ptr_conv.is_owned = false;
9894         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
9895         return ret_val;
9896 }
9897
9898 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9899         LDKUpdateFailMalformedHTLC this_ptr_conv;
9900         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9901         this_ptr_conv.is_owned = false;
9902         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
9903 }
9904
9905 int16_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
9906         LDKUpdateFailMalformedHTLC this_ptr_conv;
9907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9908         this_ptr_conv.is_owned = false;
9909         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
9910         return ret_val;
9911 }
9912
9913 void  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
9914         LDKUpdateFailMalformedHTLC this_ptr_conv;
9915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9916         this_ptr_conv.is_owned = false;
9917         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
9918 }
9919
9920 void  __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_ptr) {
9921         LDKCommitmentSigned this_ptr_conv;
9922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9923         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9924         CommitmentSigned_free(this_ptr_conv);
9925 }
9926
9927 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
9928         LDKCommitmentSigned orig_conv;
9929         orig_conv.inner = (void*)(orig & (~1));
9930         orig_conv.is_owned = false;
9931         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
9932         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9933         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9934         long ret_ref = (long)ret_var.inner;
9935         if (ret_var.is_owned) {
9936                 ret_ref |= 1;
9937         }
9938         return ret_ref;
9939 }
9940
9941 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
9942         LDKCommitmentSigned this_ptr_conv;
9943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9944         this_ptr_conv.is_owned = false;
9945         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9946         memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
9947         return ret_arr;
9948 }
9949
9950 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9951         LDKCommitmentSigned this_ptr_conv;
9952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9953         this_ptr_conv.is_owned = false;
9954         LDKThirtyTwoBytes val_ref;
9955         CHECK(*((uint32_t*)val) == 32);
9956         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9957         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
9958 }
9959
9960 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
9961         LDKCommitmentSigned this_ptr_conv;
9962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9963         this_ptr_conv.is_owned = false;
9964         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9965         memcpy((uint8_t*)(arg_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
9966         return arg_arr;
9967 }
9968
9969 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
9970         LDKCommitmentSigned this_ptr_conv;
9971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9972         this_ptr_conv.is_owned = false;
9973         LDKSignature val_ref;
9974         CHECK(*((uint32_t*)val) == 64);
9975         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9976         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
9977 }
9978
9979 void  __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
9980         LDKCommitmentSigned this_ptr_conv;
9981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9982         this_ptr_conv.is_owned = false;
9983         LDKCVec_SignatureZ val_constr;
9984         val_constr.datalen = *((uint32_t*)val);
9985         if (val_constr.datalen > 0)
9986                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9987         else
9988                 val_constr.data = NULL;
9989         int8_tArray* val_vals = (int8_tArray*)(val + 4);
9990         for (size_t m = 0; m < val_constr.datalen; m++) {
9991                 int8_tArray arr_conv_12 = val_vals[m];
9992                 LDKSignature arr_conv_12_ref;
9993                 CHECK(*((uint32_t*)arr_conv_12) == 64);
9994                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
9995                 val_constr.data[m] = arr_conv_12_ref;
9996         }
9997         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
9998 }
9999
10000 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
10001         LDKThirtyTwoBytes channel_id_arg_ref;
10002         CHECK(*((uint32_t*)channel_id_arg) == 32);
10003         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10004         LDKSignature signature_arg_ref;
10005         CHECK(*((uint32_t*)signature_arg) == 64);
10006         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
10007         LDKCVec_SignatureZ htlc_signatures_arg_constr;
10008         htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
10009         if (htlc_signatures_arg_constr.datalen > 0)
10010                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10011         else
10012                 htlc_signatures_arg_constr.data = NULL;
10013         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
10014         for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
10015                 int8_tArray arr_conv_12 = htlc_signatures_arg_vals[m];
10016                 LDKSignature arr_conv_12_ref;
10017                 CHECK(*((uint32_t*)arr_conv_12) == 64);
10018                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
10019                 htlc_signatures_arg_constr.data[m] = arr_conv_12_ref;
10020         }
10021         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
10022         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10023         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10024         long ret_ref = (long)ret_var.inner;
10025         if (ret_var.is_owned) {
10026                 ret_ref |= 1;
10027         }
10028         return ret_ref;
10029 }
10030
10031 void  __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_ptr) {
10032         LDKRevokeAndACK this_ptr_conv;
10033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10034         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10035         RevokeAndACK_free(this_ptr_conv);
10036 }
10037
10038 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
10039         LDKRevokeAndACK orig_conv;
10040         orig_conv.inner = (void*)(orig & (~1));
10041         orig_conv.is_owned = false;
10042         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
10043         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10044         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10045         long ret_ref = (long)ret_var.inner;
10046         if (ret_var.is_owned) {
10047                 ret_ref |= 1;
10048         }
10049         return ret_ref;
10050 }
10051
10052 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
10053         LDKRevokeAndACK this_ptr_conv;
10054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10055         this_ptr_conv.is_owned = false;
10056         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10057         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
10058         return ret_arr;
10059 }
10060
10061 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10062         LDKRevokeAndACK this_ptr_conv;
10063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10064         this_ptr_conv.is_owned = false;
10065         LDKThirtyTwoBytes val_ref;
10066         CHECK(*((uint32_t*)val) == 32);
10067         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10068         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
10069 }
10070
10071 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
10072         LDKRevokeAndACK this_ptr_conv;
10073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10074         this_ptr_conv.is_owned = false;
10075         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10076         memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
10077         return ret_arr;
10078 }
10079
10080 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
10081         LDKRevokeAndACK this_ptr_conv;
10082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10083         this_ptr_conv.is_owned = false;
10084         LDKThirtyTwoBytes val_ref;
10085         CHECK(*((uint32_t*)val) == 32);
10086         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10087         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
10088 }
10089
10090 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
10091         LDKRevokeAndACK this_ptr_conv;
10092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10093         this_ptr_conv.is_owned = false;
10094         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10095         memcpy((uint8_t*)(arg_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
10096         return arg_arr;
10097 }
10098
10099 void  __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
10100         LDKRevokeAndACK this_ptr_conv;
10101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10102         this_ptr_conv.is_owned = false;
10103         LDKPublicKey val_ref;
10104         CHECK(*((uint32_t*)val) == 33);
10105         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10106         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
10107 }
10108
10109 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) {
10110         LDKThirtyTwoBytes channel_id_arg_ref;
10111         CHECK(*((uint32_t*)channel_id_arg) == 32);
10112         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10113         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
10114         CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
10115         memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
10116         LDKPublicKey next_per_commitment_point_arg_ref;
10117         CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
10118         memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
10119         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
10120         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10121         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10122         long ret_ref = (long)ret_var.inner;
10123         if (ret_var.is_owned) {
10124                 ret_ref |= 1;
10125         }
10126         return ret_ref;
10127 }
10128
10129 void  __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_ptr) {
10130         LDKUpdateFee this_ptr_conv;
10131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10132         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10133         UpdateFee_free(this_ptr_conv);
10134 }
10135
10136 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
10137         LDKUpdateFee orig_conv;
10138         orig_conv.inner = (void*)(orig & (~1));
10139         orig_conv.is_owned = false;
10140         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
10141         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10142         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10143         long ret_ref = (long)ret_var.inner;
10144         if (ret_var.is_owned) {
10145                 ret_ref |= 1;
10146         }
10147         return ret_ref;
10148 }
10149
10150 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
10151         LDKUpdateFee this_ptr_conv;
10152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10153         this_ptr_conv.is_owned = false;
10154         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10155         memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
10156         return ret_arr;
10157 }
10158
10159 void  __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10160         LDKUpdateFee this_ptr_conv;
10161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10162         this_ptr_conv.is_owned = false;
10163         LDKThirtyTwoBytes val_ref;
10164         CHECK(*((uint32_t*)val) == 32);
10165         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10166         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
10167 }
10168
10169 int32_t  __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
10170         LDKUpdateFee this_ptr_conv;
10171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10172         this_ptr_conv.is_owned = false;
10173         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
10174         return ret_val;
10175 }
10176
10177 void  __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
10178         LDKUpdateFee this_ptr_conv;
10179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10180         this_ptr_conv.is_owned = false;
10181         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
10182 }
10183
10184 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
10185         LDKThirtyTwoBytes channel_id_arg_ref;
10186         CHECK(*((uint32_t*)channel_id_arg) == 32);
10187         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10188         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
10189         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10190         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10191         long ret_ref = (long)ret_var.inner;
10192         if (ret_var.is_owned) {
10193                 ret_ref |= 1;
10194         }
10195         return ret_ref;
10196 }
10197
10198 void  __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_ptr) {
10199         LDKDataLossProtect this_ptr_conv;
10200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10201         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10202         DataLossProtect_free(this_ptr_conv);
10203 }
10204
10205 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
10206         LDKDataLossProtect orig_conv;
10207         orig_conv.inner = (void*)(orig & (~1));
10208         orig_conv.is_owned = false;
10209         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
10210         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10211         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10212         long ret_ref = (long)ret_var.inner;
10213         if (ret_var.is_owned) {
10214                 ret_ref |= 1;
10215         }
10216         return ret_ref;
10217 }
10218
10219 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
10220         LDKDataLossProtect this_ptr_conv;
10221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10222         this_ptr_conv.is_owned = false;
10223         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10224         memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
10225         return ret_arr;
10226 }
10227
10228 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
10229         LDKDataLossProtect this_ptr_conv;
10230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10231         this_ptr_conv.is_owned = false;
10232         LDKThirtyTwoBytes val_ref;
10233         CHECK(*((uint32_t*)val) == 32);
10234         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10235         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
10236 }
10237
10238 int8_tArray  __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
10239         LDKDataLossProtect this_ptr_conv;
10240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10241         this_ptr_conv.is_owned = false;
10242         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10243         memcpy((uint8_t*)(arg_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
10244         return arg_arr;
10245 }
10246
10247 void  __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
10248         LDKDataLossProtect this_ptr_conv;
10249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10250         this_ptr_conv.is_owned = false;
10251         LDKPublicKey val_ref;
10252         CHECK(*((uint32_t*)val) == 33);
10253         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10254         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
10255 }
10256
10257 uint32_t  __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
10258         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
10259         CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
10260         memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
10261         LDKPublicKey my_current_per_commitment_point_arg_ref;
10262         CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
10263         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
10264         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
10265         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10266         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10267         long ret_ref = (long)ret_var.inner;
10268         if (ret_var.is_owned) {
10269                 ret_ref |= 1;
10270         }
10271         return ret_ref;
10272 }
10273
10274 void  __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_ptr) {
10275         LDKChannelReestablish this_ptr_conv;
10276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10277         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10278         ChannelReestablish_free(this_ptr_conv);
10279 }
10280
10281 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
10282         LDKChannelReestablish orig_conv;
10283         orig_conv.inner = (void*)(orig & (~1));
10284         orig_conv.is_owned = false;
10285         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
10286         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10287         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10288         long ret_ref = (long)ret_var.inner;
10289         if (ret_var.is_owned) {
10290                 ret_ref |= 1;
10291         }
10292         return ret_ref;
10293 }
10294
10295 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
10296         LDKChannelReestablish this_ptr_conv;
10297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10298         this_ptr_conv.is_owned = false;
10299         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10300         memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
10301         return ret_arr;
10302 }
10303
10304 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10305         LDKChannelReestablish this_ptr_conv;
10306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10307         this_ptr_conv.is_owned = false;
10308         LDKThirtyTwoBytes val_ref;
10309         CHECK(*((uint32_t*)val) == 32);
10310         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10311         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
10312 }
10313
10314 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
10315         LDKChannelReestablish this_ptr_conv;
10316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10317         this_ptr_conv.is_owned = false;
10318         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
10319         return ret_val;
10320 }
10321
10322 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
10323         LDKChannelReestablish this_ptr_conv;
10324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10325         this_ptr_conv.is_owned = false;
10326         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
10327 }
10328
10329 int64_t  __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
10330         LDKChannelReestablish this_ptr_conv;
10331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10332         this_ptr_conv.is_owned = false;
10333         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
10334         return ret_val;
10335 }
10336
10337 void  __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
10338         LDKChannelReestablish this_ptr_conv;
10339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10340         this_ptr_conv.is_owned = false;
10341         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
10342 }
10343
10344 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_ptr) {
10345         LDKAnnouncementSignatures this_ptr_conv;
10346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10347         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10348         AnnouncementSignatures_free(this_ptr_conv);
10349 }
10350
10351 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
10352         LDKAnnouncementSignatures orig_conv;
10353         orig_conv.inner = (void*)(orig & (~1));
10354         orig_conv.is_owned = false;
10355         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
10356         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10357         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10358         long ret_ref = (long)ret_var.inner;
10359         if (ret_var.is_owned) {
10360                 ret_ref |= 1;
10361         }
10362         return ret_ref;
10363 }
10364
10365 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
10366         LDKAnnouncementSignatures this_ptr_conv;
10367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10368         this_ptr_conv.is_owned = false;
10369         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10370         memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
10371         return ret_arr;
10372 }
10373
10374 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10375         LDKAnnouncementSignatures this_ptr_conv;
10376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10377         this_ptr_conv.is_owned = false;
10378         LDKThirtyTwoBytes val_ref;
10379         CHECK(*((uint32_t*)val) == 32);
10380         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10381         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
10382 }
10383
10384 int64_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
10385         LDKAnnouncementSignatures this_ptr_conv;
10386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10387         this_ptr_conv.is_owned = false;
10388         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
10389         return ret_val;
10390 }
10391
10392 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
10393         LDKAnnouncementSignatures this_ptr_conv;
10394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10395         this_ptr_conv.is_owned = false;
10396         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
10397 }
10398
10399 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
10400         LDKAnnouncementSignatures this_ptr_conv;
10401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10402         this_ptr_conv.is_owned = false;
10403         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10404         memcpy((uint8_t*)(arg_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
10405         return arg_arr;
10406 }
10407
10408 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
10409         LDKAnnouncementSignatures this_ptr_conv;
10410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10411         this_ptr_conv.is_owned = false;
10412         LDKSignature val_ref;
10413         CHECK(*((uint32_t*)val) == 64);
10414         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10415         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
10416 }
10417
10418 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
10419         LDKAnnouncementSignatures this_ptr_conv;
10420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10421         this_ptr_conv.is_owned = false;
10422         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10423         memcpy((uint8_t*)(arg_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
10424         return arg_arr;
10425 }
10426
10427 void  __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
10428         LDKAnnouncementSignatures this_ptr_conv;
10429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10430         this_ptr_conv.is_owned = false;
10431         LDKSignature val_ref;
10432         CHECK(*((uint32_t*)val) == 64);
10433         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10434         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
10435 }
10436
10437 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) {
10438         LDKThirtyTwoBytes channel_id_arg_ref;
10439         CHECK(*((uint32_t*)channel_id_arg) == 32);
10440         memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10441         LDKSignature node_signature_arg_ref;
10442         CHECK(*((uint32_t*)node_signature_arg) == 64);
10443         memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
10444         LDKSignature bitcoin_signature_arg_ref;
10445         CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
10446         memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
10447         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
10448         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10449         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10450         long ret_ref = (long)ret_var.inner;
10451         if (ret_var.is_owned) {
10452                 ret_ref |= 1;
10453         }
10454         return ret_ref;
10455 }
10456
10457 void  __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
10458         if ((this_ptr & 1) != 0) return;
10459         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(((uint64_t)this_ptr) & ~1);
10460         FREE((void*)this_ptr);
10461         NetAddress_free(this_ptr_conv);
10462 }
10463
10464 uint32_t  __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
10465         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
10466         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
10467         *ret_copy = NetAddress_clone(orig_conv);
10468         long ret_ref = (long)ret_copy;
10469         return ret_ref;
10470 }
10471
10472 int8_tArray  __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
10473         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
10474         LDKCVec_u8Z arg_var = NetAddress_write(obj_conv);
10475         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10476         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
10477         CVec_u8Z_free(arg_var);
10478         return arg_arr;
10479 }
10480
10481 uint32_t  __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
10482         LDKu8slice ser_ref;
10483         ser_ref.datalen = *((uint32_t*)ser);
10484         ser_ref.data = (int8_t*)(ser + 4);
10485         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10486         *ret_conv = Result_read(ser_ref);
10487         return (long)ret_conv;
10488 }
10489
10490 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_ptr) {
10491         LDKUnsignedNodeAnnouncement this_ptr_conv;
10492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10493         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10494         UnsignedNodeAnnouncement_free(this_ptr_conv);
10495 }
10496
10497 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
10498         LDKUnsignedNodeAnnouncement orig_conv;
10499         orig_conv.inner = (void*)(orig & (~1));
10500         orig_conv.is_owned = false;
10501         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
10502         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10503         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10504         long ret_ref = (long)ret_var.inner;
10505         if (ret_var.is_owned) {
10506                 ret_ref |= 1;
10507         }
10508         return ret_ref;
10509 }
10510
10511 uint32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
10512         LDKUnsignedNodeAnnouncement this_ptr_conv;
10513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10514         this_ptr_conv.is_owned = false;
10515         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
10516         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10517         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10518         long ret_ref = (long)ret_var.inner;
10519         if (ret_var.is_owned) {
10520                 ret_ref |= 1;
10521         }
10522         return ret_ref;
10523 }
10524
10525 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
10526         LDKUnsignedNodeAnnouncement this_ptr_conv;
10527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10528         this_ptr_conv.is_owned = false;
10529         LDKNodeFeatures val_conv;
10530         val_conv.inner = (void*)(val & (~1));
10531         val_conv.is_owned = (val & 1) || (val == 0);
10532         // Warning: we need a move here but no clone is available for LDKNodeFeatures
10533         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
10534 }
10535
10536 int32_t  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
10537         LDKUnsignedNodeAnnouncement this_ptr_conv;
10538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10539         this_ptr_conv.is_owned = false;
10540         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
10541         return ret_val;
10542 }
10543
10544 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
10545         LDKUnsignedNodeAnnouncement this_ptr_conv;
10546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10547         this_ptr_conv.is_owned = false;
10548         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
10549 }
10550
10551 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
10552         LDKUnsignedNodeAnnouncement this_ptr_conv;
10553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10554         this_ptr_conv.is_owned = false;
10555         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10556         memcpy((uint8_t*)(arg_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
10557         return arg_arr;
10558 }
10559
10560 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
10561         LDKUnsignedNodeAnnouncement this_ptr_conv;
10562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10563         this_ptr_conv.is_owned = false;
10564         LDKPublicKey val_ref;
10565         CHECK(*((uint32_t*)val) == 33);
10566         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10567         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
10568 }
10569
10570 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
10571         LDKUnsignedNodeAnnouncement this_ptr_conv;
10572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10573         this_ptr_conv.is_owned = false;
10574         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
10575         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
10576         return ret_arr;
10577 }
10578
10579 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
10580         LDKUnsignedNodeAnnouncement this_ptr_conv;
10581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10582         this_ptr_conv.is_owned = false;
10583         LDKThreeBytes val_ref;
10584         CHECK(*((uint32_t*)val) == 3);
10585         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
10586         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
10587 }
10588
10589 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
10590         LDKUnsignedNodeAnnouncement this_ptr_conv;
10591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10592         this_ptr_conv.is_owned = false;
10593         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10594         memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
10595         return ret_arr;
10596 }
10597
10598 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
10599         LDKUnsignedNodeAnnouncement this_ptr_conv;
10600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10601         this_ptr_conv.is_owned = false;
10602         LDKThirtyTwoBytes val_ref;
10603         CHECK(*((uint32_t*)val) == 32);
10604         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10605         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
10606 }
10607
10608 void  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
10609         LDKUnsignedNodeAnnouncement this_ptr_conv;
10610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10611         this_ptr_conv.is_owned = false;
10612         LDKCVec_NetAddressZ val_constr;
10613         val_constr.datalen = *((uint32_t*)val);
10614         if (val_constr.datalen > 0)
10615                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10616         else
10617                 val_constr.data = NULL;
10618         uint32_t* val_vals = (uint32_t*)(val + 4);
10619         for (size_t m = 0; m < val_constr.datalen; m++) {
10620                 uint32_t arr_conv_12 = val_vals[m];
10621                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
10622                 FREE((void*)arr_conv_12);
10623                 val_constr.data[m] = arr_conv_12_conv;
10624         }
10625         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
10626 }
10627
10628 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_ptr) {
10629         LDKNodeAnnouncement this_ptr_conv;
10630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10631         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10632         NodeAnnouncement_free(this_ptr_conv);
10633 }
10634
10635 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
10636         LDKNodeAnnouncement orig_conv;
10637         orig_conv.inner = (void*)(orig & (~1));
10638         orig_conv.is_owned = false;
10639         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
10640         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10641         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10642         long ret_ref = (long)ret_var.inner;
10643         if (ret_var.is_owned) {
10644                 ret_ref |= 1;
10645         }
10646         return ret_ref;
10647 }
10648
10649 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
10650         LDKNodeAnnouncement this_ptr_conv;
10651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10652         this_ptr_conv.is_owned = false;
10653         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10654         memcpy((uint8_t*)(arg_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
10655         return arg_arr;
10656 }
10657
10658 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
10659         LDKNodeAnnouncement this_ptr_conv;
10660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10661         this_ptr_conv.is_owned = false;
10662         LDKSignature val_ref;
10663         CHECK(*((uint32_t*)val) == 64);
10664         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10665         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
10666 }
10667
10668 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
10669         LDKNodeAnnouncement this_ptr_conv;
10670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10671         this_ptr_conv.is_owned = false;
10672         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
10673         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10674         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10675         long ret_ref = (long)ret_var.inner;
10676         if (ret_var.is_owned) {
10677                 ret_ref |= 1;
10678         }
10679         return ret_ref;
10680 }
10681
10682 void  __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
10683         LDKNodeAnnouncement this_ptr_conv;
10684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10685         this_ptr_conv.is_owned = false;
10686         LDKUnsignedNodeAnnouncement val_conv;
10687         val_conv.inner = (void*)(val & (~1));
10688         val_conv.is_owned = (val & 1) || (val == 0);
10689         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
10690         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
10691 }
10692
10693 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
10694         LDKSignature signature_arg_ref;
10695         CHECK(*((uint32_t*)signature_arg) == 64);
10696         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
10697         LDKUnsignedNodeAnnouncement contents_arg_conv;
10698         contents_arg_conv.inner = (void*)(contents_arg & (~1));
10699         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
10700         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
10701         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
10702         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10703         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10704         long ret_ref = (long)ret_var.inner;
10705         if (ret_var.is_owned) {
10706                 ret_ref |= 1;
10707         }
10708         return ret_ref;
10709 }
10710
10711 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_ptr) {
10712         LDKUnsignedChannelAnnouncement this_ptr_conv;
10713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10715         UnsignedChannelAnnouncement_free(this_ptr_conv);
10716 }
10717
10718 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
10719         LDKUnsignedChannelAnnouncement orig_conv;
10720         orig_conv.inner = (void*)(orig & (~1));
10721         orig_conv.is_owned = false;
10722         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
10723         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10724         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10725         long ret_ref = (long)ret_var.inner;
10726         if (ret_var.is_owned) {
10727                 ret_ref |= 1;
10728         }
10729         return ret_ref;
10730 }
10731
10732 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
10733         LDKUnsignedChannelAnnouncement this_ptr_conv;
10734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10735         this_ptr_conv.is_owned = false;
10736         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
10737         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10738         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10739         long ret_ref = (long)ret_var.inner;
10740         if (ret_var.is_owned) {
10741                 ret_ref |= 1;
10742         }
10743         return ret_ref;
10744 }
10745
10746 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
10747         LDKUnsignedChannelAnnouncement this_ptr_conv;
10748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10749         this_ptr_conv.is_owned = false;
10750         LDKChannelFeatures val_conv;
10751         val_conv.inner = (void*)(val & (~1));
10752         val_conv.is_owned = (val & 1) || (val == 0);
10753         // Warning: we need a move here but no clone is available for LDKChannelFeatures
10754         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
10755 }
10756
10757 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
10758         LDKUnsignedChannelAnnouncement this_ptr_conv;
10759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10760         this_ptr_conv.is_owned = false;
10761         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10762         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
10763         return ret_arr;
10764 }
10765
10766 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
10767         LDKUnsignedChannelAnnouncement this_ptr_conv;
10768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10769         this_ptr_conv.is_owned = false;
10770         LDKThirtyTwoBytes val_ref;
10771         CHECK(*((uint32_t*)val) == 32);
10772         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10773         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
10774 }
10775
10776 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
10777         LDKUnsignedChannelAnnouncement this_ptr_conv;
10778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10779         this_ptr_conv.is_owned = false;
10780         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
10781         return ret_val;
10782 }
10783
10784 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
10785         LDKUnsignedChannelAnnouncement this_ptr_conv;
10786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10787         this_ptr_conv.is_owned = false;
10788         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
10789 }
10790
10791 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
10792         LDKUnsignedChannelAnnouncement this_ptr_conv;
10793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10794         this_ptr_conv.is_owned = false;
10795         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10796         memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
10797         return arg_arr;
10798 }
10799
10800 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
10801         LDKUnsignedChannelAnnouncement this_ptr_conv;
10802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10803         this_ptr_conv.is_owned = false;
10804         LDKPublicKey val_ref;
10805         CHECK(*((uint32_t*)val) == 33);
10806         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10807         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
10808 }
10809
10810 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
10811         LDKUnsignedChannelAnnouncement this_ptr_conv;
10812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10813         this_ptr_conv.is_owned = false;
10814         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10815         memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
10816         return arg_arr;
10817 }
10818
10819 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
10820         LDKUnsignedChannelAnnouncement this_ptr_conv;
10821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10822         this_ptr_conv.is_owned = false;
10823         LDKPublicKey val_ref;
10824         CHECK(*((uint32_t*)val) == 33);
10825         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10826         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
10827 }
10828
10829 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
10830         LDKUnsignedChannelAnnouncement this_ptr_conv;
10831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10832         this_ptr_conv.is_owned = false;
10833         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10834         memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
10835         return arg_arr;
10836 }
10837
10838 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
10839         LDKUnsignedChannelAnnouncement this_ptr_conv;
10840         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10841         this_ptr_conv.is_owned = false;
10842         LDKPublicKey val_ref;
10843         CHECK(*((uint32_t*)val) == 33);
10844         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10845         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
10846 }
10847
10848 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
10849         LDKUnsignedChannelAnnouncement this_ptr_conv;
10850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10851         this_ptr_conv.is_owned = false;
10852         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10853         memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
10854         return arg_arr;
10855 }
10856
10857 void  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
10858         LDKUnsignedChannelAnnouncement this_ptr_conv;
10859         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10860         this_ptr_conv.is_owned = false;
10861         LDKPublicKey val_ref;
10862         CHECK(*((uint32_t*)val) == 33);
10863         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10864         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
10865 }
10866
10867 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_ptr) {
10868         LDKChannelAnnouncement this_ptr_conv;
10869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10870         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10871         ChannelAnnouncement_free(this_ptr_conv);
10872 }
10873
10874 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
10875         LDKChannelAnnouncement orig_conv;
10876         orig_conv.inner = (void*)(orig & (~1));
10877         orig_conv.is_owned = false;
10878         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
10879         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10880         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10881         long ret_ref = (long)ret_var.inner;
10882         if (ret_var.is_owned) {
10883                 ret_ref |= 1;
10884         }
10885         return ret_ref;
10886 }
10887
10888 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
10889         LDKChannelAnnouncement this_ptr_conv;
10890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10891         this_ptr_conv.is_owned = false;
10892         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10893         memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
10894         return arg_arr;
10895 }
10896
10897 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
10898         LDKChannelAnnouncement this_ptr_conv;
10899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10900         this_ptr_conv.is_owned = false;
10901         LDKSignature val_ref;
10902         CHECK(*((uint32_t*)val) == 64);
10903         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10904         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
10905 }
10906
10907 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
10908         LDKChannelAnnouncement this_ptr_conv;
10909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10910         this_ptr_conv.is_owned = false;
10911         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10912         memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
10913         return arg_arr;
10914 }
10915
10916 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
10917         LDKChannelAnnouncement this_ptr_conv;
10918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10919         this_ptr_conv.is_owned = false;
10920         LDKSignature val_ref;
10921         CHECK(*((uint32_t*)val) == 64);
10922         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10923         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
10924 }
10925
10926 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
10927         LDKChannelAnnouncement this_ptr_conv;
10928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10929         this_ptr_conv.is_owned = false;
10930         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10931         memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
10932         return arg_arr;
10933 }
10934
10935 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
10936         LDKChannelAnnouncement this_ptr_conv;
10937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10938         this_ptr_conv.is_owned = false;
10939         LDKSignature val_ref;
10940         CHECK(*((uint32_t*)val) == 64);
10941         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10942         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
10943 }
10944
10945 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
10946         LDKChannelAnnouncement this_ptr_conv;
10947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10948         this_ptr_conv.is_owned = false;
10949         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10950         memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
10951         return arg_arr;
10952 }
10953
10954 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
10955         LDKChannelAnnouncement this_ptr_conv;
10956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10957         this_ptr_conv.is_owned = false;
10958         LDKSignature val_ref;
10959         CHECK(*((uint32_t*)val) == 64);
10960         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10961         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
10962 }
10963
10964 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
10965         LDKChannelAnnouncement this_ptr_conv;
10966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10967         this_ptr_conv.is_owned = false;
10968         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
10969         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10970         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10971         long ret_ref = (long)ret_var.inner;
10972         if (ret_var.is_owned) {
10973                 ret_ref |= 1;
10974         }
10975         return ret_ref;
10976 }
10977
10978 void  __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
10979         LDKChannelAnnouncement this_ptr_conv;
10980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10981         this_ptr_conv.is_owned = false;
10982         LDKUnsignedChannelAnnouncement val_conv;
10983         val_conv.inner = (void*)(val & (~1));
10984         val_conv.is_owned = (val & 1) || (val == 0);
10985         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
10986         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
10987 }
10988
10989 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) {
10990         LDKSignature node_signature_1_arg_ref;
10991         CHECK(*((uint32_t*)node_signature_1_arg) == 64);
10992         memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
10993         LDKSignature node_signature_2_arg_ref;
10994         CHECK(*((uint32_t*)node_signature_2_arg) == 64);
10995         memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
10996         LDKSignature bitcoin_signature_1_arg_ref;
10997         CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
10998         memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
10999         LDKSignature bitcoin_signature_2_arg_ref;
11000         CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
11001         memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
11002         LDKUnsignedChannelAnnouncement contents_arg_conv;
11003         contents_arg_conv.inner = (void*)(contents_arg & (~1));
11004         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
11005         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
11006         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);
11007         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11008         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11009         long ret_ref = (long)ret_var.inner;
11010         if (ret_var.is_owned) {
11011                 ret_ref |= 1;
11012         }
11013         return ret_ref;
11014 }
11015
11016 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_ptr) {
11017         LDKUnsignedChannelUpdate this_ptr_conv;
11018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11019         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11020         UnsignedChannelUpdate_free(this_ptr_conv);
11021 }
11022
11023 uint32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
11024         LDKUnsignedChannelUpdate orig_conv;
11025         orig_conv.inner = (void*)(orig & (~1));
11026         orig_conv.is_owned = false;
11027         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
11028         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11029         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11030         long ret_ref = (long)ret_var.inner;
11031         if (ret_var.is_owned) {
11032                 ret_ref |= 1;
11033         }
11034         return ret_ref;
11035 }
11036
11037 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
11038         LDKUnsignedChannelUpdate this_ptr_conv;
11039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11040         this_ptr_conv.is_owned = false;
11041         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11042         memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
11043         return ret_arr;
11044 }
11045
11046 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11047         LDKUnsignedChannelUpdate this_ptr_conv;
11048         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11049         this_ptr_conv.is_owned = false;
11050         LDKThirtyTwoBytes val_ref;
11051         CHECK(*((uint32_t*)val) == 32);
11052         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11053         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
11054 }
11055
11056 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
11057         LDKUnsignedChannelUpdate this_ptr_conv;
11058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11059         this_ptr_conv.is_owned = false;
11060         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
11061         return ret_val;
11062 }
11063
11064 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
11065         LDKUnsignedChannelUpdate this_ptr_conv;
11066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11067         this_ptr_conv.is_owned = false;
11068         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
11069 }
11070
11071 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
11072         LDKUnsignedChannelUpdate this_ptr_conv;
11073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11074         this_ptr_conv.is_owned = false;
11075         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
11076         return ret_val;
11077 }
11078
11079 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
11080         LDKUnsignedChannelUpdate this_ptr_conv;
11081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11082         this_ptr_conv.is_owned = false;
11083         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
11084 }
11085
11086 int8_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
11087         LDKUnsignedChannelUpdate this_ptr_conv;
11088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11089         this_ptr_conv.is_owned = false;
11090         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
11091         return ret_val;
11092 }
11093
11094 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
11095         LDKUnsignedChannelUpdate this_ptr_conv;
11096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11097         this_ptr_conv.is_owned = false;
11098         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
11099 }
11100
11101 int16_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
11102         LDKUnsignedChannelUpdate this_ptr_conv;
11103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11104         this_ptr_conv.is_owned = false;
11105         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
11106         return ret_val;
11107 }
11108
11109 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
11110         LDKUnsignedChannelUpdate this_ptr_conv;
11111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11112         this_ptr_conv.is_owned = false;
11113         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
11114 }
11115
11116 int64_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
11117         LDKUnsignedChannelUpdate this_ptr_conv;
11118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11119         this_ptr_conv.is_owned = false;
11120         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
11121         return ret_val;
11122 }
11123
11124 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
11125         LDKUnsignedChannelUpdate this_ptr_conv;
11126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11127         this_ptr_conv.is_owned = false;
11128         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
11129 }
11130
11131 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
11132         LDKUnsignedChannelUpdate this_ptr_conv;
11133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11134         this_ptr_conv.is_owned = false;
11135         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
11136         return ret_val;
11137 }
11138
11139 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
11140         LDKUnsignedChannelUpdate this_ptr_conv;
11141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11142         this_ptr_conv.is_owned = false;
11143         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
11144 }
11145
11146 int32_t  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
11147         LDKUnsignedChannelUpdate this_ptr_conv;
11148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11149         this_ptr_conv.is_owned = false;
11150         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
11151         return ret_val;
11152 }
11153
11154 void  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
11155         LDKUnsignedChannelUpdate this_ptr_conv;
11156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11157         this_ptr_conv.is_owned = false;
11158         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
11159 }
11160
11161 void  __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_ptr) {
11162         LDKChannelUpdate this_ptr_conv;
11163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11164         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11165         ChannelUpdate_free(this_ptr_conv);
11166 }
11167
11168 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
11169         LDKChannelUpdate orig_conv;
11170         orig_conv.inner = (void*)(orig & (~1));
11171         orig_conv.is_owned = false;
11172         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
11173         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11174         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11175         long ret_ref = (long)ret_var.inner;
11176         if (ret_var.is_owned) {
11177                 ret_ref |= 1;
11178         }
11179         return ret_ref;
11180 }
11181
11182 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
11183         LDKChannelUpdate this_ptr_conv;
11184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11185         this_ptr_conv.is_owned = false;
11186         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
11187         memcpy((uint8_t*)(arg_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
11188         return arg_arr;
11189 }
11190
11191 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
11192         LDKChannelUpdate this_ptr_conv;
11193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11194         this_ptr_conv.is_owned = false;
11195         LDKSignature val_ref;
11196         CHECK(*((uint32_t*)val) == 64);
11197         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
11198         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
11199 }
11200
11201 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
11202         LDKChannelUpdate this_ptr_conv;
11203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11204         this_ptr_conv.is_owned = false;
11205         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
11206         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11207         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11208         long ret_ref = (long)ret_var.inner;
11209         if (ret_var.is_owned) {
11210                 ret_ref |= 1;
11211         }
11212         return ret_ref;
11213 }
11214
11215 void  __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
11216         LDKChannelUpdate this_ptr_conv;
11217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11218         this_ptr_conv.is_owned = false;
11219         LDKUnsignedChannelUpdate val_conv;
11220         val_conv.inner = (void*)(val & (~1));
11221         val_conv.is_owned = (val & 1) || (val == 0);
11222         val_conv = UnsignedChannelUpdate_clone(&val_conv);
11223         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
11224 }
11225
11226 uint32_t  __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
11227         LDKSignature signature_arg_ref;
11228         CHECK(*((uint32_t*)signature_arg) == 64);
11229         memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
11230         LDKUnsignedChannelUpdate contents_arg_conv;
11231         contents_arg_conv.inner = (void*)(contents_arg & (~1));
11232         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
11233         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
11234         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
11235         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11236         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11237         long ret_ref = (long)ret_var.inner;
11238         if (ret_var.is_owned) {
11239                 ret_ref |= 1;
11240         }
11241         return ret_ref;
11242 }
11243
11244 void  __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_ptr) {
11245         LDKQueryChannelRange this_ptr_conv;
11246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11247         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11248         QueryChannelRange_free(this_ptr_conv);
11249 }
11250
11251 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
11252         LDKQueryChannelRange orig_conv;
11253         orig_conv.inner = (void*)(orig & (~1));
11254         orig_conv.is_owned = false;
11255         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
11256         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11257         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11258         long ret_ref = (long)ret_var.inner;
11259         if (ret_var.is_owned) {
11260                 ret_ref |= 1;
11261         }
11262         return ret_ref;
11263 }
11264
11265 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
11266         LDKQueryChannelRange this_ptr_conv;
11267         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11268         this_ptr_conv.is_owned = false;
11269         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11270         memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
11271         return ret_arr;
11272 }
11273
11274 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11275         LDKQueryChannelRange this_ptr_conv;
11276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11277         this_ptr_conv.is_owned = false;
11278         LDKThirtyTwoBytes val_ref;
11279         CHECK(*((uint32_t*)val) == 32);
11280         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11281         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
11282 }
11283
11284 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
11285         LDKQueryChannelRange this_ptr_conv;
11286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11287         this_ptr_conv.is_owned = false;
11288         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
11289         return ret_val;
11290 }
11291
11292 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
11293         LDKQueryChannelRange this_ptr_conv;
11294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11295         this_ptr_conv.is_owned = false;
11296         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
11297 }
11298
11299 int32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
11300         LDKQueryChannelRange this_ptr_conv;
11301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11302         this_ptr_conv.is_owned = false;
11303         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
11304         return ret_val;
11305 }
11306
11307 void  __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
11308         LDKQueryChannelRange this_ptr_conv;
11309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11310         this_ptr_conv.is_owned = false;
11311         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
11312 }
11313
11314 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
11315         LDKThirtyTwoBytes chain_hash_arg_ref;
11316         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11317         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11318         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
11319         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11320         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11321         long ret_ref = (long)ret_var.inner;
11322         if (ret_var.is_owned) {
11323                 ret_ref |= 1;
11324         }
11325         return ret_ref;
11326 }
11327
11328 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_ptr) {
11329         LDKReplyChannelRange this_ptr_conv;
11330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11331         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11332         ReplyChannelRange_free(this_ptr_conv);
11333 }
11334
11335 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
11336         LDKReplyChannelRange orig_conv;
11337         orig_conv.inner = (void*)(orig & (~1));
11338         orig_conv.is_owned = false;
11339         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
11340         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11341         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11342         long ret_ref = (long)ret_var.inner;
11343         if (ret_var.is_owned) {
11344                 ret_ref |= 1;
11345         }
11346         return ret_ref;
11347 }
11348
11349 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
11350         LDKReplyChannelRange this_ptr_conv;
11351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11352         this_ptr_conv.is_owned = false;
11353         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11354         memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
11355         return ret_arr;
11356 }
11357
11358 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11359         LDKReplyChannelRange this_ptr_conv;
11360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11361         this_ptr_conv.is_owned = false;
11362         LDKThirtyTwoBytes val_ref;
11363         CHECK(*((uint32_t*)val) == 32);
11364         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11365         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
11366 }
11367
11368 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
11369         LDKReplyChannelRange this_ptr_conv;
11370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11371         this_ptr_conv.is_owned = false;
11372         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
11373         return ret_val;
11374 }
11375
11376 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
11377         LDKReplyChannelRange this_ptr_conv;
11378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11379         this_ptr_conv.is_owned = false;
11380         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
11381 }
11382
11383 int32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
11384         LDKReplyChannelRange this_ptr_conv;
11385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11386         this_ptr_conv.is_owned = false;
11387         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
11388         return ret_val;
11389 }
11390
11391 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
11392         LDKReplyChannelRange this_ptr_conv;
11393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11394         this_ptr_conv.is_owned = false;
11395         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
11396 }
11397
11398 jboolean  __attribute__((visibility("default"))) TS_ReplyChannelRange_get_full_information(uint32_t this_ptr) {
11399         LDKReplyChannelRange this_ptr_conv;
11400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11401         this_ptr_conv.is_owned = false;
11402         jboolean ret_val = ReplyChannelRange_get_full_information(&this_ptr_conv);
11403         return ret_val;
11404 }
11405
11406 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_full_information(uint32_t this_ptr, jboolean val) {
11407         LDKReplyChannelRange this_ptr_conv;
11408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11409         this_ptr_conv.is_owned = false;
11410         ReplyChannelRange_set_full_information(&this_ptr_conv, val);
11411 }
11412
11413 void  __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
11414         LDKReplyChannelRange this_ptr_conv;
11415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11416         this_ptr_conv.is_owned = false;
11417         LDKCVec_u64Z val_constr;
11418         val_constr.datalen = *((uint32_t*)val);
11419         if (val_constr.datalen > 0)
11420                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11421         else
11422                 val_constr.data = NULL;
11423         int64_t* val_vals = (int64_t*)(val + 4);
11424         for (size_t i = 0; i < val_constr.datalen; i++) {
11425                 int64_t arr_conv_8 = val_vals[i];
11426                 val_constr.data[i] = arr_conv_8;
11427         }
11428         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
11429 }
11430
11431 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) {
11432         LDKThirtyTwoBytes chain_hash_arg_ref;
11433         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11434         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11435         LDKCVec_u64Z short_channel_ids_arg_constr;
11436         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
11437         if (short_channel_ids_arg_constr.datalen > 0)
11438                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11439         else
11440                 short_channel_ids_arg_constr.data = NULL;
11441         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
11442         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
11443                 int64_t arr_conv_8 = short_channel_ids_arg_vals[i];
11444                 short_channel_ids_arg_constr.data[i] = arr_conv_8;
11445         }
11446         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr);
11447         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11448         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11449         long ret_ref = (long)ret_var.inner;
11450         if (ret_var.is_owned) {
11451                 ret_ref |= 1;
11452         }
11453         return ret_ref;
11454 }
11455
11456 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_ptr) {
11457         LDKQueryShortChannelIds this_ptr_conv;
11458         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11459         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11460         QueryShortChannelIds_free(this_ptr_conv);
11461 }
11462
11463 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
11464         LDKQueryShortChannelIds orig_conv;
11465         orig_conv.inner = (void*)(orig & (~1));
11466         orig_conv.is_owned = false;
11467         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
11468         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11469         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11470         long ret_ref = (long)ret_var.inner;
11471         if (ret_var.is_owned) {
11472                 ret_ref |= 1;
11473         }
11474         return ret_ref;
11475 }
11476
11477 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
11478         LDKQueryShortChannelIds this_ptr_conv;
11479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11480         this_ptr_conv.is_owned = false;
11481         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11482         memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
11483         return ret_arr;
11484 }
11485
11486 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11487         LDKQueryShortChannelIds this_ptr_conv;
11488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11489         this_ptr_conv.is_owned = false;
11490         LDKThirtyTwoBytes val_ref;
11491         CHECK(*((uint32_t*)val) == 32);
11492         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11493         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
11494 }
11495
11496 void  __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
11497         LDKQueryShortChannelIds this_ptr_conv;
11498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11499         this_ptr_conv.is_owned = false;
11500         LDKCVec_u64Z val_constr;
11501         val_constr.datalen = *((uint32_t*)val);
11502         if (val_constr.datalen > 0)
11503                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11504         else
11505                 val_constr.data = NULL;
11506         int64_t* val_vals = (int64_t*)(val + 4);
11507         for (size_t i = 0; i < val_constr.datalen; i++) {
11508                 int64_t arr_conv_8 = val_vals[i];
11509                 val_constr.data[i] = arr_conv_8;
11510         }
11511         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
11512 }
11513
11514 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
11515         LDKThirtyTwoBytes chain_hash_arg_ref;
11516         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11517         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11518         LDKCVec_u64Z short_channel_ids_arg_constr;
11519         short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
11520         if (short_channel_ids_arg_constr.datalen > 0)
11521                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11522         else
11523                 short_channel_ids_arg_constr.data = NULL;
11524         int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
11525         for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
11526                 int64_t arr_conv_8 = short_channel_ids_arg_vals[i];
11527                 short_channel_ids_arg_constr.data[i] = arr_conv_8;
11528         }
11529         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
11530         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11531         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11532         long ret_ref = (long)ret_var.inner;
11533         if (ret_var.is_owned) {
11534                 ret_ref |= 1;
11535         }
11536         return ret_ref;
11537 }
11538
11539 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_ptr) {
11540         LDKReplyShortChannelIdsEnd this_ptr_conv;
11541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11542         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11543         ReplyShortChannelIdsEnd_free(this_ptr_conv);
11544 }
11545
11546 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
11547         LDKReplyShortChannelIdsEnd orig_conv;
11548         orig_conv.inner = (void*)(orig & (~1));
11549         orig_conv.is_owned = false;
11550         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
11551         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11552         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11553         long ret_ref = (long)ret_var.inner;
11554         if (ret_var.is_owned) {
11555                 ret_ref |= 1;
11556         }
11557         return ret_ref;
11558 }
11559
11560 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
11561         LDKReplyShortChannelIdsEnd this_ptr_conv;
11562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11563         this_ptr_conv.is_owned = false;
11564         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11565         memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
11566         return ret_arr;
11567 }
11568
11569 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11570         LDKReplyShortChannelIdsEnd this_ptr_conv;
11571         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11572         this_ptr_conv.is_owned = false;
11573         LDKThirtyTwoBytes val_ref;
11574         CHECK(*((uint32_t*)val) == 32);
11575         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11576         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
11577 }
11578
11579 jboolean  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
11580         LDKReplyShortChannelIdsEnd this_ptr_conv;
11581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11582         this_ptr_conv.is_owned = false;
11583         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
11584         return ret_val;
11585 }
11586
11587 void  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
11588         LDKReplyShortChannelIdsEnd this_ptr_conv;
11589         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11590         this_ptr_conv.is_owned = false;
11591         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
11592 }
11593
11594 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
11595         LDKThirtyTwoBytes chain_hash_arg_ref;
11596         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11597         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11598         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
11599         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11600         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11601         long ret_ref = (long)ret_var.inner;
11602         if (ret_var.is_owned) {
11603                 ret_ref |= 1;
11604         }
11605         return ret_ref;
11606 }
11607
11608 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_ptr) {
11609         LDKGossipTimestampFilter this_ptr_conv;
11610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11611         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11612         GossipTimestampFilter_free(this_ptr_conv);
11613 }
11614
11615 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
11616         LDKGossipTimestampFilter orig_conv;
11617         orig_conv.inner = (void*)(orig & (~1));
11618         orig_conv.is_owned = false;
11619         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
11620         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11621         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11622         long ret_ref = (long)ret_var.inner;
11623         if (ret_var.is_owned) {
11624                 ret_ref |= 1;
11625         }
11626         return ret_ref;
11627 }
11628
11629 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
11630         LDKGossipTimestampFilter this_ptr_conv;
11631         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11632         this_ptr_conv.is_owned = false;
11633         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11634         memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
11635         return ret_arr;
11636 }
11637
11638 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11639         LDKGossipTimestampFilter this_ptr_conv;
11640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11641         this_ptr_conv.is_owned = false;
11642         LDKThirtyTwoBytes val_ref;
11643         CHECK(*((uint32_t*)val) == 32);
11644         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11645         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
11646 }
11647
11648 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
11649         LDKGossipTimestampFilter this_ptr_conv;
11650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11651         this_ptr_conv.is_owned = false;
11652         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
11653         return ret_val;
11654 }
11655
11656 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
11657         LDKGossipTimestampFilter this_ptr_conv;
11658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11659         this_ptr_conv.is_owned = false;
11660         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
11661 }
11662
11663 int32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
11664         LDKGossipTimestampFilter this_ptr_conv;
11665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11666         this_ptr_conv.is_owned = false;
11667         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
11668         return ret_val;
11669 }
11670
11671 void  __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
11672         LDKGossipTimestampFilter this_ptr_conv;
11673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11674         this_ptr_conv.is_owned = false;
11675         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
11676 }
11677
11678 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
11679         LDKThirtyTwoBytes chain_hash_arg_ref;
11680         CHECK(*((uint32_t*)chain_hash_arg) == 32);
11681         memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11682         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
11683         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11684         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11685         long ret_ref = (long)ret_var.inner;
11686         if (ret_var.is_owned) {
11687                 ret_ref |= 1;
11688         }
11689         return ret_ref;
11690 }
11691
11692 void  __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
11693         if ((this_ptr & 1) != 0) return;
11694         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(((uint64_t)this_ptr) & ~1);
11695         FREE((void*)this_ptr);
11696         ErrorAction_free(this_ptr_conv);
11697 }
11698
11699 uint32_t  __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
11700         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
11701         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
11702         *ret_copy = ErrorAction_clone(orig_conv);
11703         long ret_ref = (long)ret_copy;
11704         return ret_ref;
11705 }
11706
11707 void  __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_ptr) {
11708         LDKLightningError this_ptr_conv;
11709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11710         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11711         LightningError_free(this_ptr_conv);
11712 }
11713
11714 uint32_t  __attribute__((visibility("default"))) TS_LightningError_clone(uint32_t orig) {
11715         LDKLightningError orig_conv;
11716         orig_conv.inner = (void*)(orig & (~1));
11717         orig_conv.is_owned = false;
11718         LDKLightningError ret_var = LightningError_clone(&orig_conv);
11719         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11720         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11721         long ret_ref = (long)ret_var.inner;
11722         if (ret_var.is_owned) {
11723                 ret_ref |= 1;
11724         }
11725         return ret_ref;
11726 }
11727
11728 jstring  __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
11729         LDKLightningError this_ptr_conv;
11730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11731         this_ptr_conv.is_owned = false;
11732         LDKStr _str = LightningError_get_err(&this_ptr_conv);
11733         jstring _conv = str_ref_to_ts(_str.chars, _str.len);
11734         return _conv;
11735 }
11736
11737 void  __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, int8_tArray val) {
11738         LDKLightningError this_ptr_conv;
11739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11740         this_ptr_conv.is_owned = false;
11741         LDKCVec_u8Z val_ref;
11742         val_ref.datalen = *((uint32_t*)val);
11743         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11744         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11745         LightningError_set_err(&this_ptr_conv, val_ref);
11746 }
11747
11748 uint32_t  __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
11749         LDKLightningError this_ptr_conv;
11750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11751         this_ptr_conv.is_owned = false;
11752         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
11753         *ret_copy = LightningError_get_action(&this_ptr_conv);
11754         long ret_ref = (long)ret_copy;
11755         return ret_ref;
11756 }
11757
11758 void  __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
11759         LDKLightningError this_ptr_conv;
11760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11761         this_ptr_conv.is_owned = false;
11762         LDKErrorAction val_conv = *(LDKErrorAction*)(((uint64_t)val) & ~1);
11763         FREE((void*)val);
11764         LightningError_set_action(&this_ptr_conv, val_conv);
11765 }
11766
11767 uint32_t  __attribute__((visibility("default"))) TS_LightningError_new(int8_tArray err_arg, uint32_t action_arg) {
11768         LDKCVec_u8Z err_arg_ref;
11769         err_arg_ref.datalen = *((uint32_t*)err_arg);
11770         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11771         memcpy(err_arg_ref.data, (uint8_t*)(err_arg + 4), err_arg_ref.datalen);
11772         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(((uint64_t)action_arg) & ~1);
11773         FREE((void*)action_arg);
11774         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
11775         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11776         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11777         long ret_ref = (long)ret_var.inner;
11778         if (ret_var.is_owned) {
11779                 ret_ref |= 1;
11780         }
11781         return ret_ref;
11782 }
11783
11784 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_ptr) {
11785         LDKCommitmentUpdate this_ptr_conv;
11786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11787         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11788         CommitmentUpdate_free(this_ptr_conv);
11789 }
11790
11791 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
11792         LDKCommitmentUpdate orig_conv;
11793         orig_conv.inner = (void*)(orig & (~1));
11794         orig_conv.is_owned = false;
11795         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
11796         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11797         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11798         long ret_ref = (long)ret_var.inner;
11799         if (ret_var.is_owned) {
11800                 ret_ref |= 1;
11801         }
11802         return ret_ref;
11803 }
11804
11805 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
11806         LDKCommitmentUpdate this_ptr_conv;
11807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11808         this_ptr_conv.is_owned = false;
11809         LDKCVec_UpdateAddHTLCZ val_constr;
11810         val_constr.datalen = *((uint32_t*)val);
11811         if (val_constr.datalen > 0)
11812                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11813         else
11814                 val_constr.data = NULL;
11815         uint32_t* val_vals = (uint32_t*)(val + 4);
11816         for (size_t p = 0; p < val_constr.datalen; p++) {
11817                 uint32_t arr_conv_15 = val_vals[p];
11818                 LDKUpdateAddHTLC arr_conv_15_conv;
11819                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
11820                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
11821                 arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
11822                 val_constr.data[p] = arr_conv_15_conv;
11823         }
11824         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
11825 }
11826
11827 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
11828         LDKCommitmentUpdate this_ptr_conv;
11829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11830         this_ptr_conv.is_owned = false;
11831         LDKCVec_UpdateFulfillHTLCZ val_constr;
11832         val_constr.datalen = *((uint32_t*)val);
11833         if (val_constr.datalen > 0)
11834                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11835         else
11836                 val_constr.data = NULL;
11837         uint32_t* val_vals = (uint32_t*)(val + 4);
11838         for (size_t t = 0; t < val_constr.datalen; t++) {
11839                 uint32_t arr_conv_19 = val_vals[t];
11840                 LDKUpdateFulfillHTLC arr_conv_19_conv;
11841                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
11842                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
11843                 arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
11844                 val_constr.data[t] = arr_conv_19_conv;
11845         }
11846         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
11847 }
11848
11849 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
11850         LDKCommitmentUpdate this_ptr_conv;
11851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11852         this_ptr_conv.is_owned = false;
11853         LDKCVec_UpdateFailHTLCZ val_constr;
11854         val_constr.datalen = *((uint32_t*)val);
11855         if (val_constr.datalen > 0)
11856                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11857         else
11858                 val_constr.data = NULL;
11859         uint32_t* val_vals = (uint32_t*)(val + 4);
11860         for (size_t q = 0; q < val_constr.datalen; q++) {
11861                 uint32_t arr_conv_16 = val_vals[q];
11862                 LDKUpdateFailHTLC arr_conv_16_conv;
11863                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
11864                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
11865                 arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
11866                 val_constr.data[q] = arr_conv_16_conv;
11867         }
11868         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
11869 }
11870
11871 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
11872         LDKCommitmentUpdate this_ptr_conv;
11873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11874         this_ptr_conv.is_owned = false;
11875         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
11876         val_constr.datalen = *((uint32_t*)val);
11877         if (val_constr.datalen > 0)
11878                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11879         else
11880                 val_constr.data = NULL;
11881         uint32_t* val_vals = (uint32_t*)(val + 4);
11882         for (size_t z = 0; z < val_constr.datalen; z++) {
11883                 uint32_t arr_conv_25 = val_vals[z];
11884                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
11885                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
11886                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
11887                 arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
11888                 val_constr.data[z] = arr_conv_25_conv;
11889         }
11890         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
11891 }
11892
11893 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
11894         LDKCommitmentUpdate this_ptr_conv;
11895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11896         this_ptr_conv.is_owned = false;
11897         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
11898         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11899         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11900         long ret_ref = (long)ret_var.inner;
11901         if (ret_var.is_owned) {
11902                 ret_ref |= 1;
11903         }
11904         return ret_ref;
11905 }
11906
11907 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
11908         LDKCommitmentUpdate this_ptr_conv;
11909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11910         this_ptr_conv.is_owned = false;
11911         LDKUpdateFee val_conv;
11912         val_conv.inner = (void*)(val & (~1));
11913         val_conv.is_owned = (val & 1) || (val == 0);
11914         val_conv = UpdateFee_clone(&val_conv);
11915         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
11916 }
11917
11918 uint32_t  __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
11919         LDKCommitmentUpdate this_ptr_conv;
11920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11921         this_ptr_conv.is_owned = false;
11922         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
11923         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11924         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11925         long ret_ref = (long)ret_var.inner;
11926         if (ret_var.is_owned) {
11927                 ret_ref |= 1;
11928         }
11929         return ret_ref;
11930 }
11931
11932 void  __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
11933         LDKCommitmentUpdate this_ptr_conv;
11934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11935         this_ptr_conv.is_owned = false;
11936         LDKCommitmentSigned val_conv;
11937         val_conv.inner = (void*)(val & (~1));
11938         val_conv.is_owned = (val & 1) || (val == 0);
11939         val_conv = CommitmentSigned_clone(&val_conv);
11940         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
11941 }
11942
11943 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) {
11944         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
11945         update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
11946         if (update_add_htlcs_arg_constr.datalen > 0)
11947                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11948         else
11949                 update_add_htlcs_arg_constr.data = NULL;
11950         uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
11951         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
11952                 uint32_t arr_conv_15 = update_add_htlcs_arg_vals[p];
11953                 LDKUpdateAddHTLC arr_conv_15_conv;
11954                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
11955                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
11956                 arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
11957                 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
11958         }
11959         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
11960         update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
11961         if (update_fulfill_htlcs_arg_constr.datalen > 0)
11962                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11963         else
11964                 update_fulfill_htlcs_arg_constr.data = NULL;
11965         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
11966         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
11967                 uint32_t arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
11968                 LDKUpdateFulfillHTLC arr_conv_19_conv;
11969                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
11970                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
11971                 arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
11972                 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
11973         }
11974         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
11975         update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
11976         if (update_fail_htlcs_arg_constr.datalen > 0)
11977                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11978         else
11979                 update_fail_htlcs_arg_constr.data = NULL;
11980         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
11981         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
11982                 uint32_t arr_conv_16 = update_fail_htlcs_arg_vals[q];
11983                 LDKUpdateFailHTLC arr_conv_16_conv;
11984                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
11985                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
11986                 arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
11987                 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
11988         }
11989         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
11990         update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
11991         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
11992                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11993         else
11994                 update_fail_malformed_htlcs_arg_constr.data = NULL;
11995         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
11996         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
11997                 uint32_t arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
11998                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
11999                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
12000                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
12001                 arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
12002                 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
12003         }
12004         LDKUpdateFee update_fee_arg_conv;
12005         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
12006         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
12007         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
12008         LDKCommitmentSigned commitment_signed_arg_conv;
12009         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
12010         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
12011         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
12012         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);
12013         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12014         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12015         long ret_ref = (long)ret_var.inner;
12016         if (ret_var.is_owned) {
12017                 ret_ref |= 1;
12018         }
12019         return ret_ref;
12020 }
12021
12022 void  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
12023         if ((this_ptr & 1) != 0) return;
12024         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)(((uint64_t)this_ptr) & ~1);
12025         FREE((void*)this_ptr);
12026         HTLCFailChannelUpdate_free(this_ptr_conv);
12027 }
12028
12029 uint32_t  __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
12030         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
12031         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
12032         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
12033         long ret_ref = (long)ret_copy;
12034         return ret_ref;
12035 }
12036
12037 void  __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
12038         if ((this_ptr & 1) != 0) return;
12039         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(((uint64_t)this_ptr) & ~1);
12040         FREE((void*)this_ptr);
12041         ChannelMessageHandler_free(this_ptr_conv);
12042 }
12043
12044 void  __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
12045         if ((this_ptr & 1) != 0) return;
12046         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(((uint64_t)this_ptr) & ~1);
12047         FREE((void*)this_ptr);
12048         RoutingMessageHandler_free(this_ptr_conv);
12049 }
12050
12051 int8_tArray  __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
12052         LDKAcceptChannel obj_conv;
12053         obj_conv.inner = (void*)(obj & (~1));
12054         obj_conv.is_owned = false;
12055         LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
12056         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12057         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12058         CVec_u8Z_free(arg_var);
12059         return arg_arr;
12060 }
12061
12062 uint32_t  __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
12063         LDKu8slice ser_ref;
12064         ser_ref.datalen = *((uint32_t*)ser);
12065         ser_ref.data = (int8_t*)(ser + 4);
12066         LDKAcceptChannel ret_var = AcceptChannel_read(ser_ref);
12067         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12068         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12069         long ret_ref = (long)ret_var.inner;
12070         if (ret_var.is_owned) {
12071                 ret_ref |= 1;
12072         }
12073         return ret_ref;
12074 }
12075
12076 int8_tArray  __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
12077         LDKAnnouncementSignatures obj_conv;
12078         obj_conv.inner = (void*)(obj & (~1));
12079         obj_conv.is_owned = false;
12080         LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
12081         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12082         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12083         CVec_u8Z_free(arg_var);
12084         return arg_arr;
12085 }
12086
12087 uint32_t  __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
12088         LDKu8slice ser_ref;
12089         ser_ref.datalen = *((uint32_t*)ser);
12090         ser_ref.data = (int8_t*)(ser + 4);
12091         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_read(ser_ref);
12092         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12093         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12094         long ret_ref = (long)ret_var.inner;
12095         if (ret_var.is_owned) {
12096                 ret_ref |= 1;
12097         }
12098         return ret_ref;
12099 }
12100
12101 int8_tArray  __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
12102         LDKChannelReestablish obj_conv;
12103         obj_conv.inner = (void*)(obj & (~1));
12104         obj_conv.is_owned = false;
12105         LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
12106         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12107         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12108         CVec_u8Z_free(arg_var);
12109         return arg_arr;
12110 }
12111
12112 uint32_t  __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
12113         LDKu8slice ser_ref;
12114         ser_ref.datalen = *((uint32_t*)ser);
12115         ser_ref.data = (int8_t*)(ser + 4);
12116         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12117         *ret_conv = ChannelReestablish_read(ser_ref);
12118         return (long)ret_conv;
12119 }
12120
12121 int8_tArray  __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
12122         LDKClosingSigned obj_conv;
12123         obj_conv.inner = (void*)(obj & (~1));
12124         obj_conv.is_owned = false;
12125         LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
12126         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12127         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12128         CVec_u8Z_free(arg_var);
12129         return arg_arr;
12130 }
12131
12132 uint32_t  __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
12133         LDKu8slice ser_ref;
12134         ser_ref.datalen = *((uint32_t*)ser);
12135         ser_ref.data = (int8_t*)(ser + 4);
12136         LDKClosingSigned ret_var = ClosingSigned_read(ser_ref);
12137         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12138         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12139         long ret_ref = (long)ret_var.inner;
12140         if (ret_var.is_owned) {
12141                 ret_ref |= 1;
12142         }
12143         return ret_ref;
12144 }
12145
12146 int8_tArray  __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
12147         LDKCommitmentSigned obj_conv;
12148         obj_conv.inner = (void*)(obj & (~1));
12149         obj_conv.is_owned = false;
12150         LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
12151         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12152         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12153         CVec_u8Z_free(arg_var);
12154         return arg_arr;
12155 }
12156
12157 uint32_t  __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
12158         LDKu8slice ser_ref;
12159         ser_ref.datalen = *((uint32_t*)ser);
12160         ser_ref.data = (int8_t*)(ser + 4);
12161         LDKCommitmentSigned ret_var = CommitmentSigned_read(ser_ref);
12162         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12163         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12164         long ret_ref = (long)ret_var.inner;
12165         if (ret_var.is_owned) {
12166                 ret_ref |= 1;
12167         }
12168         return ret_ref;
12169 }
12170
12171 int8_tArray  __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
12172         LDKFundingCreated obj_conv;
12173         obj_conv.inner = (void*)(obj & (~1));
12174         obj_conv.is_owned = false;
12175         LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
12176         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12177         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12178         CVec_u8Z_free(arg_var);
12179         return arg_arr;
12180 }
12181
12182 uint32_t  __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
12183         LDKu8slice ser_ref;
12184         ser_ref.datalen = *((uint32_t*)ser);
12185         ser_ref.data = (int8_t*)(ser + 4);
12186         LDKFundingCreated ret_var = FundingCreated_read(ser_ref);
12187         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12188         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12189         long ret_ref = (long)ret_var.inner;
12190         if (ret_var.is_owned) {
12191                 ret_ref |= 1;
12192         }
12193         return ret_ref;
12194 }
12195
12196 int8_tArray  __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
12197         LDKFundingSigned obj_conv;
12198         obj_conv.inner = (void*)(obj & (~1));
12199         obj_conv.is_owned = false;
12200         LDKCVec_u8Z arg_var = FundingSigned_write(&obj_conv);
12201         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12202         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12203         CVec_u8Z_free(arg_var);
12204         return arg_arr;
12205 }
12206
12207 uint32_t  __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
12208         LDKu8slice ser_ref;
12209         ser_ref.datalen = *((uint32_t*)ser);
12210         ser_ref.data = (int8_t*)(ser + 4);
12211         LDKFundingSigned ret_var = FundingSigned_read(ser_ref);
12212         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12213         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12214         long ret_ref = (long)ret_var.inner;
12215         if (ret_var.is_owned) {
12216                 ret_ref |= 1;
12217         }
12218         return ret_ref;
12219 }
12220
12221 int8_tArray  __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
12222         LDKFundingLocked obj_conv;
12223         obj_conv.inner = (void*)(obj & (~1));
12224         obj_conv.is_owned = false;
12225         LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
12226         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12227         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12228         CVec_u8Z_free(arg_var);
12229         return arg_arr;
12230 }
12231
12232 uint32_t  __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
12233         LDKu8slice ser_ref;
12234         ser_ref.datalen = *((uint32_t*)ser);
12235         ser_ref.data = (int8_t*)(ser + 4);
12236         LDKFundingLocked ret_var = FundingLocked_read(ser_ref);
12237         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12238         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12239         long ret_ref = (long)ret_var.inner;
12240         if (ret_var.is_owned) {
12241                 ret_ref |= 1;
12242         }
12243         return ret_ref;
12244 }
12245
12246 int8_tArray  __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
12247         LDKInit obj_conv;
12248         obj_conv.inner = (void*)(obj & (~1));
12249         obj_conv.is_owned = false;
12250         LDKCVec_u8Z arg_var = Init_write(&obj_conv);
12251         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12252         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12253         CVec_u8Z_free(arg_var);
12254         return arg_arr;
12255 }
12256
12257 uint32_t  __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
12258         LDKu8slice ser_ref;
12259         ser_ref.datalen = *((uint32_t*)ser);
12260         ser_ref.data = (int8_t*)(ser + 4);
12261         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12262         *ret_conv = Init_read(ser_ref);
12263         return (long)ret_conv;
12264 }
12265
12266 int8_tArray  __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
12267         LDKOpenChannel obj_conv;
12268         obj_conv.inner = (void*)(obj & (~1));
12269         obj_conv.is_owned = false;
12270         LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
12271         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12272         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12273         CVec_u8Z_free(arg_var);
12274         return arg_arr;
12275 }
12276
12277 uint32_t  __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
12278         LDKu8slice ser_ref;
12279         ser_ref.datalen = *((uint32_t*)ser);
12280         ser_ref.data = (int8_t*)(ser + 4);
12281         LDKOpenChannel ret_var = OpenChannel_read(ser_ref);
12282         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12283         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12284         long ret_ref = (long)ret_var.inner;
12285         if (ret_var.is_owned) {
12286                 ret_ref |= 1;
12287         }
12288         return ret_ref;
12289 }
12290
12291 int8_tArray  __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
12292         LDKRevokeAndACK obj_conv;
12293         obj_conv.inner = (void*)(obj & (~1));
12294         obj_conv.is_owned = false;
12295         LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
12296         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12297         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12298         CVec_u8Z_free(arg_var);
12299         return arg_arr;
12300 }
12301
12302 uint32_t  __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
12303         LDKu8slice ser_ref;
12304         ser_ref.datalen = *((uint32_t*)ser);
12305         ser_ref.data = (int8_t*)(ser + 4);
12306         LDKRevokeAndACK ret_var = RevokeAndACK_read(ser_ref);
12307         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12308         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12309         long ret_ref = (long)ret_var.inner;
12310         if (ret_var.is_owned) {
12311                 ret_ref |= 1;
12312         }
12313         return ret_ref;
12314 }
12315
12316 int8_tArray  __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
12317         LDKShutdown obj_conv;
12318         obj_conv.inner = (void*)(obj & (~1));
12319         obj_conv.is_owned = false;
12320         LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
12321         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12322         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12323         CVec_u8Z_free(arg_var);
12324         return arg_arr;
12325 }
12326
12327 uint32_t  __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
12328         LDKu8slice ser_ref;
12329         ser_ref.datalen = *((uint32_t*)ser);
12330         ser_ref.data = (int8_t*)(ser + 4);
12331         LDKShutdown ret_var = Shutdown_read(ser_ref);
12332         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12333         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12334         long ret_ref = (long)ret_var.inner;
12335         if (ret_var.is_owned) {
12336                 ret_ref |= 1;
12337         }
12338         return ret_ref;
12339 }
12340
12341 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
12342         LDKUpdateFailHTLC obj_conv;
12343         obj_conv.inner = (void*)(obj & (~1));
12344         obj_conv.is_owned = false;
12345         LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
12346         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12347         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12348         CVec_u8Z_free(arg_var);
12349         return arg_arr;
12350 }
12351
12352 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
12353         LDKu8slice ser_ref;
12354         ser_ref.datalen = *((uint32_t*)ser);
12355         ser_ref.data = (int8_t*)(ser + 4);
12356         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_read(ser_ref);
12357         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12358         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12359         long ret_ref = (long)ret_var.inner;
12360         if (ret_var.is_owned) {
12361                 ret_ref |= 1;
12362         }
12363         return ret_ref;
12364 }
12365
12366 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
12367         LDKUpdateFailMalformedHTLC obj_conv;
12368         obj_conv.inner = (void*)(obj & (~1));
12369         obj_conv.is_owned = false;
12370         LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
12371         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12372         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12373         CVec_u8Z_free(arg_var);
12374         return arg_arr;
12375 }
12376
12377 uint32_t  __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
12378         LDKu8slice ser_ref;
12379         ser_ref.datalen = *((uint32_t*)ser);
12380         ser_ref.data = (int8_t*)(ser + 4);
12381         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_read(ser_ref);
12382         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12383         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12384         long ret_ref = (long)ret_var.inner;
12385         if (ret_var.is_owned) {
12386                 ret_ref |= 1;
12387         }
12388         return ret_ref;
12389 }
12390
12391 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
12392         LDKUpdateFee obj_conv;
12393         obj_conv.inner = (void*)(obj & (~1));
12394         obj_conv.is_owned = false;
12395         LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
12396         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12397         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12398         CVec_u8Z_free(arg_var);
12399         return arg_arr;
12400 }
12401
12402 uint32_t  __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
12403         LDKu8slice ser_ref;
12404         ser_ref.datalen = *((uint32_t*)ser);
12405         ser_ref.data = (int8_t*)(ser + 4);
12406         LDKUpdateFee ret_var = UpdateFee_read(ser_ref);
12407         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12408         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12409         long ret_ref = (long)ret_var.inner;
12410         if (ret_var.is_owned) {
12411                 ret_ref |= 1;
12412         }
12413         return ret_ref;
12414 }
12415
12416 int8_tArray  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
12417         LDKUpdateFulfillHTLC obj_conv;
12418         obj_conv.inner = (void*)(obj & (~1));
12419         obj_conv.is_owned = false;
12420         LDKCVec_u8Z arg_var = UpdateFulfillHTLC_write(&obj_conv);
12421         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12422         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12423         CVec_u8Z_free(arg_var);
12424         return arg_arr;
12425 }
12426
12427 uint32_t  __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
12428         LDKu8slice ser_ref;
12429         ser_ref.datalen = *((uint32_t*)ser);
12430         ser_ref.data = (int8_t*)(ser + 4);
12431         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_read(ser_ref);
12432         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12433         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12434         long ret_ref = (long)ret_var.inner;
12435         if (ret_var.is_owned) {
12436                 ret_ref |= 1;
12437         }
12438         return ret_ref;
12439 }
12440
12441 int8_tArray  __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
12442         LDKUpdateAddHTLC obj_conv;
12443         obj_conv.inner = (void*)(obj & (~1));
12444         obj_conv.is_owned = false;
12445         LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
12446         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12447         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12448         CVec_u8Z_free(arg_var);
12449         return arg_arr;
12450 }
12451
12452 uint32_t  __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
12453         LDKu8slice ser_ref;
12454         ser_ref.datalen = *((uint32_t*)ser);
12455         ser_ref.data = (int8_t*)(ser + 4);
12456         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_read(ser_ref);
12457         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12458         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12459         long ret_ref = (long)ret_var.inner;
12460         if (ret_var.is_owned) {
12461                 ret_ref |= 1;
12462         }
12463         return ret_ref;
12464 }
12465
12466 int8_tArray  __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
12467         LDKPing obj_conv;
12468         obj_conv.inner = (void*)(obj & (~1));
12469         obj_conv.is_owned = false;
12470         LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
12471         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12472         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12473         CVec_u8Z_free(arg_var);
12474         return arg_arr;
12475 }
12476
12477 uint32_t  __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
12478         LDKu8slice ser_ref;
12479         ser_ref.datalen = *((uint32_t*)ser);
12480         ser_ref.data = (int8_t*)(ser + 4);
12481         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12482         *ret_conv = Ping_read(ser_ref);
12483         return (long)ret_conv;
12484 }
12485
12486 int8_tArray  __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
12487         LDKPong obj_conv;
12488         obj_conv.inner = (void*)(obj & (~1));
12489         obj_conv.is_owned = false;
12490         LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
12491         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12492         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12493         CVec_u8Z_free(arg_var);
12494         return arg_arr;
12495 }
12496
12497 uint32_t  __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
12498         LDKu8slice ser_ref;
12499         ser_ref.datalen = *((uint32_t*)ser);
12500         ser_ref.data = (int8_t*)(ser + 4);
12501         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12502         *ret_conv = Pong_read(ser_ref);
12503         return (long)ret_conv;
12504 }
12505
12506 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
12507         LDKUnsignedChannelAnnouncement obj_conv;
12508         obj_conv.inner = (void*)(obj & (~1));
12509         obj_conv.is_owned = false;
12510         LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_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_UnsignedChannelAnnouncement_read(int8_tArray ser) {
12518         LDKu8slice ser_ref;
12519         ser_ref.datalen = *((uint32_t*)ser);
12520         ser_ref.data = (int8_t*)(ser + 4);
12521         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12522         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
12523         return (long)ret_conv;
12524 }
12525
12526 int8_tArray  __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
12527         LDKChannelAnnouncement obj_conv;
12528         obj_conv.inner = (void*)(obj & (~1));
12529         obj_conv.is_owned = false;
12530         LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
12531         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12532         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12533         CVec_u8Z_free(arg_var);
12534         return arg_arr;
12535 }
12536
12537 uint32_t  __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
12538         LDKu8slice ser_ref;
12539         ser_ref.datalen = *((uint32_t*)ser);
12540         ser_ref.data = (int8_t*)(ser + 4);
12541         LDKChannelAnnouncement ret_var = ChannelAnnouncement_read(ser_ref);
12542         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12543         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12544         long ret_ref = (long)ret_var.inner;
12545         if (ret_var.is_owned) {
12546                 ret_ref |= 1;
12547         }
12548         return ret_ref;
12549 }
12550
12551 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
12552         LDKUnsignedChannelUpdate obj_conv;
12553         obj_conv.inner = (void*)(obj & (~1));
12554         obj_conv.is_owned = false;
12555         LDKCVec_u8Z arg_var = UnsignedChannelUpdate_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_UnsignedChannelUpdate_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_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12567         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
12568         return (long)ret_conv;
12569 }
12570
12571 int8_tArray  __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
12572         LDKChannelUpdate obj_conv;
12573         obj_conv.inner = (void*)(obj & (~1));
12574         obj_conv.is_owned = false;
12575         LDKCVec_u8Z arg_var = ChannelUpdate_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_ChannelUpdate_read(int8_tArray ser) {
12583         LDKu8slice ser_ref;
12584         ser_ref.datalen = *((uint32_t*)ser);
12585         ser_ref.data = (int8_t*)(ser + 4);
12586         LDKChannelUpdate ret_var = ChannelUpdate_read(ser_ref);
12587         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12588         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12589         long ret_ref = (long)ret_var.inner;
12590         if (ret_var.is_owned) {
12591                 ret_ref |= 1;
12592         }
12593         return ret_ref;
12594 }
12595
12596 int8_tArray  __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
12597         LDKErrorMessage obj_conv;
12598         obj_conv.inner = (void*)(obj & (~1));
12599         obj_conv.is_owned = false;
12600         LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
12601         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12602         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12603         CVec_u8Z_free(arg_var);
12604         return arg_arr;
12605 }
12606
12607 uint32_t  __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
12608         LDKu8slice ser_ref;
12609         ser_ref.datalen = *((uint32_t*)ser);
12610         ser_ref.data = (int8_t*)(ser + 4);
12611         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12612         *ret_conv = ErrorMessage_read(ser_ref);
12613         return (long)ret_conv;
12614 }
12615
12616 int8_tArray  __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
12617         LDKUnsignedNodeAnnouncement obj_conv;
12618         obj_conv.inner = (void*)(obj & (~1));
12619         obj_conv.is_owned = false;
12620         LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_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_UnsignedNodeAnnouncement_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_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12632         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
12633         return (long)ret_conv;
12634 }
12635
12636 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
12637         LDKNodeAnnouncement obj_conv;
12638         obj_conv.inner = (void*)(obj & (~1));
12639         obj_conv.is_owned = false;
12640         LDKCVec_u8Z arg_var = NodeAnnouncement_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_NodeAnnouncement_read(int8_tArray ser) {
12648         LDKu8slice ser_ref;
12649         ser_ref.datalen = *((uint32_t*)ser);
12650         ser_ref.data = (int8_t*)(ser + 4);
12651         LDKNodeAnnouncement ret_var = NodeAnnouncement_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 uint32_t  __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
12662         LDKu8slice ser_ref;
12663         ser_ref.datalen = *((uint32_t*)ser);
12664         ser_ref.data = (int8_t*)(ser + 4);
12665         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12666         *ret_conv = QueryShortChannelIds_read(ser_ref);
12667         return (long)ret_conv;
12668 }
12669
12670 int8_tArray  __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
12671         LDKQueryShortChannelIds obj_conv;
12672         obj_conv.inner = (void*)(obj & (~1));
12673         obj_conv.is_owned = false;
12674         LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
12675         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12676         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12677         CVec_u8Z_free(arg_var);
12678         return arg_arr;
12679 }
12680
12681 uint32_t  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
12682         LDKu8slice ser_ref;
12683         ser_ref.datalen = *((uint32_t*)ser);
12684         ser_ref.data = (int8_t*)(ser + 4);
12685         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12686         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
12687         return (long)ret_conv;
12688 }
12689
12690 int8_tArray  __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
12691         LDKReplyShortChannelIdsEnd obj_conv;
12692         obj_conv.inner = (void*)(obj & (~1));
12693         obj_conv.is_owned = false;
12694         LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
12695         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12696         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12697         CVec_u8Z_free(arg_var);
12698         return arg_arr;
12699 }
12700
12701 uint32_t  __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
12702         LDKu8slice ser_ref;
12703         ser_ref.datalen = *((uint32_t*)ser);
12704         ser_ref.data = (int8_t*)(ser + 4);
12705         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12706         *ret_conv = QueryChannelRange_read(ser_ref);
12707         return (long)ret_conv;
12708 }
12709
12710 int8_tArray  __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
12711         LDKQueryChannelRange obj_conv;
12712         obj_conv.inner = (void*)(obj & (~1));
12713         obj_conv.is_owned = false;
12714         LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
12715         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12716         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12717         CVec_u8Z_free(arg_var);
12718         return arg_arr;
12719 }
12720
12721 uint32_t  __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
12722         LDKu8slice ser_ref;
12723         ser_ref.datalen = *((uint32_t*)ser);
12724         ser_ref.data = (int8_t*)(ser + 4);
12725         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12726         *ret_conv = ReplyChannelRange_read(ser_ref);
12727         return (long)ret_conv;
12728 }
12729
12730 int8_tArray  __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
12731         LDKReplyChannelRange obj_conv;
12732         obj_conv.inner = (void*)(obj & (~1));
12733         obj_conv.is_owned = false;
12734         LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
12735         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12736         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12737         CVec_u8Z_free(arg_var);
12738         return arg_arr;
12739 }
12740
12741 uint32_t  __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
12742         LDKu8slice ser_ref;
12743         ser_ref.datalen = *((uint32_t*)ser);
12744         ser_ref.data = (int8_t*)(ser + 4);
12745         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12746         *ret_conv = GossipTimestampFilter_read(ser_ref);
12747         return (long)ret_conv;
12748 }
12749
12750 int8_tArray  __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
12751         LDKGossipTimestampFilter obj_conv;
12752         obj_conv.inner = (void*)(obj & (~1));
12753         obj_conv.is_owned = false;
12754         LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
12755         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12756         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12757         CVec_u8Z_free(arg_var);
12758         return arg_arr;
12759 }
12760
12761 void  __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_ptr) {
12762         LDKMessageHandler this_ptr_conv;
12763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12764         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12765         MessageHandler_free(this_ptr_conv);
12766 }
12767
12768 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
12769         LDKMessageHandler this_ptr_conv;
12770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12771         this_ptr_conv.is_owned = false;
12772         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
12773         return ret_ret;
12774 }
12775
12776 void  __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
12777         LDKMessageHandler this_ptr_conv;
12778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12779         this_ptr_conv.is_owned = false;
12780         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(((uint64_t)val) & ~1);
12781         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
12782 }
12783
12784 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
12785         LDKMessageHandler this_ptr_conv;
12786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12787         this_ptr_conv.is_owned = false;
12788         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
12789         return ret_ret;
12790 }
12791
12792 void  __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
12793         LDKMessageHandler this_ptr_conv;
12794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12795         this_ptr_conv.is_owned = false;
12796         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(((uint64_t)val) & ~1);
12797         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
12798 }
12799
12800 uint32_t  __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
12801         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(((uint64_t)chan_handler_arg) & ~1);
12802         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(((uint64_t)route_handler_arg) & ~1);
12803         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
12804         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12805         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12806         long ret_ref = (long)ret_var.inner;
12807         if (ret_var.is_owned) {
12808                 ret_ref |= 1;
12809         }
12810         return ret_ref;
12811 }
12812
12813 uint32_t  __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
12814         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig;
12815         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12816         *ret = SocketDescriptor_clone(orig_conv);
12817         return (long)ret;
12818 }
12819
12820 void  __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
12821         if ((this_ptr & 1) != 0) return;
12822         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(((uint64_t)this_ptr) & ~1);
12823         FREE((void*)this_ptr);
12824         SocketDescriptor_free(this_ptr_conv);
12825 }
12826
12827 void  __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_ptr) {
12828         LDKPeerHandleError this_ptr_conv;
12829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12830         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12831         PeerHandleError_free(this_ptr_conv);
12832 }
12833
12834 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_clone(uint32_t orig) {
12835         LDKPeerHandleError orig_conv;
12836         orig_conv.inner = (void*)(orig & (~1));
12837         orig_conv.is_owned = false;
12838         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
12839         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12840         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12841         long ret_ref = (long)ret_var.inner;
12842         if (ret_var.is_owned) {
12843                 ret_ref |= 1;
12844         }
12845         return ret_ref;
12846 }
12847
12848 jboolean  __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
12849         LDKPeerHandleError this_ptr_conv;
12850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12851         this_ptr_conv.is_owned = false;
12852         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
12853         return ret_val;
12854 }
12855
12856 void  __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
12857         LDKPeerHandleError this_ptr_conv;
12858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12859         this_ptr_conv.is_owned = false;
12860         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
12861 }
12862
12863 uint32_t  __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
12864         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
12865         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12866         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12867         long ret_ref = (long)ret_var.inner;
12868         if (ret_var.is_owned) {
12869                 ret_ref |= 1;
12870         }
12871         return ret_ref;
12872 }
12873
12874 void  __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_ptr) {
12875         LDKPeerManager this_ptr_conv;
12876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12877         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12878         PeerManager_free(this_ptr_conv);
12879 }
12880
12881 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) {
12882         LDKMessageHandler message_handler_conv;
12883         message_handler_conv.inner = (void*)(message_handler & (~1));
12884         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
12885         // Warning: we need a move here but no clone is available for LDKMessageHandler
12886         LDKSecretKey our_node_secret_ref;
12887         CHECK(*((uint32_t*)our_node_secret) == 32);
12888         memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
12889         unsigned char ephemeral_random_data_arr[32];
12890         CHECK(*((uint32_t*)ephemeral_random_data) == 32);
12891         memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
12892         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
12893         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
12894         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
12895         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12896         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12897         long ret_ref = (long)ret_var.inner;
12898         if (ret_var.is_owned) {
12899                 ret_ref |= 1;
12900         }
12901         return ret_ref;
12902 }
12903
12904 ptrArray  __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
12905         LDKPeerManager this_arg_conv;
12906         this_arg_conv.inner = (void*)(this_arg & (~1));
12907         this_arg_conv.is_owned = false;
12908         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
12909         ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
12910         int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
12911         for (size_t m = 0; m < ret_var.datalen; m++) {
12912                 int8_tArray arr_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12913                 memcpy((uint8_t*)(arr_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
12914                 ret_arr_ptr[m] = arr_conv_12_arr;
12915         }
12916         FREE(ret_var.data);
12917         return ret_arr;
12918 }
12919
12920 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
12921         LDKPeerManager this_arg_conv;
12922         this_arg_conv.inner = (void*)(this_arg & (~1));
12923         this_arg_conv.is_owned = false;
12924         LDKPublicKey their_node_id_ref;
12925         CHECK(*((uint32_t*)their_node_id) == 33);
12926         memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
12927         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
12928         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
12929         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
12930         return (long)ret_conv;
12931 }
12932
12933 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
12934         LDKPeerManager this_arg_conv;
12935         this_arg_conv.inner = (void*)(this_arg & (~1));
12936         this_arg_conv.is_owned = false;
12937         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(((uint64_t)descriptor) & ~1);
12938         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12939         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
12940         return (long)ret_conv;
12941 }
12942
12943 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
12944         LDKPeerManager this_arg_conv;
12945         this_arg_conv.inner = (void*)(this_arg & (~1));
12946         this_arg_conv.is_owned = false;
12947         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
12948         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12949         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
12950         return (long)ret_conv;
12951 }
12952
12953 uint32_t  __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
12954         LDKPeerManager this_arg_conv;
12955         this_arg_conv.inner = (void*)(this_arg & (~1));
12956         this_arg_conv.is_owned = false;
12957         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
12958         LDKu8slice data_ref;
12959         data_ref.datalen = *((uint32_t*)data);
12960         data_ref.data = (int8_t*)(data + 4);
12961         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12962         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
12963         return (long)ret_conv;
12964 }
12965
12966 void  __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
12967         LDKPeerManager this_arg_conv;
12968         this_arg_conv.inner = (void*)(this_arg & (~1));
12969         this_arg_conv.is_owned = false;
12970         PeerManager_process_events(&this_arg_conv);
12971 }
12972
12973 void  __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
12974         LDKPeerManager this_arg_conv;
12975         this_arg_conv.inner = (void*)(this_arg & (~1));
12976         this_arg_conv.is_owned = false;
12977         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
12978         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
12979 }
12980
12981 void  __attribute__((visibility("default"))) TS_PeerManager_disconnect_by_node_id(uint32_t this_arg, int8_tArray node_id, jboolean no_connection_possible) {
12982         LDKPeerManager this_arg_conv;
12983         this_arg_conv.inner = (void*)(this_arg & (~1));
12984         this_arg_conv.is_owned = false;
12985         LDKPublicKey node_id_ref;
12986         CHECK(*((uint32_t*)node_id) == 33);
12987         memcpy(node_id_ref.compressed_form, (uint8_t*)(node_id + 4), 33);
12988         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
12989 }
12990
12991 void  __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occured(uint32_t this_arg) {
12992         LDKPeerManager this_arg_conv;
12993         this_arg_conv.inner = (void*)(this_arg & (~1));
12994         this_arg_conv.is_owned = false;
12995         PeerManager_timer_tick_occured(&this_arg_conv);
12996 }
12997
12998 int8_tArray  __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
12999         unsigned char commitment_seed_arr[32];
13000         CHECK(*((uint32_t*)commitment_seed) == 32);
13001         memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
13002         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
13003         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13004         memcpy((uint8_t*)(arg_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
13005         return arg_arr;
13006 }
13007
13008 uint32_t  __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
13009         LDKPublicKey per_commitment_point_ref;
13010         CHECK(*((uint32_t*)per_commitment_point) == 33);
13011         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13012         unsigned char base_secret_arr[32];
13013         CHECK(*((uint32_t*)base_secret) == 32);
13014         memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
13015         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
13016         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
13017         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
13018         return (long)ret_conv;
13019 }
13020
13021 uint32_t  __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
13022         LDKPublicKey per_commitment_point_ref;
13023         CHECK(*((uint32_t*)per_commitment_point) == 33);
13024         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13025         LDKPublicKey base_point_ref;
13026         CHECK(*((uint32_t*)base_point) == 33);
13027         memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
13028         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
13029         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
13030         return (long)ret_conv;
13031 }
13032
13033 uint32_t  __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
13034         unsigned char per_commitment_secret_arr[32];
13035         CHECK(*((uint32_t*)per_commitment_secret) == 32);
13036         memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
13037         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
13038         unsigned char countersignatory_revocation_base_secret_arr[32];
13039         CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
13040         memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
13041         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
13042         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
13043         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
13044         return (long)ret_conv;
13045 }
13046
13047 uint32_t  __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
13048         LDKPublicKey per_commitment_point_ref;
13049         CHECK(*((uint32_t*)per_commitment_point) == 33);
13050         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13051         LDKPublicKey countersignatory_revocation_base_point_ref;
13052         CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
13053         memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
13054         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
13055         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
13056         return (long)ret_conv;
13057 }
13058
13059 void  __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_ptr) {
13060         LDKTxCreationKeys this_ptr_conv;
13061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13062         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13063         TxCreationKeys_free(this_ptr_conv);
13064 }
13065
13066 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
13067         LDKTxCreationKeys orig_conv;
13068         orig_conv.inner = (void*)(orig & (~1));
13069         orig_conv.is_owned = false;
13070         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
13071         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13072         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13073         long ret_ref = (long)ret_var.inner;
13074         if (ret_var.is_owned) {
13075                 ret_ref |= 1;
13076         }
13077         return ret_ref;
13078 }
13079
13080 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
13081         LDKTxCreationKeys this_ptr_conv;
13082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13083         this_ptr_conv.is_owned = false;
13084         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13085         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13086         return arg_arr;
13087 }
13088
13089 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13090         LDKTxCreationKeys this_ptr_conv;
13091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13092         this_ptr_conv.is_owned = false;
13093         LDKPublicKey val_ref;
13094         CHECK(*((uint32_t*)val) == 33);
13095         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13096         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
13097 }
13098
13099 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
13100         LDKTxCreationKeys this_ptr_conv;
13101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13102         this_ptr_conv.is_owned = false;
13103         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13104         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
13105         return arg_arr;
13106 }
13107
13108 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
13109         LDKTxCreationKeys this_ptr_conv;
13110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13111         this_ptr_conv.is_owned = false;
13112         LDKPublicKey val_ref;
13113         CHECK(*((uint32_t*)val) == 33);
13114         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13115         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
13116 }
13117
13118 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
13119         LDKTxCreationKeys this_ptr_conv;
13120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13121         this_ptr_conv.is_owned = false;
13122         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13123         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
13124         return arg_arr;
13125 }
13126
13127 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
13128         LDKTxCreationKeys this_ptr_conv;
13129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13130         this_ptr_conv.is_owned = false;
13131         LDKPublicKey val_ref;
13132         CHECK(*((uint32_t*)val) == 33);
13133         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13134         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
13135 }
13136
13137 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
13138         LDKTxCreationKeys this_ptr_conv;
13139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13140         this_ptr_conv.is_owned = false;
13141         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13142         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
13143         return arg_arr;
13144 }
13145
13146 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
13147         LDKTxCreationKeys this_ptr_conv;
13148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13149         this_ptr_conv.is_owned = false;
13150         LDKPublicKey val_ref;
13151         CHECK(*((uint32_t*)val) == 33);
13152         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13153         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
13154 }
13155
13156 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
13157         LDKTxCreationKeys this_ptr_conv;
13158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13159         this_ptr_conv.is_owned = false;
13160         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13161         memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
13162         return arg_arr;
13163 }
13164
13165 void  __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
13166         LDKTxCreationKeys this_ptr_conv;
13167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13168         this_ptr_conv.is_owned = false;
13169         LDKPublicKey val_ref;
13170         CHECK(*((uint32_t*)val) == 33);
13171         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13172         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
13173 }
13174
13175 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) {
13176         LDKPublicKey per_commitment_point_arg_ref;
13177         CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
13178         memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
13179         LDKPublicKey revocation_key_arg_ref;
13180         CHECK(*((uint32_t*)revocation_key_arg) == 33);
13181         memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
13182         LDKPublicKey broadcaster_htlc_key_arg_ref;
13183         CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
13184         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
13185         LDKPublicKey countersignatory_htlc_key_arg_ref;
13186         CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
13187         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
13188         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
13189         CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
13190         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
13191         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);
13192         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13193         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13194         long ret_ref = (long)ret_var.inner;
13195         if (ret_var.is_owned) {
13196                 ret_ref |= 1;
13197         }
13198         return ret_ref;
13199 }
13200
13201 int8_tArray  __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
13202         LDKTxCreationKeys obj_conv;
13203         obj_conv.inner = (void*)(obj & (~1));
13204         obj_conv.is_owned = false;
13205         LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
13206         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13207         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13208         CVec_u8Z_free(arg_var);
13209         return arg_arr;
13210 }
13211
13212 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
13213         LDKu8slice ser_ref;
13214         ser_ref.datalen = *((uint32_t*)ser);
13215         ser_ref.data = (int8_t*)(ser + 4);
13216         LDKTxCreationKeys ret_var = TxCreationKeys_read(ser_ref);
13217         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13218         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13219         long ret_ref = (long)ret_var.inner;
13220         if (ret_var.is_owned) {
13221                 ret_ref |= 1;
13222         }
13223         return ret_ref;
13224 }
13225
13226 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_ptr) {
13227         LDKChannelPublicKeys this_ptr_conv;
13228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13229         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13230         ChannelPublicKeys_free(this_ptr_conv);
13231 }
13232
13233 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
13234         LDKChannelPublicKeys orig_conv;
13235         orig_conv.inner = (void*)(orig & (~1));
13236         orig_conv.is_owned = false;
13237         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
13238         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13239         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13240         long ret_ref = (long)ret_var.inner;
13241         if (ret_var.is_owned) {
13242                 ret_ref |= 1;
13243         }
13244         return ret_ref;
13245 }
13246
13247 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
13248         LDKChannelPublicKeys this_ptr_conv;
13249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13250         this_ptr_conv.is_owned = false;
13251         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13252         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
13253         return arg_arr;
13254 }
13255
13256 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
13257         LDKChannelPublicKeys this_ptr_conv;
13258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13259         this_ptr_conv.is_owned = false;
13260         LDKPublicKey val_ref;
13261         CHECK(*((uint32_t*)val) == 33);
13262         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13263         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
13264 }
13265
13266 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
13267         LDKChannelPublicKeys this_ptr_conv;
13268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13269         this_ptr_conv.is_owned = false;
13270         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13271         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
13272         return arg_arr;
13273 }
13274
13275 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
13276         LDKChannelPublicKeys this_ptr_conv;
13277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13278         this_ptr_conv.is_owned = false;
13279         LDKPublicKey val_ref;
13280         CHECK(*((uint32_t*)val) == 33);
13281         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13282         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
13283 }
13284
13285 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
13286         LDKChannelPublicKeys this_ptr_conv;
13287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13288         this_ptr_conv.is_owned = false;
13289         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13290         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
13291         return arg_arr;
13292 }
13293
13294 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
13295         LDKChannelPublicKeys this_ptr_conv;
13296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13297         this_ptr_conv.is_owned = false;
13298         LDKPublicKey val_ref;
13299         CHECK(*((uint32_t*)val) == 33);
13300         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13301         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
13302 }
13303
13304 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
13305         LDKChannelPublicKeys this_ptr_conv;
13306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13307         this_ptr_conv.is_owned = false;
13308         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13309         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
13310         return arg_arr;
13311 }
13312
13313 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
13314         LDKChannelPublicKeys this_ptr_conv;
13315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13316         this_ptr_conv.is_owned = false;
13317         LDKPublicKey val_ref;
13318         CHECK(*((uint32_t*)val) == 33);
13319         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13320         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13321 }
13322
13323 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
13324         LDKChannelPublicKeys this_ptr_conv;
13325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13326         this_ptr_conv.is_owned = false;
13327         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13328         memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
13329         return arg_arr;
13330 }
13331
13332 void  __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
13333         LDKChannelPublicKeys this_ptr_conv;
13334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13335         this_ptr_conv.is_owned = false;
13336         LDKPublicKey val_ref;
13337         CHECK(*((uint32_t*)val) == 33);
13338         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13339         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
13340 }
13341
13342 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) {
13343         LDKPublicKey funding_pubkey_arg_ref;
13344         CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
13345         memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
13346         LDKPublicKey revocation_basepoint_arg_ref;
13347         CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
13348         memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
13349         LDKPublicKey payment_point_arg_ref;
13350         CHECK(*((uint32_t*)payment_point_arg) == 33);
13351         memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
13352         LDKPublicKey delayed_payment_basepoint_arg_ref;
13353         CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
13354         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
13355         LDKPublicKey htlc_basepoint_arg_ref;
13356         CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
13357         memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
13358         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);
13359         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13360         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13361         long ret_ref = (long)ret_var.inner;
13362         if (ret_var.is_owned) {
13363                 ret_ref |= 1;
13364         }
13365         return ret_ref;
13366 }
13367
13368 int8_tArray  __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
13369         LDKChannelPublicKeys obj_conv;
13370         obj_conv.inner = (void*)(obj & (~1));
13371         obj_conv.is_owned = false;
13372         LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
13373         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13374         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13375         CVec_u8Z_free(arg_var);
13376         return arg_arr;
13377 }
13378
13379 uint32_t  __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
13380         LDKu8slice ser_ref;
13381         ser_ref.datalen = *((uint32_t*)ser);
13382         ser_ref.data = (int8_t*)(ser + 4);
13383         LDKChannelPublicKeys ret_var = ChannelPublicKeys_read(ser_ref);
13384         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13385         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13386         long ret_ref = (long)ret_var.inner;
13387         if (ret_var.is_owned) {
13388                 ret_ref |= 1;
13389         }
13390         return ret_ref;
13391 }
13392
13393 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) {
13394         LDKPublicKey per_commitment_point_ref;
13395         CHECK(*((uint32_t*)per_commitment_point) == 33);
13396         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13397         LDKPublicKey broadcaster_delayed_payment_base_ref;
13398         CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
13399         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
13400         LDKPublicKey broadcaster_htlc_base_ref;
13401         CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
13402         memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
13403         LDKPublicKey countersignatory_revocation_base_ref;
13404         CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
13405         memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
13406         LDKPublicKey countersignatory_htlc_base_ref;
13407         CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
13408         memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
13409         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
13410         *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);
13411         return (long)ret_conv;
13412 }
13413
13414 uint32_t  __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
13415         LDKPublicKey per_commitment_point_ref;
13416         CHECK(*((uint32_t*)per_commitment_point) == 33);
13417         memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13418         LDKChannelPublicKeys broadcaster_keys_conv;
13419         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
13420         broadcaster_keys_conv.is_owned = false;
13421         LDKChannelPublicKeys countersignatory_keys_conv;
13422         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
13423         countersignatory_keys_conv.is_owned = false;
13424         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
13425         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
13426         return (long)ret_conv;
13427 }
13428
13429 int8_tArray  __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
13430         LDKPublicKey revocation_key_ref;
13431         CHECK(*((uint32_t*)revocation_key) == 33);
13432         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
13433         LDKPublicKey broadcaster_delayed_payment_key_ref;
13434         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
13435         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
13436         LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
13437         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13438         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13439         CVec_u8Z_free(arg_var);
13440         return arg_arr;
13441 }
13442
13443 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_ptr) {
13444         LDKHTLCOutputInCommitment this_ptr_conv;
13445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13446         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13447         HTLCOutputInCommitment_free(this_ptr_conv);
13448 }
13449
13450 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
13451         LDKHTLCOutputInCommitment orig_conv;
13452         orig_conv.inner = (void*)(orig & (~1));
13453         orig_conv.is_owned = false;
13454         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
13455         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13456         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13457         long ret_ref = (long)ret_var.inner;
13458         if (ret_var.is_owned) {
13459                 ret_ref |= 1;
13460         }
13461         return ret_ref;
13462 }
13463
13464 jboolean  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
13465         LDKHTLCOutputInCommitment this_ptr_conv;
13466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13467         this_ptr_conv.is_owned = false;
13468         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
13469         return ret_val;
13470 }
13471
13472 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
13473         LDKHTLCOutputInCommitment this_ptr_conv;
13474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13475         this_ptr_conv.is_owned = false;
13476         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
13477 }
13478
13479 int64_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
13480         LDKHTLCOutputInCommitment this_ptr_conv;
13481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13482         this_ptr_conv.is_owned = false;
13483         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
13484         return ret_val;
13485 }
13486
13487 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
13488         LDKHTLCOutputInCommitment this_ptr_conv;
13489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13490         this_ptr_conv.is_owned = false;
13491         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
13492 }
13493
13494 int32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
13495         LDKHTLCOutputInCommitment this_ptr_conv;
13496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13497         this_ptr_conv.is_owned = false;
13498         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
13499         return ret_val;
13500 }
13501
13502 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
13503         LDKHTLCOutputInCommitment this_ptr_conv;
13504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13505         this_ptr_conv.is_owned = false;
13506         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
13507 }
13508
13509 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
13510         LDKHTLCOutputInCommitment this_ptr_conv;
13511         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13512         this_ptr_conv.is_owned = false;
13513         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13514         memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
13515         return ret_arr;
13516 }
13517
13518 void  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
13519         LDKHTLCOutputInCommitment this_ptr_conv;
13520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13521         this_ptr_conv.is_owned = false;
13522         LDKThirtyTwoBytes val_ref;
13523         CHECK(*((uint32_t*)val) == 32);
13524         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13525         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
13526 }
13527
13528 int8_tArray  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
13529         LDKHTLCOutputInCommitment obj_conv;
13530         obj_conv.inner = (void*)(obj & (~1));
13531         obj_conv.is_owned = false;
13532         LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
13533         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13534         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13535         CVec_u8Z_free(arg_var);
13536         return arg_arr;
13537 }
13538
13539 uint32_t  __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
13540         LDKu8slice ser_ref;
13541         ser_ref.datalen = *((uint32_t*)ser);
13542         ser_ref.data = (int8_t*)(ser + 4);
13543         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_read(ser_ref);
13544         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13545         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13546         long ret_ref = (long)ret_var.inner;
13547         if (ret_var.is_owned) {
13548                 ret_ref |= 1;
13549         }
13550         return ret_ref;
13551 }
13552
13553 int8_tArray  __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
13554         LDKHTLCOutputInCommitment htlc_conv;
13555         htlc_conv.inner = (void*)(htlc & (~1));
13556         htlc_conv.is_owned = false;
13557         LDKTxCreationKeys keys_conv;
13558         keys_conv.inner = (void*)(keys & (~1));
13559         keys_conv.is_owned = false;
13560         LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
13561         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13562         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13563         CVec_u8Z_free(arg_var);
13564         return arg_arr;
13565 }
13566
13567 int8_tArray  __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
13568         LDKPublicKey broadcaster_ref;
13569         CHECK(*((uint32_t*)broadcaster) == 33);
13570         memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
13571         LDKPublicKey countersignatory_ref;
13572         CHECK(*((uint32_t*)countersignatory) == 33);
13573         memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
13574         LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
13575         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13576         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13577         CVec_u8Z_free(arg_var);
13578         return arg_arr;
13579 }
13580
13581 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) {
13582         unsigned char prev_hash_arr[32];
13583         CHECK(*((uint32_t*)prev_hash) == 32);
13584         memcpy(prev_hash_arr, (uint8_t*)(prev_hash + 4), 32);
13585         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
13586         LDKHTLCOutputInCommitment htlc_conv;
13587         htlc_conv.inner = (void*)(htlc & (~1));
13588         htlc_conv.is_owned = false;
13589         LDKPublicKey broadcaster_delayed_payment_key_ref;
13590         CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
13591         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
13592         LDKPublicKey revocation_key_ref;
13593         CHECK(*((uint32_t*)revocation_key) == 33);
13594         memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
13595         LDKTransaction arg_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
13596         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13597         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13598         Transaction_free(arg_var);
13599         return arg_arr;
13600 }
13601
13602 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_ptr) {
13603         LDKChannelTransactionParameters this_ptr_conv;
13604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13605         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13606         ChannelTransactionParameters_free(this_ptr_conv);
13607 }
13608
13609 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
13610         LDKChannelTransactionParameters orig_conv;
13611         orig_conv.inner = (void*)(orig & (~1));
13612         orig_conv.is_owned = false;
13613         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
13614         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13615         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13616         long ret_ref = (long)ret_var.inner;
13617         if (ret_var.is_owned) {
13618                 ret_ref |= 1;
13619         }
13620         return ret_ref;
13621 }
13622
13623 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
13624         LDKChannelTransactionParameters this_ptr_conv;
13625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13626         this_ptr_conv.is_owned = false;
13627         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
13628         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13629         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13630         long ret_ref = (long)ret_var.inner;
13631         if (ret_var.is_owned) {
13632                 ret_ref |= 1;
13633         }
13634         return ret_ref;
13635 }
13636
13637 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
13638         LDKChannelTransactionParameters this_ptr_conv;
13639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13640         this_ptr_conv.is_owned = false;
13641         LDKChannelPublicKeys val_conv;
13642         val_conv.inner = (void*)(val & (~1));
13643         val_conv.is_owned = (val & 1) || (val == 0);
13644         val_conv = ChannelPublicKeys_clone(&val_conv);
13645         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
13646 }
13647
13648 int16_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
13649         LDKChannelTransactionParameters this_ptr_conv;
13650         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13651         this_ptr_conv.is_owned = false;
13652         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
13653         return ret_val;
13654 }
13655
13656 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
13657         LDKChannelTransactionParameters this_ptr_conv;
13658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13659         this_ptr_conv.is_owned = false;
13660         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
13661 }
13662
13663 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(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         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
13668         return ret_val;
13669 }
13670
13671 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
13672         LDKChannelTransactionParameters this_ptr_conv;
13673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13674         this_ptr_conv.is_owned = false;
13675         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
13676 }
13677
13678 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
13679         LDKChannelTransactionParameters this_ptr_conv;
13680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13681         this_ptr_conv.is_owned = false;
13682         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
13683         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13684         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13685         long ret_ref = (long)ret_var.inner;
13686         if (ret_var.is_owned) {
13687                 ret_ref |= 1;
13688         }
13689         return ret_ref;
13690 }
13691
13692 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
13693         LDKChannelTransactionParameters this_ptr_conv;
13694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13695         this_ptr_conv.is_owned = false;
13696         LDKCounterpartyChannelTransactionParameters val_conv;
13697         val_conv.inner = (void*)(val & (~1));
13698         val_conv.is_owned = (val & 1) || (val == 0);
13699         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
13700         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
13701 }
13702
13703 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
13704         LDKChannelTransactionParameters this_ptr_conv;
13705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13706         this_ptr_conv.is_owned = false;
13707         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
13708         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13709         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13710         long ret_ref = (long)ret_var.inner;
13711         if (ret_var.is_owned) {
13712                 ret_ref |= 1;
13713         }
13714         return ret_ref;
13715 }
13716
13717 void  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
13718         LDKChannelTransactionParameters this_ptr_conv;
13719         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13720         this_ptr_conv.is_owned = false;
13721         LDKOutPoint val_conv;
13722         val_conv.inner = (void*)(val & (~1));
13723         val_conv.is_owned = (val & 1) || (val == 0);
13724         val_conv = OutPoint_clone(&val_conv);
13725         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
13726 }
13727
13728 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) {
13729         LDKChannelPublicKeys holder_pubkeys_arg_conv;
13730         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
13731         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
13732         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
13733         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
13734         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
13735         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
13736         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
13737         LDKOutPoint funding_outpoint_arg_conv;
13738         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
13739         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
13740         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
13741         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);
13742         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13743         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13744         long ret_ref = (long)ret_var.inner;
13745         if (ret_var.is_owned) {
13746                 ret_ref |= 1;
13747         }
13748         return ret_ref;
13749 }
13750
13751 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_ptr) {
13752         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13754         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13755         CounterpartyChannelTransactionParameters_free(this_ptr_conv);
13756 }
13757
13758 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
13759         LDKCounterpartyChannelTransactionParameters orig_conv;
13760         orig_conv.inner = (void*)(orig & (~1));
13761         orig_conv.is_owned = false;
13762         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
13763         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13764         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13765         long ret_ref = (long)ret_var.inner;
13766         if (ret_var.is_owned) {
13767                 ret_ref |= 1;
13768         }
13769         return ret_ref;
13770 }
13771
13772 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
13773         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13775         this_ptr_conv.is_owned = false;
13776         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
13777         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13778         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13779         long ret_ref = (long)ret_var.inner;
13780         if (ret_var.is_owned) {
13781                 ret_ref |= 1;
13782         }
13783         return ret_ref;
13784 }
13785
13786 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
13787         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13789         this_ptr_conv.is_owned = false;
13790         LDKChannelPublicKeys val_conv;
13791         val_conv.inner = (void*)(val & (~1));
13792         val_conv.is_owned = (val & 1) || (val == 0);
13793         val_conv = ChannelPublicKeys_clone(&val_conv);
13794         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
13795 }
13796
13797 int16_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
13798         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13800         this_ptr_conv.is_owned = false;
13801         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
13802         return ret_val;
13803 }
13804
13805 void  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
13806         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13808         this_ptr_conv.is_owned = false;
13809         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
13810 }
13811
13812 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
13813         LDKChannelPublicKeys pubkeys_arg_conv;
13814         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
13815         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
13816         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
13817         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
13818         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13819         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13820         long ret_ref = (long)ret_var.inner;
13821         if (ret_var.is_owned) {
13822                 ret_ref |= 1;
13823         }
13824         return ret_ref;
13825 }
13826
13827 jboolean  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
13828         LDKChannelTransactionParameters this_arg_conv;
13829         this_arg_conv.inner = (void*)(this_arg & (~1));
13830         this_arg_conv.is_owned = false;
13831         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
13832         return ret_val;
13833 }
13834
13835 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
13836         LDKChannelTransactionParameters this_arg_conv;
13837         this_arg_conv.inner = (void*)(this_arg & (~1));
13838         this_arg_conv.is_owned = false;
13839         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
13840         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13841         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13842         long ret_ref = (long)ret_var.inner;
13843         if (ret_var.is_owned) {
13844                 ret_ref |= 1;
13845         }
13846         return ret_ref;
13847 }
13848
13849 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
13850         LDKChannelTransactionParameters this_arg_conv;
13851         this_arg_conv.inner = (void*)(this_arg & (~1));
13852         this_arg_conv.is_owned = false;
13853         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
13854         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13855         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13856         long ret_ref = (long)ret_var.inner;
13857         if (ret_var.is_owned) {
13858                 ret_ref |= 1;
13859         }
13860         return ret_ref;
13861 }
13862
13863 int8_tArray  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
13864         LDKCounterpartyChannelTransactionParameters obj_conv;
13865         obj_conv.inner = (void*)(obj & (~1));
13866         obj_conv.is_owned = false;
13867         LDKCVec_u8Z arg_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
13868         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13869         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13870         CVec_u8Z_free(arg_var);
13871         return arg_arr;
13872 }
13873
13874 uint32_t  __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
13875         LDKu8slice ser_ref;
13876         ser_ref.datalen = *((uint32_t*)ser);
13877         ser_ref.data = (int8_t*)(ser + 4);
13878         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_read(ser_ref);
13879         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13880         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13881         long ret_ref = (long)ret_var.inner;
13882         if (ret_var.is_owned) {
13883                 ret_ref |= 1;
13884         }
13885         return ret_ref;
13886 }
13887
13888 int8_tArray  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
13889         LDKChannelTransactionParameters obj_conv;
13890         obj_conv.inner = (void*)(obj & (~1));
13891         obj_conv.is_owned = false;
13892         LDKCVec_u8Z arg_var = ChannelTransactionParameters_write(&obj_conv);
13893         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13894         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13895         CVec_u8Z_free(arg_var);
13896         return arg_arr;
13897 }
13898
13899 uint32_t  __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
13900         LDKu8slice ser_ref;
13901         ser_ref.datalen = *((uint32_t*)ser);
13902         ser_ref.data = (int8_t*)(ser + 4);
13903         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_read(ser_ref);
13904         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13905         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13906         long ret_ref = (long)ret_var.inner;
13907         if (ret_var.is_owned) {
13908                 ret_ref |= 1;
13909         }
13910         return ret_ref;
13911 }
13912
13913 void  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_ptr) {
13914         LDKDirectedChannelTransactionParameters this_ptr_conv;
13915         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13916         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13917         DirectedChannelTransactionParameters_free(this_ptr_conv);
13918 }
13919
13920 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
13921         LDKDirectedChannelTransactionParameters this_arg_conv;
13922         this_arg_conv.inner = (void*)(this_arg & (~1));
13923         this_arg_conv.is_owned = false;
13924         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
13925         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13926         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13927         long ret_ref = (long)ret_var.inner;
13928         if (ret_var.is_owned) {
13929                 ret_ref |= 1;
13930         }
13931         return ret_ref;
13932 }
13933
13934 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
13935         LDKDirectedChannelTransactionParameters this_arg_conv;
13936         this_arg_conv.inner = (void*)(this_arg & (~1));
13937         this_arg_conv.is_owned = false;
13938         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
13939         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13940         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13941         long ret_ref = (long)ret_var.inner;
13942         if (ret_var.is_owned) {
13943                 ret_ref |= 1;
13944         }
13945         return ret_ref;
13946 }
13947
13948 int16_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
13949         LDKDirectedChannelTransactionParameters this_arg_conv;
13950         this_arg_conv.inner = (void*)(this_arg & (~1));
13951         this_arg_conv.is_owned = false;
13952         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
13953         return ret_val;
13954 }
13955
13956 jboolean  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
13957         LDKDirectedChannelTransactionParameters this_arg_conv;
13958         this_arg_conv.inner = (void*)(this_arg & (~1));
13959         this_arg_conv.is_owned = false;
13960         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
13961         return ret_val;
13962 }
13963
13964 uint32_t  __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
13965         LDKDirectedChannelTransactionParameters this_arg_conv;
13966         this_arg_conv.inner = (void*)(this_arg & (~1));
13967         this_arg_conv.is_owned = false;
13968         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
13969         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13970         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13971         long ret_ref = (long)ret_var.inner;
13972         if (ret_var.is_owned) {
13973                 ret_ref |= 1;
13974         }
13975         return ret_ref;
13976 }
13977
13978 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_ptr) {
13979         LDKHolderCommitmentTransaction this_ptr_conv;
13980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13981         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13982         HolderCommitmentTransaction_free(this_ptr_conv);
13983 }
13984
13985 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
13986         LDKHolderCommitmentTransaction orig_conv;
13987         orig_conv.inner = (void*)(orig & (~1));
13988         orig_conv.is_owned = false;
13989         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
13990         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13991         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13992         long ret_ref = (long)ret_var.inner;
13993         if (ret_var.is_owned) {
13994                 ret_ref |= 1;
13995         }
13996         return ret_ref;
13997 }
13998
13999 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
14000         LDKHolderCommitmentTransaction this_ptr_conv;
14001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14002         this_ptr_conv.is_owned = false;
14003         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14004         memcpy((uint8_t*)(arg_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
14005         return arg_arr;
14006 }
14007
14008 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
14009         LDKHolderCommitmentTransaction this_ptr_conv;
14010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14011         this_ptr_conv.is_owned = false;
14012         LDKSignature val_ref;
14013         CHECK(*((uint32_t*)val) == 64);
14014         memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
14015         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
14016 }
14017
14018 void  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
14019         LDKHolderCommitmentTransaction this_ptr_conv;
14020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14021         this_ptr_conv.is_owned = false;
14022         LDKCVec_SignatureZ val_constr;
14023         val_constr.datalen = *((uint32_t*)val);
14024         if (val_constr.datalen > 0)
14025                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14026         else
14027                 val_constr.data = NULL;
14028         int8_tArray* val_vals = (int8_tArray*)(val + 4);
14029         for (size_t m = 0; m < val_constr.datalen; m++) {
14030                 int8_tArray arr_conv_12 = val_vals[m];
14031                 LDKSignature arr_conv_12_ref;
14032                 CHECK(*((uint32_t*)arr_conv_12) == 64);
14033                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
14034                 val_constr.data[m] = arr_conv_12_ref;
14035         }
14036         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
14037 }
14038
14039 int8_tArray  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
14040         LDKHolderCommitmentTransaction obj_conv;
14041         obj_conv.inner = (void*)(obj & (~1));
14042         obj_conv.is_owned = false;
14043         LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
14044         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14045         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14046         CVec_u8Z_free(arg_var);
14047         return arg_arr;
14048 }
14049
14050 uint32_t  __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
14051         LDKu8slice ser_ref;
14052         ser_ref.datalen = *((uint32_t*)ser);
14053         ser_ref.data = (int8_t*)(ser + 4);
14054         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_read(ser_ref);
14055         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14056         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14057         long ret_ref = (long)ret_var.inner;
14058         if (ret_var.is_owned) {
14059                 ret_ref |= 1;
14060         }
14061         return ret_ref;
14062 }
14063
14064 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) {
14065         LDKCommitmentTransaction commitment_tx_conv;
14066         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
14067         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
14068         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
14069         LDKSignature counterparty_sig_ref;
14070         CHECK(*((uint32_t*)counterparty_sig) == 64);
14071         memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
14072         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
14073         counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
14074         if (counterparty_htlc_sigs_constr.datalen > 0)
14075                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14076         else
14077                 counterparty_htlc_sigs_constr.data = NULL;
14078         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
14079         for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
14080                 int8_tArray arr_conv_12 = counterparty_htlc_sigs_vals[m];
14081                 LDKSignature arr_conv_12_ref;
14082                 CHECK(*((uint32_t*)arr_conv_12) == 64);
14083                 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
14084                 counterparty_htlc_sigs_constr.data[m] = arr_conv_12_ref;
14085         }
14086         LDKPublicKey holder_funding_key_ref;
14087         CHECK(*((uint32_t*)holder_funding_key) == 33);
14088         memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
14089         LDKPublicKey counterparty_funding_key_ref;
14090         CHECK(*((uint32_t*)counterparty_funding_key) == 33);
14091         memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
14092         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
14093         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14094         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14095         long ret_ref = (long)ret_var.inner;
14096         if (ret_var.is_owned) {
14097                 ret_ref |= 1;
14098         }
14099         return ret_ref;
14100 }
14101
14102 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_ptr) {
14103         LDKBuiltCommitmentTransaction this_ptr_conv;
14104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14105         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14106         BuiltCommitmentTransaction_free(this_ptr_conv);
14107 }
14108
14109 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
14110         LDKBuiltCommitmentTransaction orig_conv;
14111         orig_conv.inner = (void*)(orig & (~1));
14112         orig_conv.is_owned = false;
14113         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
14114         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14115         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14116         long ret_ref = (long)ret_var.inner;
14117         if (ret_var.is_owned) {
14118                 ret_ref |= 1;
14119         }
14120         return ret_ref;
14121 }
14122
14123 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
14124         LDKBuiltCommitmentTransaction this_ptr_conv;
14125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14126         this_ptr_conv.is_owned = false;
14127         LDKTransaction arg_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
14128         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14129         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14130         Transaction_free(arg_var);
14131         return arg_arr;
14132 }
14133
14134 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
14135         LDKBuiltCommitmentTransaction this_ptr_conv;
14136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14137         this_ptr_conv.is_owned = false;
14138         LDKTransaction val_ref;
14139         val_ref.datalen = *((uint32_t*)val);
14140         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
14141         memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
14142         val_ref.data_is_owned = true;
14143         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
14144 }
14145
14146 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
14147         LDKBuiltCommitmentTransaction this_ptr_conv;
14148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14149         this_ptr_conv.is_owned = false;
14150         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14151         memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
14152         return ret_arr;
14153 }
14154
14155 void  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
14156         LDKBuiltCommitmentTransaction this_ptr_conv;
14157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14158         this_ptr_conv.is_owned = false;
14159         LDKThirtyTwoBytes val_ref;
14160         CHECK(*((uint32_t*)val) == 32);
14161         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14162         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
14163 }
14164
14165 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
14166         LDKTransaction transaction_arg_ref;
14167         transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
14168         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
14169         memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
14170         transaction_arg_ref.data_is_owned = true;
14171         LDKThirtyTwoBytes txid_arg_ref;
14172         CHECK(*((uint32_t*)txid_arg) == 32);
14173         memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
14174         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
14175         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14176         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14177         long ret_ref = (long)ret_var.inner;
14178         if (ret_var.is_owned) {
14179                 ret_ref |= 1;
14180         }
14181         return ret_ref;
14182 }
14183
14184 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
14185         LDKBuiltCommitmentTransaction obj_conv;
14186         obj_conv.inner = (void*)(obj & (~1));
14187         obj_conv.is_owned = false;
14188         LDKCVec_u8Z arg_var = BuiltCommitmentTransaction_write(&obj_conv);
14189         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14190         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14191         CVec_u8Z_free(arg_var);
14192         return arg_arr;
14193 }
14194
14195 uint32_t  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
14196         LDKu8slice ser_ref;
14197         ser_ref.datalen = *((uint32_t*)ser);
14198         ser_ref.data = (int8_t*)(ser + 4);
14199         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_read(ser_ref);
14200         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14201         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14202         long ret_ref = (long)ret_var.inner;
14203         if (ret_var.is_owned) {
14204                 ret_ref |= 1;
14205         }
14206         return ret_ref;
14207 }
14208
14209 int8_tArray  __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
14210         LDKBuiltCommitmentTransaction this_arg_conv;
14211         this_arg_conv.inner = (void*)(this_arg & (~1));
14212         this_arg_conv.is_owned = false;
14213         LDKu8slice funding_redeemscript_ref;
14214         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
14215         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
14216         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14217         memcpy((uint8_t*)(arg_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
14218         return arg_arr;
14219 }
14220
14221 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) {
14222         LDKBuiltCommitmentTransaction this_arg_conv;
14223         this_arg_conv.inner = (void*)(this_arg & (~1));
14224         this_arg_conv.is_owned = false;
14225         unsigned char funding_key_arr[32];
14226         CHECK(*((uint32_t*)funding_key) == 32);
14227         memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
14228         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
14229         LDKu8slice funding_redeemscript_ref;
14230         funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
14231         funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
14232         int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14233         memcpy((uint8_t*)(arg_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
14234         return arg_arr;
14235 }
14236
14237 void  __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_ptr) {
14238         LDKCommitmentTransaction this_ptr_conv;
14239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14240         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14241         CommitmentTransaction_free(this_ptr_conv);
14242 }
14243
14244 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
14245         LDKCommitmentTransaction orig_conv;
14246         orig_conv.inner = (void*)(orig & (~1));
14247         orig_conv.is_owned = false;
14248         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
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_CommitmentTransaction_write(uint32_t obj) {
14259         LDKCommitmentTransaction obj_conv;
14260         obj_conv.inner = (void*)(obj & (~1));
14261         obj_conv.is_owned = false;
14262         LDKCVec_u8Z arg_var = CommitmentTransaction_write(&obj_conv);
14263         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14264         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14265         CVec_u8Z_free(arg_var);
14266         return arg_arr;
14267 }
14268
14269 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
14270         LDKu8slice ser_ref;
14271         ser_ref.datalen = *((uint32_t*)ser);
14272         ser_ref.data = (int8_t*)(ser + 4);
14273         LDKCommitmentTransaction ret_var = CommitmentTransaction_read(ser_ref);
14274         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14275         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14276         long ret_ref = (long)ret_var.inner;
14277         if (ret_var.is_owned) {
14278                 ret_ref |= 1;
14279         }
14280         return ret_ref;
14281 }
14282
14283 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
14284         LDKCommitmentTransaction this_arg_conv;
14285         this_arg_conv.inner = (void*)(this_arg & (~1));
14286         this_arg_conv.is_owned = false;
14287         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
14288         return ret_val;
14289 }
14290
14291 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
14292         LDKCommitmentTransaction this_arg_conv;
14293         this_arg_conv.inner = (void*)(this_arg & (~1));
14294         this_arg_conv.is_owned = false;
14295         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
14296         return ret_val;
14297 }
14298
14299 int64_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
14300         LDKCommitmentTransaction this_arg_conv;
14301         this_arg_conv.inner = (void*)(this_arg & (~1));
14302         this_arg_conv.is_owned = false;
14303         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
14304         return ret_val;
14305 }
14306
14307 int32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
14308         LDKCommitmentTransaction this_arg_conv;
14309         this_arg_conv.inner = (void*)(this_arg & (~1));
14310         this_arg_conv.is_owned = false;
14311         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
14312         return ret_val;
14313 }
14314
14315 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
14316         LDKCommitmentTransaction this_arg_conv;
14317         this_arg_conv.inner = (void*)(this_arg & (~1));
14318         this_arg_conv.is_owned = false;
14319         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
14320         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14321         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14322         long ret_ref = (long)ret_var.inner;
14323         if (ret_var.is_owned) {
14324                 ret_ref |= 1;
14325         }
14326         return ret_ref;
14327 }
14328
14329 uint32_t  __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
14330         LDKCommitmentTransaction this_arg_conv;
14331         this_arg_conv.inner = (void*)(this_arg & (~1));
14332         this_arg_conv.is_owned = false;
14333         LDKDirectedChannelTransactionParameters channel_parameters_conv;
14334         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
14335         channel_parameters_conv.is_owned = false;
14336         LDKChannelPublicKeys broadcaster_keys_conv;
14337         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
14338         broadcaster_keys_conv.is_owned = false;
14339         LDKChannelPublicKeys countersignatory_keys_conv;
14340         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
14341         countersignatory_keys_conv.is_owned = false;
14342         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14343         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
14344         return (long)ret_conv;
14345 }
14346
14347 void  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_ptr) {
14348         LDKTrustedCommitmentTransaction this_ptr_conv;
14349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14350         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14351         TrustedCommitmentTransaction_free(this_ptr_conv);
14352 }
14353
14354 int8_tArray  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
14355         LDKTrustedCommitmentTransaction this_arg_conv;
14356         this_arg_conv.inner = (void*)(this_arg & (~1));
14357         this_arg_conv.is_owned = false;
14358         int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14359         memcpy((uint8_t*)(arg_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
14360         return arg_arr;
14361 }
14362
14363 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
14364         LDKTrustedCommitmentTransaction this_arg_conv;
14365         this_arg_conv.inner = (void*)(this_arg & (~1));
14366         this_arg_conv.is_owned = false;
14367         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
14368         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14369         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14370         long ret_ref = (long)ret_var.inner;
14371         if (ret_var.is_owned) {
14372                 ret_ref |= 1;
14373         }
14374         return ret_ref;
14375 }
14376
14377 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
14378         LDKTrustedCommitmentTransaction this_arg_conv;
14379         this_arg_conv.inner = (void*)(this_arg & (~1));
14380         this_arg_conv.is_owned = false;
14381         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
14382         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14383         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14384         long ret_ref = (long)ret_var.inner;
14385         if (ret_var.is_owned) {
14386                 ret_ref |= 1;
14387         }
14388         return ret_ref;
14389 }
14390
14391 uint32_t  __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
14392         LDKTrustedCommitmentTransaction this_arg_conv;
14393         this_arg_conv.inner = (void*)(this_arg & (~1));
14394         this_arg_conv.is_owned = false;
14395         unsigned char htlc_base_key_arr[32];
14396         CHECK(*((uint32_t*)htlc_base_key) == 32);
14397         memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
14398         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
14399         LDKDirectedChannelTransactionParameters channel_parameters_conv;
14400         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
14401         channel_parameters_conv.is_owned = false;
14402         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14403         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
14404         return (long)ret_conv;
14405 }
14406
14407 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) {
14408         LDKPublicKey broadcaster_payment_basepoint_ref;
14409         CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
14410         memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
14411         LDKPublicKey countersignatory_payment_basepoint_ref;
14412         CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
14413         memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
14414         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
14415         return ret_val;
14416 }
14417
14418 void  __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_ptr) {
14419         LDKInitFeatures this_ptr_conv;
14420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14421         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14422         InitFeatures_free(this_ptr_conv);
14423 }
14424
14425 void  __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_ptr) {
14426         LDKNodeFeatures this_ptr_conv;
14427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14428         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14429         NodeFeatures_free(this_ptr_conv);
14430 }
14431
14432 void  __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_ptr) {
14433         LDKChannelFeatures this_ptr_conv;
14434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14435         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14436         ChannelFeatures_free(this_ptr_conv);
14437 }
14438
14439 void  __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_ptr) {
14440         LDKRouteHop this_ptr_conv;
14441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14442         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14443         RouteHop_free(this_ptr_conv);
14444 }
14445
14446 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
14447         LDKRouteHop orig_conv;
14448         orig_conv.inner = (void*)(orig & (~1));
14449         orig_conv.is_owned = false;
14450         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
14451         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14452         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14453         long ret_ref = (long)ret_var.inner;
14454         if (ret_var.is_owned) {
14455                 ret_ref |= 1;
14456         }
14457         return ret_ref;
14458 }
14459
14460 int8_tArray  __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
14461         LDKRouteHop this_ptr_conv;
14462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14463         this_ptr_conv.is_owned = false;
14464         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14465         memcpy((uint8_t*)(arg_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
14466         return arg_arr;
14467 }
14468
14469 void  __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
14470         LDKRouteHop this_ptr_conv;
14471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14472         this_ptr_conv.is_owned = false;
14473         LDKPublicKey val_ref;
14474         CHECK(*((uint32_t*)val) == 33);
14475         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14476         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
14477 }
14478
14479 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
14480         LDKRouteHop this_ptr_conv;
14481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14482         this_ptr_conv.is_owned = false;
14483         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
14484         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14485         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14486         long ret_ref = (long)ret_var.inner;
14487         if (ret_var.is_owned) {
14488                 ret_ref |= 1;
14489         }
14490         return ret_ref;
14491 }
14492
14493 void  __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
14494         LDKRouteHop this_ptr_conv;
14495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14496         this_ptr_conv.is_owned = false;
14497         LDKNodeFeatures val_conv;
14498         val_conv.inner = (void*)(val & (~1));
14499         val_conv.is_owned = (val & 1) || (val == 0);
14500         // Warning: we need a move here but no clone is available for LDKNodeFeatures
14501         RouteHop_set_node_features(&this_ptr_conv, val_conv);
14502 }
14503
14504 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
14505         LDKRouteHop this_ptr_conv;
14506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14507         this_ptr_conv.is_owned = false;
14508         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
14509         return ret_val;
14510 }
14511
14512 void  __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14513         LDKRouteHop this_ptr_conv;
14514         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14515         this_ptr_conv.is_owned = false;
14516         RouteHop_set_short_channel_id(&this_ptr_conv, val);
14517 }
14518
14519 uint32_t  __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
14520         LDKRouteHop this_ptr_conv;
14521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14522         this_ptr_conv.is_owned = false;
14523         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
14524         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14525         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14526         long ret_ref = (long)ret_var.inner;
14527         if (ret_var.is_owned) {
14528                 ret_ref |= 1;
14529         }
14530         return ret_ref;
14531 }
14532
14533 void  __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
14534         LDKRouteHop this_ptr_conv;
14535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14536         this_ptr_conv.is_owned = false;
14537         LDKChannelFeatures val_conv;
14538         val_conv.inner = (void*)(val & (~1));
14539         val_conv.is_owned = (val & 1) || (val == 0);
14540         // Warning: we need a move here but no clone is available for LDKChannelFeatures
14541         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
14542 }
14543
14544 int64_t  __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
14545         LDKRouteHop this_ptr_conv;
14546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14547         this_ptr_conv.is_owned = false;
14548         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
14549         return ret_val;
14550 }
14551
14552 void  __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
14553         LDKRouteHop this_ptr_conv;
14554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14555         this_ptr_conv.is_owned = false;
14556         RouteHop_set_fee_msat(&this_ptr_conv, val);
14557 }
14558
14559 int32_t  __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
14560         LDKRouteHop this_ptr_conv;
14561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14562         this_ptr_conv.is_owned = false;
14563         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
14564         return ret_val;
14565 }
14566
14567 void  __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
14568         LDKRouteHop this_ptr_conv;
14569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14570         this_ptr_conv.is_owned = false;
14571         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
14572 }
14573
14574 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) {
14575         LDKPublicKey pubkey_arg_ref;
14576         CHECK(*((uint32_t*)pubkey_arg) == 33);
14577         memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
14578         LDKNodeFeatures node_features_arg_conv;
14579         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
14580         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
14581         // Warning: we need a move here but no clone is available for LDKNodeFeatures
14582         LDKChannelFeatures channel_features_arg_conv;
14583         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
14584         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
14585         // Warning: we need a move here but no clone is available for LDKChannelFeatures
14586         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);
14587         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14588         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14589         long ret_ref = (long)ret_var.inner;
14590         if (ret_var.is_owned) {
14591                 ret_ref |= 1;
14592         }
14593         return ret_ref;
14594 }
14595
14596 void  __attribute__((visibility("default"))) TS_Route_free(uint32_t this_ptr) {
14597         LDKRoute this_ptr_conv;
14598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14599         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14600         Route_free(this_ptr_conv);
14601 }
14602
14603 uint32_t  __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
14604         LDKRoute orig_conv;
14605         orig_conv.inner = (void*)(orig & (~1));
14606         orig_conv.is_owned = false;
14607         LDKRoute ret_var = Route_clone(&orig_conv);
14608         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14609         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14610         long ret_ref = (long)ret_var.inner;
14611         if (ret_var.is_owned) {
14612                 ret_ref |= 1;
14613         }
14614         return ret_ref;
14615 }
14616
14617 void  __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
14618         LDKRoute this_ptr_conv;
14619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14620         this_ptr_conv.is_owned = false;
14621         LDKCVec_CVec_RouteHopZZ val_constr;
14622         val_constr.datalen = *((uint32_t*)val);
14623         if (val_constr.datalen > 0)
14624                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14625         else
14626                 val_constr.data = NULL;
14627         uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
14628         for (size_t m = 0; m < val_constr.datalen; m++) {
14629                 uint32_tArray arr_conv_12 = val_vals[m];
14630                 LDKCVec_RouteHopZ arr_conv_12_constr;
14631                 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
14632                 if (arr_conv_12_constr.datalen > 0)
14633                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14634                 else
14635                         arr_conv_12_constr.data = NULL;
14636                 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
14637                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
14638                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
14639                         LDKRouteHop arr_conv_10_conv;
14640                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
14641                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
14642                         arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
14643                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
14644                 }
14645                 val_constr.data[m] = arr_conv_12_constr;
14646         }
14647         Route_set_paths(&this_ptr_conv, val_constr);
14648 }
14649
14650 uint32_t  __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
14651         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
14652         paths_arg_constr.datalen = *((uint32_t*)paths_arg);
14653         if (paths_arg_constr.datalen > 0)
14654                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14655         else
14656                 paths_arg_constr.data = NULL;
14657         uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
14658         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
14659                 uint32_tArray arr_conv_12 = paths_arg_vals[m];
14660                 LDKCVec_RouteHopZ arr_conv_12_constr;
14661                 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
14662                 if (arr_conv_12_constr.datalen > 0)
14663                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14664                 else
14665                         arr_conv_12_constr.data = NULL;
14666                 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
14667                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
14668                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
14669                         LDKRouteHop arr_conv_10_conv;
14670                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
14671                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
14672                         arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
14673                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
14674                 }
14675                 paths_arg_constr.data[m] = arr_conv_12_constr;
14676         }
14677         LDKRoute ret_var = Route_new(paths_arg_constr);
14678         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14679         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14680         long ret_ref = (long)ret_var.inner;
14681         if (ret_var.is_owned) {
14682                 ret_ref |= 1;
14683         }
14684         return ret_ref;
14685 }
14686
14687 int8_tArray  __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
14688         LDKRoute obj_conv;
14689         obj_conv.inner = (void*)(obj & (~1));
14690         obj_conv.is_owned = false;
14691         LDKCVec_u8Z arg_var = Route_write(&obj_conv);
14692         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14693         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14694         CVec_u8Z_free(arg_var);
14695         return arg_arr;
14696 }
14697
14698 uint32_t  __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
14699         LDKu8slice ser_ref;
14700         ser_ref.datalen = *((uint32_t*)ser);
14701         ser_ref.data = (int8_t*)(ser + 4);
14702         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14703         *ret_conv = Route_read(ser_ref);
14704         return (long)ret_conv;
14705 }
14706
14707 void  __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_ptr) {
14708         LDKRouteHint this_ptr_conv;
14709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14710         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14711         RouteHint_free(this_ptr_conv);
14712 }
14713
14714 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
14715         LDKRouteHint orig_conv;
14716         orig_conv.inner = (void*)(orig & (~1));
14717         orig_conv.is_owned = false;
14718         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
14719         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14720         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14721         long ret_ref = (long)ret_var.inner;
14722         if (ret_var.is_owned) {
14723                 ret_ref |= 1;
14724         }
14725         return ret_ref;
14726 }
14727
14728 int8_tArray  __attribute__((visibility("default"))) TS_RouteHint_get_src_node_id(uint32_t this_ptr) {
14729         LDKRouteHint this_ptr_conv;
14730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14731         this_ptr_conv.is_owned = false;
14732         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14733         memcpy((uint8_t*)(arg_arr + 4), RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
14734         return arg_arr;
14735 }
14736
14737 void  __attribute__((visibility("default"))) TS_RouteHint_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
14738         LDKRouteHint this_ptr_conv;
14739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14740         this_ptr_conv.is_owned = false;
14741         LDKPublicKey val_ref;
14742         CHECK(*((uint32_t*)val) == 33);
14743         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14744         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
14745 }
14746
14747 int64_t  __attribute__((visibility("default"))) TS_RouteHint_get_short_channel_id(uint32_t this_ptr) {
14748         LDKRouteHint this_ptr_conv;
14749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14750         this_ptr_conv.is_owned = false;
14751         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
14752         return ret_val;
14753 }
14754
14755 void  __attribute__((visibility("default"))) TS_RouteHint_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14756         LDKRouteHint this_ptr_conv;
14757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14758         this_ptr_conv.is_owned = false;
14759         RouteHint_set_short_channel_id(&this_ptr_conv, val);
14760 }
14761
14762 uint32_t  __attribute__((visibility("default"))) TS_RouteHint_get_fees(uint32_t this_ptr) {
14763         LDKRouteHint this_ptr_conv;
14764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14765         this_ptr_conv.is_owned = false;
14766         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
14767         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14768         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14769         long ret_ref = (long)ret_var.inner;
14770         if (ret_var.is_owned) {
14771                 ret_ref |= 1;
14772         }
14773         return ret_ref;
14774 }
14775
14776 void  __attribute__((visibility("default"))) TS_RouteHint_set_fees(uint32_t this_ptr, uint32_t val) {
14777         LDKRouteHint this_ptr_conv;
14778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14779         this_ptr_conv.is_owned = false;
14780         LDKRoutingFees val_conv;
14781         val_conv.inner = (void*)(val & (~1));
14782         val_conv.is_owned = (val & 1) || (val == 0);
14783         val_conv = RoutingFees_clone(&val_conv);
14784         RouteHint_set_fees(&this_ptr_conv, val_conv);
14785 }
14786
14787 int16_t  __attribute__((visibility("default"))) TS_RouteHint_get_cltv_expiry_delta(uint32_t this_ptr) {
14788         LDKRouteHint this_ptr_conv;
14789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14790         this_ptr_conv.is_owned = false;
14791         int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
14792         return ret_val;
14793 }
14794
14795 void  __attribute__((visibility("default"))) TS_RouteHint_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14796         LDKRouteHint this_ptr_conv;
14797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14798         this_ptr_conv.is_owned = false;
14799         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
14800 }
14801
14802 int64_t  __attribute__((visibility("default"))) TS_RouteHint_get_htlc_minimum_msat(uint32_t this_ptr) {
14803         LDKRouteHint this_ptr_conv;
14804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14805         this_ptr_conv.is_owned = false;
14806         int64_t ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
14807         return ret_val;
14808 }
14809
14810 void  __attribute__((visibility("default"))) TS_RouteHint_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14811         LDKRouteHint this_ptr_conv;
14812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14813         this_ptr_conv.is_owned = false;
14814         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
14815 }
14816
14817 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) {
14818         LDKPublicKey src_node_id_arg_ref;
14819         CHECK(*((uint32_t*)src_node_id_arg) == 33);
14820         memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
14821         LDKRoutingFees fees_arg_conv;
14822         fees_arg_conv.inner = (void*)(fees_arg & (~1));
14823         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
14824         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
14825         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);
14826         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14827         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14828         long ret_ref = (long)ret_var.inner;
14829         if (ret_var.is_owned) {
14830                 ret_ref |= 1;
14831         }
14832         return ret_ref;
14833 }
14834
14835 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) {
14836         LDKPublicKey our_node_id_ref;
14837         CHECK(*((uint32_t*)our_node_id) == 33);
14838         memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
14839         LDKNetworkGraph network_conv;
14840         network_conv.inner = (void*)(network & (~1));
14841         network_conv.is_owned = false;
14842         LDKPublicKey target_ref;
14843         CHECK(*((uint32_t*)target) == 33);
14844         memcpy(target_ref.compressed_form, (uint8_t*)(target + 4), 33);
14845         LDKCVec_ChannelDetailsZ first_hops_constr;
14846         first_hops_constr.datalen = *((uint32_t*)first_hops);
14847         if (first_hops_constr.datalen > 0)
14848                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14849         else
14850                 first_hops_constr.data = NULL;
14851         uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
14852         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14853                 uint32_t arr_conv_16 = first_hops_vals[q];
14854                 LDKChannelDetails arr_conv_16_conv;
14855                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
14856                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
14857                 first_hops_constr.data[q] = arr_conv_16_conv;
14858         }
14859         LDKCVec_RouteHintZ last_hops_constr;
14860         last_hops_constr.datalen = *((uint32_t*)last_hops);
14861         if (last_hops_constr.datalen > 0)
14862                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
14863         else
14864                 last_hops_constr.data = NULL;
14865         uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
14866         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
14867                 uint32_t arr_conv_11 = last_hops_vals[l];
14868                 LDKRouteHint arr_conv_11_conv;
14869                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
14870                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
14871                 arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
14872                 last_hops_constr.data[l] = arr_conv_11_conv;
14873         }
14874         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14875         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14876         *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);
14877         FREE(first_hops_constr.data);
14878         return (long)ret_conv;
14879 }
14880
14881 void  __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_ptr) {
14882         LDKNetworkGraph this_ptr_conv;
14883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14884         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14885         NetworkGraph_free(this_ptr_conv);
14886 }
14887
14888 void  __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_ptr) {
14889         LDKLockedNetworkGraph this_ptr_conv;
14890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14891         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14892         LockedNetworkGraph_free(this_ptr_conv);
14893 }
14894
14895 void  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_ptr) {
14896         LDKNetGraphMsgHandler this_ptr_conv;
14897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14898         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14899         NetGraphMsgHandler_free(this_ptr_conv);
14900 }
14901
14902 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
14903         LDKThirtyTwoBytes genesis_hash_ref;
14904         CHECK(*((uint32_t*)genesis_hash) == 32);
14905         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
14906         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14907         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14908         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv, logger_conv);
14909         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14910         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14911         long ret_ref = (long)ret_var.inner;
14912         if (ret_var.is_owned) {
14913                 ret_ref |= 1;
14914         }
14915         return ret_ref;
14916 }
14917
14918 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
14919         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14920         LDKLogger logger_conv = *(LDKLogger*)(((uint64_t)logger) & ~1);
14921         LDKNetworkGraph network_graph_conv;
14922         network_graph_conv.inner = (void*)(network_graph & (~1));
14923         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
14924         // Warning: we need a move here but no clone is available for LDKNetworkGraph
14925         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
14926         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14927         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14928         long ret_ref = (long)ret_var.inner;
14929         if (ret_var.is_owned) {
14930                 ret_ref |= 1;
14931         }
14932         return ret_ref;
14933 }
14934
14935 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
14936         LDKNetGraphMsgHandler this_arg_conv;
14937         this_arg_conv.inner = (void*)(this_arg & (~1));
14938         this_arg_conv.is_owned = false;
14939         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
14940         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14941         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14942         long ret_ref = (long)ret_var.inner;
14943         if (ret_var.is_owned) {
14944                 ret_ref |= 1;
14945         }
14946         return ret_ref;
14947 }
14948
14949 uint32_t  __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
14950         LDKLockedNetworkGraph this_arg_conv;
14951         this_arg_conv.inner = (void*)(this_arg & (~1));
14952         this_arg_conv.is_owned = false;
14953         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
14954         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14955         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14956         long ret_ref = (long)ret_var.inner;
14957         if (ret_var.is_owned) {
14958                 ret_ref |= 1;
14959         }
14960         return ret_ref;
14961 }
14962
14963 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
14964         LDKNetGraphMsgHandler this_arg_conv;
14965         this_arg_conv.inner = (void*)(this_arg & (~1));
14966         this_arg_conv.is_owned = false;
14967         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
14968         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
14969         return (long)ret;
14970 }
14971
14972 uint32_t  __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
14973         LDKNetGraphMsgHandler this_arg_conv;
14974         this_arg_conv.inner = (void*)(this_arg & (~1));
14975         this_arg_conv.is_owned = false;
14976         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
14977         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
14978         return (long)ret;
14979 }
14980
14981 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_ptr) {
14982         LDKDirectionalChannelInfo this_ptr_conv;
14983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14984         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14985         DirectionalChannelInfo_free(this_ptr_conv);
14986 }
14987
14988 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_clone(uint32_t orig) {
14989         LDKDirectionalChannelInfo orig_conv;
14990         orig_conv.inner = (void*)(orig & (~1));
14991         orig_conv.is_owned = false;
14992         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
14993         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14994         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14995         long ret_ref = (long)ret_var.inner;
14996         if (ret_var.is_owned) {
14997                 ret_ref |= 1;
14998         }
14999         return ret_ref;
15000 }
15001
15002 int32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
15003         LDKDirectionalChannelInfo this_ptr_conv;
15004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15005         this_ptr_conv.is_owned = false;
15006         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
15007         return ret_val;
15008 }
15009
15010 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
15011         LDKDirectionalChannelInfo this_ptr_conv;
15012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15013         this_ptr_conv.is_owned = false;
15014         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
15015 }
15016
15017 jboolean  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
15018         LDKDirectionalChannelInfo this_ptr_conv;
15019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15020         this_ptr_conv.is_owned = false;
15021         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
15022         return ret_val;
15023 }
15024
15025 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
15026         LDKDirectionalChannelInfo this_ptr_conv;
15027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15028         this_ptr_conv.is_owned = false;
15029         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
15030 }
15031
15032 int16_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
15033         LDKDirectionalChannelInfo this_ptr_conv;
15034         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15035         this_ptr_conv.is_owned = false;
15036         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
15037         return ret_val;
15038 }
15039
15040 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
15041         LDKDirectionalChannelInfo this_ptr_conv;
15042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15043         this_ptr_conv.is_owned = false;
15044         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
15045 }
15046
15047 int64_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
15048         LDKDirectionalChannelInfo this_ptr_conv;
15049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15050         this_ptr_conv.is_owned = false;
15051         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
15052         return ret_val;
15053 }
15054
15055 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
15056         LDKDirectionalChannelInfo this_ptr_conv;
15057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15058         this_ptr_conv.is_owned = false;
15059         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
15060 }
15061
15062 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
15063         LDKDirectionalChannelInfo this_ptr_conv;
15064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15065         this_ptr_conv.is_owned = false;
15066         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
15067         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15068         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15069         long ret_ref = (long)ret_var.inner;
15070         if (ret_var.is_owned) {
15071                 ret_ref |= 1;
15072         }
15073         return ret_ref;
15074 }
15075
15076 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
15077         LDKDirectionalChannelInfo this_ptr_conv;
15078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15079         this_ptr_conv.is_owned = false;
15080         LDKRoutingFees val_conv;
15081         val_conv.inner = (void*)(val & (~1));
15082         val_conv.is_owned = (val & 1) || (val == 0);
15083         val_conv = RoutingFees_clone(&val_conv);
15084         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
15085 }
15086
15087 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(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         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
15092         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15093         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15094         long ret_ref = (long)ret_var.inner;
15095         if (ret_var.is_owned) {
15096                 ret_ref |= 1;
15097         }
15098         return ret_ref;
15099 }
15100
15101 void  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
15102         LDKDirectionalChannelInfo this_ptr_conv;
15103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15104         this_ptr_conv.is_owned = false;
15105         LDKChannelUpdate val_conv;
15106         val_conv.inner = (void*)(val & (~1));
15107         val_conv.is_owned = (val & 1) || (val == 0);
15108         val_conv = ChannelUpdate_clone(&val_conv);
15109         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
15110 }
15111
15112 int8_tArray  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
15113         LDKDirectionalChannelInfo obj_conv;
15114         obj_conv.inner = (void*)(obj & (~1));
15115         obj_conv.is_owned = false;
15116         LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
15117         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15118         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15119         CVec_u8Z_free(arg_var);
15120         return arg_arr;
15121 }
15122
15123 uint32_t  __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
15124         LDKu8slice ser_ref;
15125         ser_ref.datalen = *((uint32_t*)ser);
15126         ser_ref.data = (int8_t*)(ser + 4);
15127         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_read(ser_ref);
15128         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15129         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15130         long ret_ref = (long)ret_var.inner;
15131         if (ret_var.is_owned) {
15132                 ret_ref |= 1;
15133         }
15134         return ret_ref;
15135 }
15136
15137 void  __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_ptr) {
15138         LDKChannelInfo this_ptr_conv;
15139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15140         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15141         ChannelInfo_free(this_ptr_conv);
15142 }
15143
15144 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
15145         LDKChannelInfo this_ptr_conv;
15146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15147         this_ptr_conv.is_owned = false;
15148         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
15149         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15150         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15151         long ret_ref = (long)ret_var.inner;
15152         if (ret_var.is_owned) {
15153                 ret_ref |= 1;
15154         }
15155         return ret_ref;
15156 }
15157
15158 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
15159         LDKChannelInfo this_ptr_conv;
15160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15161         this_ptr_conv.is_owned = false;
15162         LDKChannelFeatures val_conv;
15163         val_conv.inner = (void*)(val & (~1));
15164         val_conv.is_owned = (val & 1) || (val == 0);
15165         // Warning: we need a move here but no clone is available for LDKChannelFeatures
15166         ChannelInfo_set_features(&this_ptr_conv, val_conv);
15167 }
15168
15169 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
15170         LDKChannelInfo this_ptr_conv;
15171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15172         this_ptr_conv.is_owned = false;
15173         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15174         memcpy((uint8_t*)(arg_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
15175         return arg_arr;
15176 }
15177
15178 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
15179         LDKChannelInfo this_ptr_conv;
15180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15181         this_ptr_conv.is_owned = false;
15182         LDKPublicKey val_ref;
15183         CHECK(*((uint32_t*)val) == 33);
15184         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15185         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
15186 }
15187
15188 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
15189         LDKChannelInfo this_ptr_conv;
15190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15191         this_ptr_conv.is_owned = false;
15192         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
15193         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15194         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15195         long ret_ref = (long)ret_var.inner;
15196         if (ret_var.is_owned) {
15197                 ret_ref |= 1;
15198         }
15199         return ret_ref;
15200 }
15201
15202 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
15203         LDKChannelInfo this_ptr_conv;
15204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15205         this_ptr_conv.is_owned = false;
15206         LDKDirectionalChannelInfo val_conv;
15207         val_conv.inner = (void*)(val & (~1));
15208         val_conv.is_owned = (val & 1) || (val == 0);
15209         val_conv = DirectionalChannelInfo_clone(&val_conv);
15210         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
15211 }
15212
15213 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
15214         LDKChannelInfo this_ptr_conv;
15215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15216         this_ptr_conv.is_owned = false;
15217         int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15218         memcpy((uint8_t*)(arg_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
15219         return arg_arr;
15220 }
15221
15222 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
15223         LDKChannelInfo this_ptr_conv;
15224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15225         this_ptr_conv.is_owned = false;
15226         LDKPublicKey val_ref;
15227         CHECK(*((uint32_t*)val) == 33);
15228         memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15229         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
15230 }
15231
15232 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
15233         LDKChannelInfo this_ptr_conv;
15234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15235         this_ptr_conv.is_owned = false;
15236         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
15237         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15238         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15239         long ret_ref = (long)ret_var.inner;
15240         if (ret_var.is_owned) {
15241                 ret_ref |= 1;
15242         }
15243         return ret_ref;
15244 }
15245
15246 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
15247         LDKChannelInfo this_ptr_conv;
15248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15249         this_ptr_conv.is_owned = false;
15250         LDKDirectionalChannelInfo val_conv;
15251         val_conv.inner = (void*)(val & (~1));
15252         val_conv.is_owned = (val & 1) || (val == 0);
15253         val_conv = DirectionalChannelInfo_clone(&val_conv);
15254         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
15255 }
15256
15257 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
15258         LDKChannelInfo this_ptr_conv;
15259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15260         this_ptr_conv.is_owned = false;
15261         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
15262         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15263         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15264         long ret_ref = (long)ret_var.inner;
15265         if (ret_var.is_owned) {
15266                 ret_ref |= 1;
15267         }
15268         return ret_ref;
15269 }
15270
15271 void  __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
15272         LDKChannelInfo this_ptr_conv;
15273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15274         this_ptr_conv.is_owned = false;
15275         LDKChannelAnnouncement val_conv;
15276         val_conv.inner = (void*)(val & (~1));
15277         val_conv.is_owned = (val & 1) || (val == 0);
15278         val_conv = ChannelAnnouncement_clone(&val_conv);
15279         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
15280 }
15281
15282 int8_tArray  __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
15283         LDKChannelInfo obj_conv;
15284         obj_conv.inner = (void*)(obj & (~1));
15285         obj_conv.is_owned = false;
15286         LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
15287         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15288         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15289         CVec_u8Z_free(arg_var);
15290         return arg_arr;
15291 }
15292
15293 uint32_t  __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
15294         LDKu8slice ser_ref;
15295         ser_ref.datalen = *((uint32_t*)ser);
15296         ser_ref.data = (int8_t*)(ser + 4);
15297         LDKChannelInfo ret_var = ChannelInfo_read(ser_ref);
15298         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15299         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15300         long ret_ref = (long)ret_var.inner;
15301         if (ret_var.is_owned) {
15302                 ret_ref |= 1;
15303         }
15304         return ret_ref;
15305 }
15306
15307 void  __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_ptr) {
15308         LDKRoutingFees this_ptr_conv;
15309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15310         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15311         RoutingFees_free(this_ptr_conv);
15312 }
15313
15314 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
15315         LDKRoutingFees orig_conv;
15316         orig_conv.inner = (void*)(orig & (~1));
15317         orig_conv.is_owned = false;
15318         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
15319         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15320         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15321         long ret_ref = (long)ret_var.inner;
15322         if (ret_var.is_owned) {
15323                 ret_ref |= 1;
15324         }
15325         return ret_ref;
15326 }
15327
15328 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
15329         LDKRoutingFees this_ptr_conv;
15330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15331         this_ptr_conv.is_owned = false;
15332         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
15333         return ret_val;
15334 }
15335
15336 void  __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
15337         LDKRoutingFees this_ptr_conv;
15338         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15339         this_ptr_conv.is_owned = false;
15340         RoutingFees_set_base_msat(&this_ptr_conv, val);
15341 }
15342
15343 int32_t  __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
15344         LDKRoutingFees this_ptr_conv;
15345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15346         this_ptr_conv.is_owned = false;
15347         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
15348         return ret_val;
15349 }
15350
15351 void  __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
15352         LDKRoutingFees this_ptr_conv;
15353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15354         this_ptr_conv.is_owned = false;
15355         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
15356 }
15357
15358 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
15359         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
15360         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15361         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15362         long ret_ref = (long)ret_var.inner;
15363         if (ret_var.is_owned) {
15364                 ret_ref |= 1;
15365         }
15366         return ret_ref;
15367 }
15368
15369 uint32_t  __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
15370         LDKu8slice ser_ref;
15371         ser_ref.datalen = *((uint32_t*)ser);
15372         ser_ref.data = (int8_t*)(ser + 4);
15373         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
15374         *ret_conv = RoutingFees_read(ser_ref);
15375         return (long)ret_conv;
15376 }
15377
15378 int8_tArray  __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
15379         LDKRoutingFees obj_conv;
15380         obj_conv.inner = (void*)(obj & (~1));
15381         obj_conv.is_owned = false;
15382         LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
15383         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15384         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15385         CVec_u8Z_free(arg_var);
15386         return arg_arr;
15387 }
15388
15389 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_ptr) {
15390         LDKNodeAnnouncementInfo this_ptr_conv;
15391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15392         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15393         NodeAnnouncementInfo_free(this_ptr_conv);
15394 }
15395
15396 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_clone(uint32_t orig) {
15397         LDKNodeAnnouncementInfo orig_conv;
15398         orig_conv.inner = (void*)(orig & (~1));
15399         orig_conv.is_owned = false;
15400         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
15401         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15402         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15403         long ret_ref = (long)ret_var.inner;
15404         if (ret_var.is_owned) {
15405                 ret_ref |= 1;
15406         }
15407         return ret_ref;
15408 }
15409
15410 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
15411         LDKNodeAnnouncementInfo this_ptr_conv;
15412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15413         this_ptr_conv.is_owned = false;
15414         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
15415         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15416         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15417         long ret_ref = (long)ret_var.inner;
15418         if (ret_var.is_owned) {
15419                 ret_ref |= 1;
15420         }
15421         return ret_ref;
15422 }
15423
15424 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
15425         LDKNodeAnnouncementInfo this_ptr_conv;
15426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15427         this_ptr_conv.is_owned = false;
15428         LDKNodeFeatures val_conv;
15429         val_conv.inner = (void*)(val & (~1));
15430         val_conv.is_owned = (val & 1) || (val == 0);
15431         // Warning: we need a move here but no clone is available for LDKNodeFeatures
15432         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
15433 }
15434
15435 int32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
15436         LDKNodeAnnouncementInfo this_ptr_conv;
15437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15438         this_ptr_conv.is_owned = false;
15439         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
15440         return ret_val;
15441 }
15442
15443 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
15444         LDKNodeAnnouncementInfo this_ptr_conv;
15445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15446         this_ptr_conv.is_owned = false;
15447         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
15448 }
15449
15450 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
15451         LDKNodeAnnouncementInfo this_ptr_conv;
15452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15453         this_ptr_conv.is_owned = false;
15454         int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
15455         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
15456         return ret_arr;
15457 }
15458
15459 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
15460         LDKNodeAnnouncementInfo this_ptr_conv;
15461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15462         this_ptr_conv.is_owned = false;
15463         LDKThreeBytes val_ref;
15464         CHECK(*((uint32_t*)val) == 3);
15465         memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
15466         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
15467 }
15468
15469 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
15470         LDKNodeAnnouncementInfo this_ptr_conv;
15471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15472         this_ptr_conv.is_owned = false;
15473         int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15474         memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
15475         return ret_arr;
15476 }
15477
15478 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
15479         LDKNodeAnnouncementInfo this_ptr_conv;
15480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15481         this_ptr_conv.is_owned = false;
15482         LDKThirtyTwoBytes val_ref;
15483         CHECK(*((uint32_t*)val) == 32);
15484         memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15485         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
15486 }
15487
15488 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
15489         LDKNodeAnnouncementInfo this_ptr_conv;
15490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15491         this_ptr_conv.is_owned = false;
15492         LDKCVec_NetAddressZ val_constr;
15493         val_constr.datalen = *((uint32_t*)val);
15494         if (val_constr.datalen > 0)
15495                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15496         else
15497                 val_constr.data = NULL;
15498         uint32_t* val_vals = (uint32_t*)(val + 4);
15499         for (size_t m = 0; m < val_constr.datalen; m++) {
15500                 uint32_t arr_conv_12 = val_vals[m];
15501                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
15502                 FREE((void*)arr_conv_12);
15503                 val_constr.data[m] = arr_conv_12_conv;
15504         }
15505         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
15506 }
15507
15508 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
15509         LDKNodeAnnouncementInfo this_ptr_conv;
15510         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15511         this_ptr_conv.is_owned = false;
15512         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
15513         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15514         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15515         long ret_ref = (long)ret_var.inner;
15516         if (ret_var.is_owned) {
15517                 ret_ref |= 1;
15518         }
15519         return ret_ref;
15520 }
15521
15522 void  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
15523         LDKNodeAnnouncementInfo this_ptr_conv;
15524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15525         this_ptr_conv.is_owned = false;
15526         LDKNodeAnnouncement val_conv;
15527         val_conv.inner = (void*)(val & (~1));
15528         val_conv.is_owned = (val & 1) || (val == 0);
15529         val_conv = NodeAnnouncement_clone(&val_conv);
15530         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
15531 }
15532
15533 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) {
15534         LDKNodeFeatures features_arg_conv;
15535         features_arg_conv.inner = (void*)(features_arg & (~1));
15536         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
15537         // Warning: we need a move here but no clone is available for LDKNodeFeatures
15538         LDKThreeBytes rgb_arg_ref;
15539         CHECK(*((uint32_t*)rgb_arg) == 3);
15540         memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
15541         LDKThirtyTwoBytes alias_arg_ref;
15542         CHECK(*((uint32_t*)alias_arg) == 32);
15543         memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
15544         LDKCVec_NetAddressZ addresses_arg_constr;
15545         addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
15546         if (addresses_arg_constr.datalen > 0)
15547                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15548         else
15549                 addresses_arg_constr.data = NULL;
15550         uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
15551         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
15552                 uint32_t arr_conv_12 = addresses_arg_vals[m];
15553                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)(((uint64_t)arr_conv_12) & ~1);
15554                 FREE((void*)arr_conv_12);
15555                 addresses_arg_constr.data[m] = arr_conv_12_conv;
15556         }
15557         LDKNodeAnnouncement announcement_message_arg_conv;
15558         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
15559         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
15560         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
15561         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
15562         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15563         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15564         long ret_ref = (long)ret_var.inner;
15565         if (ret_var.is_owned) {
15566                 ret_ref |= 1;
15567         }
15568         return ret_ref;
15569 }
15570
15571 int8_tArray  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
15572         LDKNodeAnnouncementInfo obj_conv;
15573         obj_conv.inner = (void*)(obj & (~1));
15574         obj_conv.is_owned = false;
15575         LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
15576         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15577         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15578         CVec_u8Z_free(arg_var);
15579         return arg_arr;
15580 }
15581
15582 uint32_t  __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
15583         LDKu8slice ser_ref;
15584         ser_ref.datalen = *((uint32_t*)ser);
15585         ser_ref.data = (int8_t*)(ser + 4);
15586         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
15587         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
15588         return (long)ret_conv;
15589 }
15590
15591 void  __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_ptr) {
15592         LDKNodeInfo this_ptr_conv;
15593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15594         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15595         NodeInfo_free(this_ptr_conv);
15596 }
15597
15598 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_clone(uint32_t orig) {
15599         LDKNodeInfo orig_conv;
15600         orig_conv.inner = (void*)(orig & (~1));
15601         orig_conv.is_owned = false;
15602         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
15603         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15604         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15605         long ret_ref = (long)ret_var.inner;
15606         if (ret_var.is_owned) {
15607                 ret_ref |= 1;
15608         }
15609         return ret_ref;
15610 }
15611
15612 void  __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
15613         LDKNodeInfo this_ptr_conv;
15614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15615         this_ptr_conv.is_owned = false;
15616         LDKCVec_u64Z val_constr;
15617         val_constr.datalen = *((uint32_t*)val);
15618         if (val_constr.datalen > 0)
15619                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15620         else
15621                 val_constr.data = NULL;
15622         int64_t* val_vals = (int64_t*)(val + 4);
15623         for (size_t i = 0; i < val_constr.datalen; i++) {
15624                 int64_t arr_conv_8 = val_vals[i];
15625                 val_constr.data[i] = arr_conv_8;
15626         }
15627         NodeInfo_set_channels(&this_ptr_conv, val_constr);
15628 }
15629
15630 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
15631         LDKNodeInfo this_ptr_conv;
15632         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15633         this_ptr_conv.is_owned = false;
15634         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
15635         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15636         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15637         long ret_ref = (long)ret_var.inner;
15638         if (ret_var.is_owned) {
15639                 ret_ref |= 1;
15640         }
15641         return ret_ref;
15642 }
15643
15644 void  __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
15645         LDKNodeInfo this_ptr_conv;
15646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15647         this_ptr_conv.is_owned = false;
15648         LDKRoutingFees val_conv;
15649         val_conv.inner = (void*)(val & (~1));
15650         val_conv.is_owned = (val & 1) || (val == 0);
15651         val_conv = RoutingFees_clone(&val_conv);
15652         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
15653 }
15654
15655 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
15656         LDKNodeInfo this_ptr_conv;
15657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15658         this_ptr_conv.is_owned = false;
15659         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
15660         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15661         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15662         long ret_ref = (long)ret_var.inner;
15663         if (ret_var.is_owned) {
15664                 ret_ref |= 1;
15665         }
15666         return ret_ref;
15667 }
15668
15669 void  __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
15670         LDKNodeInfo this_ptr_conv;
15671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
15672         this_ptr_conv.is_owned = false;
15673         LDKNodeAnnouncementInfo val_conv;
15674         val_conv.inner = (void*)(val & (~1));
15675         val_conv.is_owned = (val & 1) || (val == 0);
15676         val_conv = NodeAnnouncementInfo_clone(&val_conv);
15677         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
15678 }
15679
15680 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
15681         LDKCVec_u64Z channels_arg_constr;
15682         channels_arg_constr.datalen = *((uint32_t*)channels_arg);
15683         if (channels_arg_constr.datalen > 0)
15684                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15685         else
15686                 channels_arg_constr.data = NULL;
15687         int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
15688         for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
15689                 int64_t arr_conv_8 = channels_arg_vals[i];
15690                 channels_arg_constr.data[i] = arr_conv_8;
15691         }
15692         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
15693         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
15694         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
15695         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
15696         LDKNodeAnnouncementInfo announcement_info_arg_conv;
15697         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
15698         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
15699         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
15700         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
15701         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15702         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15703         long ret_ref = (long)ret_var.inner;
15704         if (ret_var.is_owned) {
15705                 ret_ref |= 1;
15706         }
15707         return ret_ref;
15708 }
15709
15710 int8_tArray  __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
15711         LDKNodeInfo obj_conv;
15712         obj_conv.inner = (void*)(obj & (~1));
15713         obj_conv.is_owned = false;
15714         LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
15715         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15716         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15717         CVec_u8Z_free(arg_var);
15718         return arg_arr;
15719 }
15720
15721 uint32_t  __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
15722         LDKu8slice ser_ref;
15723         ser_ref.datalen = *((uint32_t*)ser);
15724         ser_ref.data = (int8_t*)(ser + 4);
15725         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
15726         *ret_conv = NodeInfo_read(ser_ref);
15727         return (long)ret_conv;
15728 }
15729
15730 int8_tArray  __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
15731         LDKNetworkGraph obj_conv;
15732         obj_conv.inner = (void*)(obj & (~1));
15733         obj_conv.is_owned = false;
15734         LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
15735         int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15736         memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15737         CVec_u8Z_free(arg_var);
15738         return arg_arr;
15739 }
15740
15741 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
15742         LDKu8slice ser_ref;
15743         ser_ref.datalen = *((uint32_t*)ser);
15744         ser_ref.data = (int8_t*)(ser + 4);
15745         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
15746         *ret_conv = NetworkGraph_read(ser_ref);
15747         return (long)ret_conv;
15748 }
15749
15750 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
15751         LDKThirtyTwoBytes genesis_hash_ref;
15752         CHECK(*((uint32_t*)genesis_hash) == 32);
15753         memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
15754         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
15755         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15756         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15757         long ret_ref = (long)ret_var.inner;
15758         if (ret_var.is_owned) {
15759                 ret_ref |= 1;
15760         }
15761         return ret_ref;
15762 }
15763
15764 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
15765         LDKNetworkGraph this_arg_conv;
15766         this_arg_conv.inner = (void*)(this_arg & (~1));
15767         this_arg_conv.is_owned = false;
15768         LDKNodeAnnouncement msg_conv;
15769         msg_conv.inner = (void*)(msg & (~1));
15770         msg_conv.is_owned = false;
15771         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15772         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
15773         return (long)ret_conv;
15774 }
15775
15776 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
15777         LDKNetworkGraph this_arg_conv;
15778         this_arg_conv.inner = (void*)(this_arg & (~1));
15779         this_arg_conv.is_owned = false;
15780         LDKUnsignedNodeAnnouncement msg_conv;
15781         msg_conv.inner = (void*)(msg & (~1));
15782         msg_conv.is_owned = false;
15783         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15784         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
15785         return (long)ret_conv;
15786 }
15787
15788 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
15789         LDKNetworkGraph this_arg_conv;
15790         this_arg_conv.inner = (void*)(this_arg & (~1));
15791         this_arg_conv.is_owned = false;
15792         LDKChannelAnnouncement msg_conv;
15793         msg_conv.inner = (void*)(msg & (~1));
15794         msg_conv.is_owned = false;
15795         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
15796         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15797         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
15798         return (long)ret_conv;
15799 }
15800
15801 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
15802         LDKNetworkGraph this_arg_conv;
15803         this_arg_conv.inner = (void*)(this_arg & (~1));
15804         this_arg_conv.is_owned = false;
15805         LDKUnsignedChannelAnnouncement msg_conv;
15806         msg_conv.inner = (void*)(msg & (~1));
15807         msg_conv.is_owned = false;
15808         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
15809         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15810         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
15811         return (long)ret_conv;
15812 }
15813
15814 void  __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
15815         LDKNetworkGraph this_arg_conv;
15816         this_arg_conv.inner = (void*)(this_arg & (~1));
15817         this_arg_conv.is_owned = false;
15818         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
15819 }
15820
15821 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
15822         LDKNetworkGraph this_arg_conv;
15823         this_arg_conv.inner = (void*)(this_arg & (~1));
15824         this_arg_conv.is_owned = false;
15825         LDKChannelUpdate msg_conv;
15826         msg_conv.inner = (void*)(msg & (~1));
15827         msg_conv.is_owned = false;
15828         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15829         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
15830         return (long)ret_conv;
15831 }
15832
15833 uint32_t  __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
15834         LDKNetworkGraph this_arg_conv;
15835         this_arg_conv.inner = (void*)(this_arg & (~1));
15836         this_arg_conv.is_owned = false;
15837         LDKUnsignedChannelUpdate msg_conv;
15838         msg_conv.inner = (void*)(msg & (~1));
15839         msg_conv.is_owned = false;
15840         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15841         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
15842         return (long)ret_conv;
15843 }
15844