bindings updates
[ldk-java] / ts / bindings.c
1 #include <rust_types.h>
2 #include <stdatomic.h>
3 #include <lightning.h>
4
5 // These should be provided...somehow...
6 void *memset(void *s, int c, size_t n);
7 void *memcpy(void *dest, const void *src, size_t n);
8 int memcmp(const void *s1, const void *s2, size_t n);
9
10 void __attribute__((noreturn)) abort(void);
11 void assert(scalar expression);
12
13 // Always run a, then assert it is true:
14 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
15 // Assert a is true or do nothing
16 #define CHECK(a) DO_ASSERT(a)
17
18 // Running a leak check across all the allocations and frees of the JDK is a mess,
19 // so instead we implement our own naive leak checker here, relying on the -wrap
20 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
21 // and free'd in Rust or C across the generated bindings shared library.
22
23 #define BT_MAX 128
24 typedef struct allocation {
25         struct allocation* next;
26         void* ptr;
27         const char* struct_name;
28 } allocation;
29 static allocation* allocation_ll = NULL;
30
31 void* __real_malloc(size_t len);
32 void* __real_calloc(size_t nmemb, size_t len);
33 static void new_allocation(void* res, const char* struct_name) {
34         allocation* new_alloc = __real_malloc(sizeof(allocation));
35         new_alloc->ptr = res;
36         new_alloc->struct_name = struct_name;
37         new_alloc->next = allocation_ll;
38         allocation_ll = new_alloc;
39 }
40 static void* MALLOC(size_t len, const char* struct_name) {
41         void* res = __real_malloc(len);
42         new_allocation(res, struct_name);
43         return res;
44 }
45 void __real_free(void* ptr);
46 static void alloc_freed(void* ptr) {
47         allocation* p = NULL;
48         allocation* it = allocation_ll;
49         while (it->ptr != ptr) {
50                 p = it; it = it->next;
51                 if (it == NULL) {
52                         //XXX: fprintf(stderr, "Tried to free unknown pointer %p\n", ptr);
53                         return; // addrsan should catch malloc-unknown and print more info than we have
54                 }
55         }
56         if (p) { p->next = it->next; } else { allocation_ll = it->next; }
57         DO_ASSERT(it->ptr == ptr);
58         __real_free(it);
59 }
60 static void FREE(void* ptr) {
61         if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
62         alloc_freed(ptr);
63         __real_free(ptr);
64 }
65
66 void* __wrap_malloc(size_t len) {
67         void* res = __real_malloc(len);
68         new_allocation(res, "malloc call");
69         return res;
70 }
71 void* __wrap_calloc(size_t nmemb, size_t len) {
72         void* res = __real_calloc(nmemb, len);
73         new_allocation(res, "calloc call");
74         return res;
75 }
76 void __wrap_free(void* ptr) {
77         if (ptr == NULL) return;
78         alloc_freed(ptr);
79         __real_free(ptr);
80 }
81
82 void* __real_realloc(void* ptr, size_t newlen);
83 void* __wrap_realloc(void* ptr, size_t len) {
84         if (ptr != NULL) alloc_freed(ptr);
85         void* res = __real_realloc(ptr, len);
86         new_allocation(res, "realloc call");
87         return res;
88 }
89 void __wrap_reallocarray(void* ptr, size_t new_sz) {
90         // Rust doesn't seem to use reallocarray currently
91         DO_ASSERT(false);
92 }
93
94 void __attribute__((destructor)) check_leaks() {
95         for (allocation* a = allocation_ll; a != NULL; a = a->next) {
96                 //XXX: fprintf(stderr, "%s %p remains\n", a->struct_name, a->ptr);
97         }
98         DO_ASSERT(allocation_ll == NULL);
99 }
100
101 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
102 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
103 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
104 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
105
106 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
107
108 typedef struct int64_tArray {uint32_t len;int64_t *ptr;} int64_tArray;
109 typedef struct uint32_tArray {uint32_t len;int32_t *ptr;} uint32_tArray;
110 typedef struct int8_tArray {uint32_t len;int8_t *ptr;} int8_tArray;
111
112 typedef bool jboolean;
113
114 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
115 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
116         switch (ord) {
117                 case 0: return LDKAccessError_UnknownChain;
118                 case 1: return LDKAccessError_UnknownTx;
119         }
120         abort();
121 }
122 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
123         switch (val) {
124                 case LDKAccessError_UnknownChain: return 0;
125                 case LDKAccessError_UnknownTx: return 1;
126                 default: abort();
127         }
128 }
129 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
130         switch (ord) {
131                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
132                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
133         }
134         abort();
135 }
136 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
137         switch (val) {
138                 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
139                 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
140                 default: abort();
141         }
142 }
143 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
144         switch (ord) {
145                 case 0: return LDKConfirmationTarget_Background;
146                 case 1: return LDKConfirmationTarget_Normal;
147                 case 2: return LDKConfirmationTarget_HighPriority;
148         }
149         abort();
150 }
151 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
152         switch (val) {
153                 case LDKConfirmationTarget_Background: return 0;
154                 case LDKConfirmationTarget_Normal: return 1;
155                 case LDKConfirmationTarget_HighPriority: return 2;
156                 default: abort();
157         }
158 }
159 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
160         switch (ord) {
161                 case 0: return LDKLevel_Off;
162                 case 1: return LDKLevel_Error;
163                 case 2: return LDKLevel_Warn;
164                 case 3: return LDKLevel_Info;
165                 case 4: return LDKLevel_Debug;
166                 case 5: return LDKLevel_Trace;
167         }
168         abort();
169 }
170 static inline int32_t LDKLevel_to_js(LDKLevel val) {
171         switch (val) {
172                 case LDKLevel_Off: return 0;
173                 case LDKLevel_Error: return 1;
174                 case LDKLevel_Warn: return 2;
175                 case LDKLevel_Info: return 3;
176                 case LDKLevel_Debug: return 4;
177                 case LDKLevel_Trace: return 5;
178                 default: abort();
179         }
180 }
181 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
182         switch (ord) {
183                 case 0: return LDKNetwork_Bitcoin;
184                 case 1: return LDKNetwork_Testnet;
185                 case 2: return LDKNetwork_Regtest;
186         }
187         abort();
188 }
189 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
190         switch (val) {
191                 case LDKNetwork_Bitcoin: return 0;
192                 case LDKNetwork_Testnet: return 1;
193                 case LDKNetwork_Regtest: return 2;
194                 default: abort();
195         }
196 }
197 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
198         switch (ord) {
199                 case 0: return LDKSecp256k1Error_IncorrectSignature;
200                 case 1: return LDKSecp256k1Error_InvalidMessage;
201                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
202                 case 3: return LDKSecp256k1Error_InvalidSignature;
203                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
204                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
205                 case 6: return LDKSecp256k1Error_InvalidTweak;
206                 case 7: return LDKSecp256k1Error_NotEnoughMemory;
207                 case 8: return LDKSecp256k1Error_CallbackPanicked;
208         }
209         abort();
210 }
211 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
212         switch (val) {
213                 case LDKSecp256k1Error_IncorrectSignature: return 0;
214                 case LDKSecp256k1Error_InvalidMessage: return 1;
215                 case LDKSecp256k1Error_InvalidPublicKey: return 2;
216                 case LDKSecp256k1Error_InvalidSignature: return 3;
217                 case LDKSecp256k1Error_InvalidSecretKey: return 4;
218                 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
219                 case LDKSecp256k1Error_InvalidTweak: return 6;
220                 case LDKSecp256k1Error_NotEnoughMemory: return 7;
221                 case LDKSecp256k1Error_CallbackPanicked: return 8;
222                 default: abort();
223         }
224 }
225 uint32_t LDKCVec_1u8Z_1new(void* ctx_TODO, int8_tArray elems) {
226         LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
227         ret->datalen = elems.len;
228         if (ret->datalen == 0) {
229                 ret->data = NULL;
230         } else {
231                 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
232                 int8_t *java_elems = elems.ptr;
233                 for (size_t i = 0; i < ret->datalen; i++) {
234                         ret->data[i] = java_elems[i];
235                 }
236         }
237         return (long)ret;
238 }
239 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
240         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
241         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
242         return ret;
243 }
244 uint32_t LDKC2Tuple_1u64u64Z_1new(void* ctx_TODO, int64_t a, int64_t b) {
245         LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
246         ret->a = a;
247         ret->b = b;
248         return (long)ret;
249 }
250 static inline LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_clone(const LDKC2Tuple_u64u64Z *orig) {
251         LDKC2Tuple_u64u64Z ret = {
252                 .a = orig->a,
253                 .b = orig->b,
254         };
255         return ret;
256 }
257 int64_t LDKC2Tuple_1u64u64Z_1get_1a(void* ctx_TODO, uint32_t ptr) {
258         LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)ptr;
259         return tuple->a;
260 }
261 int64_t LDKC2Tuple_1u64u64Z_1get_1b(void* ctx_TODO, uint32_t ptr) {
262         LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)ptr;
263         return tuple->b;
264 }
265 uint32_t LDKSpendableOutputDescriptor_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
266         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
267         switch(obj->tag) {
268                 case LDKSpendableOutputDescriptor_StaticOutput: {
269                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
270                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
271                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
272                         long outpoint_ref = (long)outpoint_var.inner & ~1;
273                         long output_ref = (long)&obj->static_output.output;
274                         return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
275                 }
276                 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
277                         LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
278                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
279                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
280                         long outpoint_ref = (long)outpoint_var.inner & ~1;
281                         int8_tArray per_commitment_point_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
282                         memcpy(per_commitment_point_arr.ptr, obj->dynamic_output_p2wsh.per_commitment_point.compressed_form, 33);
283                         long output_ref = (long)&obj->dynamic_output_p2wsh.output;
284                         long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
285                         int8_tArray revocation_pubkey_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
286                         memcpy(revocation_pubkey_arr.ptr, obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form, 33);
287                         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;
288                 }
289                 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
290                         LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
291                         CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
292                         CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
293                         long outpoint_ref = (long)outpoint_var.inner & ~1;
294                         long output_ref = (long)&obj->static_output_counterparty_payment.output;
295                         long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
296                         return 0 /* LDKSpendableOutputDescriptor - StaticOutputCounterpartyPayment */; (void) outpoint_ref; (void) (long)output_ref; (void) key_derivation_params_ref;
297                 }
298                 default: abort();
299         }
300 }
301 uint32_t LDKCVec_1SpendableOutputDescriptorZ_1new(void* ctx_TODO, uint32_tArray elems) {
302         LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
303         ret->datalen = elems.len;
304         if (ret->datalen == 0) {
305                 ret->data = NULL;
306         } else {
307                 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
308                 uint32_t *java_elems = elems.ptr;
309                 for (size_t i = 0; i < ret->datalen; i++) {
310                         uint32_t arr_elem = java_elems[i];
311                         LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
312                         FREE((void*)arr_elem);
313                         ret->data[i] = arr_elem_conv;
314                 }
315         }
316         return (long)ret;
317 }
318 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
319         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
320         for (size_t i = 0; i < ret.datalen; i++) {
321                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
322         }
323         return ret;
324 }
325 uint32_t LDKErrorAction_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
326         LDKErrorAction *obj = (LDKErrorAction*)ptr;
327         switch(obj->tag) {
328                 case LDKErrorAction_DisconnectPeer: {
329                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
330                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
331                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
332                         long msg_ref = (long)msg_var.inner & ~1;
333                         return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
334                 }
335                 case LDKErrorAction_IgnoreError: {
336                         return 0 /* LDKErrorAction - IgnoreError */;
337                 }
338                 case LDKErrorAction_SendErrorMessage: {
339                         LDKErrorMessage msg_var = obj->send_error_message.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 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
344                 }
345                 default: abort();
346         }
347 }
348 uint32_t LDKHTLCFailChannelUpdate_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
349         LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
350         switch(obj->tag) {
351                 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
352                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
353                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
354                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
355                         long msg_ref = (long)msg_var.inner & ~1;
356                         return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
357                 }
358                 case LDKHTLCFailChannelUpdate_ChannelClosed: {
359                         return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
360                 }
361                 case LDKHTLCFailChannelUpdate_NodeFailure: {
362                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
363                         memcpy(node_id_arr.ptr, obj->node_failure.node_id.compressed_form, 33);
364                         return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
365                 }
366                 default: abort();
367         }
368 }
369 uint32_t LDKMessageSendEvent_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
370         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
371         switch(obj->tag) {
372                 case LDKMessageSendEvent_SendAcceptChannel: {
373                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
374                         memcpy(node_id_arr.ptr, obj->send_accept_channel.node_id.compressed_form, 33);
375                         LDKAcceptChannel msg_var = obj->send_accept_channel.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 - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
380                 }
381                 case LDKMessageSendEvent_SendOpenChannel: {
382                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
383                         memcpy(node_id_arr.ptr, obj->send_open_channel.node_id.compressed_form, 33);
384                         LDKOpenChannel msg_var = obj->send_open_channel.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 - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
389                 }
390                 case LDKMessageSendEvent_SendFundingCreated: {
391                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
392                         memcpy(node_id_arr.ptr, obj->send_funding_created.node_id.compressed_form, 33);
393                         LDKFundingCreated msg_var = obj->send_funding_created.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 - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
398                 }
399                 case LDKMessageSendEvent_SendFundingSigned: {
400                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
401                         memcpy(node_id_arr.ptr, obj->send_funding_signed.node_id.compressed_form, 33);
402                         LDKFundingSigned msg_var = obj->send_funding_signed.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 - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
407                 }
408                 case LDKMessageSendEvent_SendFundingLocked: {
409                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
410                         memcpy(node_id_arr.ptr, obj->send_funding_locked.node_id.compressed_form, 33);
411                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
412                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
413                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
414                         long msg_ref = (long)msg_var.inner & ~1;
415                         return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
416                 }
417                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
418                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
419                         memcpy(node_id_arr.ptr, obj->send_announcement_signatures.node_id.compressed_form, 33);
420                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.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 - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
425                 }
426                 case LDKMessageSendEvent_UpdateHTLCs: {
427                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
428                         memcpy(node_id_arr.ptr, obj->update_htl_cs.node_id.compressed_form, 33);
429                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
430                         CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
431                         CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
432                         long updates_ref = (long)updates_var.inner & ~1;
433                         return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
434                 }
435                 case LDKMessageSendEvent_SendRevokeAndACK: {
436                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
437                         memcpy(node_id_arr.ptr, obj->send_revoke_and_ack.node_id.compressed_form, 33);
438                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
439                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
440                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
441                         long msg_ref = (long)msg_var.inner & ~1;
442                         return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
443                 }
444                 case LDKMessageSendEvent_SendClosingSigned: {
445                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
446                         memcpy(node_id_arr.ptr, obj->send_closing_signed.node_id.compressed_form, 33);
447                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
448                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
449                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
450                         long msg_ref = (long)msg_var.inner & ~1;
451                         return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
452                 }
453                 case LDKMessageSendEvent_SendShutdown: {
454                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
455                         memcpy(node_id_arr.ptr, obj->send_shutdown.node_id.compressed_form, 33);
456                         LDKShutdown msg_var = obj->send_shutdown.msg;
457                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
458                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
459                         long msg_ref = (long)msg_var.inner & ~1;
460                         return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
461                 }
462                 case LDKMessageSendEvent_SendChannelReestablish: {
463                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
464                         memcpy(node_id_arr.ptr, obj->send_channel_reestablish.node_id.compressed_form, 33);
465                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
466                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
467                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
468                         long msg_ref = (long)msg_var.inner & ~1;
469                         return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
470                 }
471                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
472                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
473                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
474                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
475                         long msg_ref = (long)msg_var.inner & ~1;
476                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
477                         CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
478                         CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
479                         long update_msg_ref = (long)update_msg_var.inner & ~1;
480                         return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
481                 }
482                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
483                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
484                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
485                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
486                         long msg_ref = (long)msg_var.inner & ~1;
487                         return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
488                 }
489                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
490                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
491                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
492                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
493                         long msg_ref = (long)msg_var.inner & ~1;
494                         return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
495                 }
496                 case LDKMessageSendEvent_HandleError: {
497                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
498                         memcpy(node_id_arr.ptr, obj->handle_error.node_id.compressed_form, 33);
499                         long action_ref = (long)&obj->handle_error.action;
500                         return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
501                 }
502                 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
503                         long update_ref = (long)&obj->payment_failure_network_update.update;
504                         return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
505                 }
506                 case LDKMessageSendEvent_SendChannelRangeQuery: {
507                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
508                         memcpy(node_id_arr.ptr, obj->send_channel_range_query.node_id.compressed_form, 33);
509                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
510                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
511                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
512                         long msg_ref = (long)msg_var.inner & ~1;
513                         return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
514                 }
515                 case LDKMessageSendEvent_SendShortIdsQuery: {
516                         int8_tArray node_id_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
517                         memcpy(node_id_arr.ptr, obj->send_short_ids_query.node_id.compressed_form, 33);
518                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
519                         CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
520                         CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
521                         long msg_ref = (long)msg_var.inner & ~1;
522                         return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
523                 }
524                 default: abort();
525         }
526 }
527 uint32_t LDKCVec_1MessageSendEventZ_1new(void* ctx_TODO, uint32_tArray elems) {
528         LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
529         ret->datalen = elems.len;
530         if (ret->datalen == 0) {
531                 ret->data = NULL;
532         } else {
533                 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
534                 uint32_t *java_elems = elems.ptr;
535                 for (size_t i = 0; i < ret->datalen; i++) {
536                         uint32_t arr_elem = java_elems[i];
537                         LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
538                         FREE((void*)arr_elem);
539                         ret->data[i] = arr_elem_conv;
540                 }
541         }
542         return (long)ret;
543 }
544 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
545         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
546         for (size_t i = 0; i < ret.datalen; i++) {
547                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
548         }
549         return ret;
550 }
551 uint32_t LDKEvent_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
552         LDKEvent *obj = (LDKEvent*)ptr;
553         switch(obj->tag) {
554                 case LDKEvent_FundingGenerationReady: {
555                         int8_tArray temporary_channel_id_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
556                         memcpy(temporary_channel_id_arr.ptr, obj->funding_generation_ready.temporary_channel_id.data, 32);
557                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
558                         int8_tArray output_script_arr = { .len = output_script_var.datalen, .ptr = MALLOC(output_script_var.datalen, "Native int8_tArray Bytes") };
559                         memcpy(output_script_arr.ptr, output_script_var.data, output_script_var.datalen);
560                         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;
561                 }
562                 case LDKEvent_FundingBroadcastSafe: {
563                         LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
564                         CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
565                         CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
566                         long funding_txo_ref = (long)funding_txo_var.inner & ~1;
567                         return 0 /* LDKEvent - FundingBroadcastSafe */; (void) funding_txo_ref; (void) obj->funding_broadcast_safe.user_channel_id;
568                 }
569                 case LDKEvent_PaymentReceived: {
570                         int8_tArray payment_hash_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
571                         memcpy(payment_hash_arr.ptr, obj->payment_received.payment_hash.data, 32);
572                         int8_tArray payment_secret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
573                         memcpy(payment_secret_arr.ptr, obj->payment_received.payment_secret.data, 32);
574                         return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
575                 }
576                 case LDKEvent_PaymentSent: {
577                         int8_tArray payment_preimage_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
578                         memcpy(payment_preimage_arr.ptr, obj->payment_sent.payment_preimage.data, 32);
579                         return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
580                 }
581                 case LDKEvent_PaymentFailed: {
582                         int8_tArray payment_hash_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
583                         memcpy(payment_hash_arr.ptr, obj->payment_failed.payment_hash.data, 32);
584                         return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
585                 }
586                 case LDKEvent_PendingHTLCsForwardable: {
587                         return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
588                 }
589                 case LDKEvent_SpendableOutputs: {
590                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
591                         uint32_tArray outputs_arr = { .len = outputs_var.datalen, .ptr = MALLOC(outputs_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
592                         uint32_t *outputs_arr_ptr = outputs_arr.ptr;
593                         for (size_t b = 0; b < outputs_var.datalen; b++) {
594                                 long arr_conv_27_ref = (long)&outputs_var.data[b];
595                                 outputs_arr_ptr[b] = arr_conv_27_ref;
596                         }
597                         return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
598                 }
599                 default: abort();
600         }
601 }
602 uint32_t LDKCVec_1EventZ_1new(void* ctx_TODO, uint32_tArray elems) {
603         LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
604         ret->datalen = elems.len;
605         if (ret->datalen == 0) {
606                 ret->data = NULL;
607         } else {
608                 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
609                 uint32_t *java_elems = elems.ptr;
610                 for (size_t i = 0; i < ret->datalen; i++) {
611                         uint32_t arr_elem = java_elems[i];
612                         LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
613                         FREE((void*)arr_elem);
614                         ret->data[i] = arr_elem_conv;
615                 }
616         }
617         return (long)ret;
618 }
619 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
620         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
621         for (size_t i = 0; i < ret.datalen; i++) {
622                 ret.data[i] = Event_clone(&orig->data[i]);
623         }
624         return ret;
625 }
626 uint32_t LDKC2Tuple_1usizeTransactionZ_1new(void* ctx_TODO, int64_t a, int8_tArray b) {
627         LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
628         ret->a = a;
629         LDKTransaction b_ref;
630         b_ref.datalen = b.len;
631         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
632         memcpy(b_ref.data, b.ptr, b_ref.datalen);
633         b_ref.data_is_owned = false;
634         ret->b = b_ref;
635         return (long)ret;
636 }
637 int64_t LDKC2Tuple_1usizeTransactionZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
638         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)ptr;
639         return tuple->a;
640 }
641 int8_tArray LDKC2Tuple_1usizeTransactionZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
642         LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)ptr;
643         LDKTransaction b_var = tuple->b;
644         int8_tArray b_arr = { .len = b_var.datalen, .ptr = MALLOC(b_var.datalen, "Native int8_tArray Bytes") };
645         memcpy(b_arr.ptr, b_var.data, b_var.datalen);
646         return b_arr;
647 }
648 uint32_t LDKCVec_1C2Tuple_1usizeTransactionZZ_1new(void* ctx_TODO, uint32_tArray elems) {
649         LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
650         ret->datalen = elems.len;
651         if (ret->datalen == 0) {
652                 ret->data = NULL;
653         } else {
654                 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
655                 uint32_t *java_elems = elems.ptr;
656                 for (size_t i = 0; i < ret->datalen; i++) {
657                         uint32_t arr_elem = java_elems[i];
658                         LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_elem;
659                         FREE((void*)arr_elem);
660                         ret->data[i] = arr_elem_conv;
661                 }
662         }
663         return (long)ret;
664 }
665 jboolean LDKCResult_1NoneChannelMonitorUpdateErrZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
666         return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
667 }
668 void LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
669         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
670         CHECK(val->result_ok);
671         return *val->contents.result;
672 }
673 uint32_t LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err (void* ctx_TODO, uint32_t arg) {
674         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
675         CHECK(!val->result_ok);
676         uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
677         return err_conv;
678 }
679 static inline LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const LDKCResult_NoneChannelMonitorUpdateErrZ *orig) {
680         LDKCResult_NoneChannelMonitorUpdateErrZ res = { .result_ok = orig->result_ok };
681         if (orig->result_ok) {
682                 res.contents.result = NULL;
683         } else {
684                 LDKChannelMonitorUpdateErr* contents = MALLOC(sizeof(LDKChannelMonitorUpdateErr), "LDKChannelMonitorUpdateErr result Err clone");
685                 *contents = ChannelMonitorUpdateErr_clone(orig->contents.err);
686                 res.contents.err = contents;
687         }
688         return res;
689 }
690 uint32_t LDKCVec_1MonitorEventZ_1new(void* ctx_TODO, uint32_tArray elems) {
691         LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
692         ret->datalen = elems.len;
693         if (ret->datalen == 0) {
694                 ret->data = NULL;
695         } else {
696                 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
697                 uint32_t *java_elems = elems.ptr;
698                 for (size_t i = 0; i < ret->datalen; i++) {
699                         uint32_t arr_elem = java_elems[i];
700                         LDKMonitorEvent arr_elem_conv;
701                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
702                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
703                         if (arr_elem_conv.inner != NULL)
704                                 arr_elem_conv = MonitorEvent_clone(&arr_elem_conv);
705                         ret->data[i] = arr_elem_conv;
706                 }
707         }
708         return (long)ret;
709 }
710 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
711         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
712         for (size_t i = 0; i < ret.datalen; i++) {
713                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
714         }
715         return ret;
716 }
717 jboolean LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
718         return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
719 }
720 uint32_t LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
721         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg;
722         CHECK(val->result_ok);
723         LDKChannelMonitorUpdate res_var = (*val->contents.result);
724         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
725         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
726         long res_ref = (long)res_var.inner & ~1;
727         return res_ref;
728 }
729 uint32_t LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
730         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg;
731         CHECK(!val->result_ok);
732         LDKDecodeError err_var = (*val->contents.err);
733         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
734         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
735         long err_ref = (long)err_var.inner & ~1;
736         return err_ref;
737 }
738 jboolean LDKCResult_1NoneMonitorUpdateErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
739         return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
740 }
741 void LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
742         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
743         CHECK(val->result_ok);
744         return *val->contents.result;
745 }
746 uint32_t LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
747         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
748         CHECK(!val->result_ok);
749         LDKMonitorUpdateError err_var = (*val->contents.err);
750         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
751         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
752         long err_ref = (long)err_var.inner & ~1;
753         return err_ref;
754 }
755 uint32_t LDKC2Tuple_1OutPointScriptZ_1new(void* ctx_TODO, uint32_t a, int8_tArray b) {
756         LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
757         LDKOutPoint a_conv;
758         a_conv.inner = (void*)(a & (~1));
759         a_conv.is_owned = (a & 1) || (a == 0);
760         if (a_conv.inner != NULL)
761                 a_conv = OutPoint_clone(&a_conv);
762         ret->a = a_conv;
763         LDKCVec_u8Z b_ref;
764         b_ref.datalen = b.len;
765         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
766         memcpy(b_ref.data, b.ptr, b_ref.datalen);
767         ret->b = b_ref;
768         return (long)ret;
769 }
770 static inline LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const LDKC2Tuple_OutPointScriptZ *orig) {
771         LDKC2Tuple_OutPointScriptZ ret = {
772                 .a = OutPoint_clone(&orig->a),
773                 .b = CVec_u8Z_clone(&orig->b),
774         };
775         return ret;
776 }
777 uint32_t LDKC2Tuple_1OutPointScriptZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
778         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
779         LDKOutPoint a_var = tuple->a;
780         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
781         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
782         long a_ref = (long)a_var.inner & ~1;
783         return a_ref;
784 }
785 int8_tArray LDKC2Tuple_1OutPointScriptZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
786         LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
787         LDKCVec_u8Z b_var = tuple->b;
788         int8_tArray b_arr = { .len = b_var.datalen, .ptr = MALLOC(b_var.datalen, "Native int8_tArray Bytes") };
789         memcpy(b_arr.ptr, b_var.data, b_var.datalen);
790         return b_arr;
791 }
792 uint32_t LDKC2Tuple_1u32TxOutZ_1new(void* ctx_TODO, int32_t a, uint32_t b) {
793         LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
794         ret->a = a;
795         LDKTxOut b_conv = *(LDKTxOut*)b;
796         FREE((void*)b);
797         ret->b = b_conv;
798         return (long)ret;
799 }
800 int32_t LDKC2Tuple_1u32TxOutZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
801         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
802         return tuple->a;
803 }
804 uint32_t LDKC2Tuple_1u32TxOutZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
805         LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
806         long b_ref = (long)&tuple->b;
807         return (long)b_ref;
808 }
809 uint32_t LDKCVec_1C2Tuple_1u32TxOutZZ_1new(void* ctx_TODO, uint32_tArray elems) {
810         LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
811         ret->datalen = elems.len;
812         if (ret->datalen == 0) {
813                 ret->data = NULL;
814         } else {
815                 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
816                 uint32_t *java_elems = elems.ptr;
817                 for (size_t i = 0; i < ret->datalen; i++) {
818                         uint32_t arr_elem = java_elems[i];
819                         LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)arr_elem;
820                         FREE((void*)arr_elem);
821                         ret->data[i] = arr_elem_conv;
822                 }
823         }
824         return (long)ret;
825 }
826 uint32_t LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(void* ctx_TODO, int8_tArray a, uint32_tArray b) {
827         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
828         LDKThirtyTwoBytes a_ref;
829         CHECK(a.len == 32);
830         memcpy(a_ref.data, a.ptr, 32);
831         ret->a = a_ref;
832         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
833         b_constr.datalen = b.len;
834         if (b_constr.datalen > 0)
835                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
836         else
837                 b_constr.data = NULL;
838         uint32_t* b_vals = (uint32_t*) b.ptr;
839         for (size_t a = 0; a < b_constr.datalen; a++) {
840                 uint32_t arr_conv_26 = b_vals[a];
841                 LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_26;
842                 FREE((void*)arr_conv_26);
843                 b_constr.data[a] = arr_conv_26_conv;
844         }
845         ret->b = b_constr;
846         return (long)ret;
847 }
848 int8_tArray LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
849         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
850         int8_tArray a_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
851         memcpy(a_arr.ptr, tuple->a.data, 32);
852         return a_arr;
853 }
854 uint32_tArray LDKC2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
855         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
856         LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
857         uint32_tArray b_arr = { .len = b_var.datalen, .ptr = MALLOC(b_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
858         uint32_t *b_arr_ptr = b_arr.ptr;
859         for (size_t a = 0; a < b_var.datalen; a++) {
860                 long arr_conv_26_ref = (long)&b_var.data[a];
861                 b_arr_ptr[a] = arr_conv_26_ref;
862         }
863         return b_arr;
864 }
865 uint32_t LDKCVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1new(void* ctx_TODO, uint32_tArray elems) {
866         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
867         ret->datalen = elems.len;
868         if (ret->datalen == 0) {
869                 ret->data = NULL;
870         } else {
871                 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
872                 uint32_t *java_elems = elems.ptr;
873                 for (size_t i = 0; i < ret->datalen; i++) {
874                         uint32_t arr_elem = java_elems[i];
875                         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)arr_elem;
876                         FREE((void*)arr_elem);
877                         ret->data[i] = arr_elem_conv;
878                 }
879         }
880         return (long)ret;
881 }
882 uint32_t LDKC2Tuple_1SignatureCVec_1SignatureZZ_1new(void* ctx_TODO, int8_tArray a, uint32_tArray b) {
883         LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
884         LDKSignature a_ref;
885         CHECK(a.len == 64);
886         memcpy(a_ref.compact_form, a.ptr, 64);
887         ret->a = a_ref;
888         LDKCVec_SignatureZ b_constr;
889         b_constr.datalen = b.len;
890         if (b_constr.datalen > 0)
891                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
892         else
893                 b_constr.data = NULL;
894         int8_tArray* b_vals = (int8_tArray*) b.ptr;
895         for (size_t i = 0; i < b_constr.datalen; i++) {
896                 int8_tArray arr_conv_8 = b_vals[i];
897                 LDKSignature arr_conv_8_ref;
898                 CHECK(arr_conv_8.len == 64);
899                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
900                 b_constr.data[i] = arr_conv_8_ref;
901         }
902         ret->b = b_constr;
903         return (long)ret;
904 }
905 int8_tArray LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
906         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)ptr;
907         int8_tArray a_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
908         memcpy(a_arr.ptr, tuple->a.compact_form, 64);
909         return a_arr;
910 }
911 uint32_tArray LDKC2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
912         LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)ptr;
913         LDKCVec_SignatureZ b_var = tuple->b;
914         uint32_tArray b_arr = (*env)->NewObjectArray(env, b_var.datalen, arr_of_B_clz, NULL);
915         for (size_t i = 0; i < b_var.datalen; i++) {
916                 int8_tArray arr_conv_8_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
917                 memcpy(arr_conv_8_arr.ptr, b_var.data[i].compact_form, 64);
918                 (*env)->SetObjectArrayElement(env, b_arr, i, arr_conv_8_arr);
919         }
920         return b_arr;
921 }
922 jboolean LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
923         return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
924 }
925 uint32_t LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
926         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
927         CHECK(val->result_ok);
928         long res_ref = (long)&(*val->contents.result);
929         return res_ref;
930 }
931 void LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err (void* ctx_TODO, uint32_t arg) {
932         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
933         CHECK(!val->result_ok);
934         return *val->contents.err;
935 }
936 jboolean LDKCResult_1SignatureNoneZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
937         return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
938 }
939 int8_tArray LDKCResult_1SignatureNoneZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
940         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
941         CHECK(val->result_ok);
942         int8_tArray res_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
943         memcpy(res_arr.ptr, (*val->contents.result).compact_form, 64);
944         return res_arr;
945 }
946 void LDKCResult_1SignatureNoneZ_1get_1err (void* ctx_TODO, uint32_t arg) {
947         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
948         CHECK(!val->result_ok);
949         return *val->contents.err;
950 }
951 jboolean LDKCResult_1CVec_1SignatureZNoneZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
952         return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
953 }
954 uint32_tArray LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
955         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
956         CHECK(val->result_ok);
957         LDKCVec_SignatureZ res_var = (*val->contents.result);
958         uint32_tArray res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
959         for (size_t i = 0; i < res_var.datalen; i++) {
960                 int8_tArray arr_conv_8_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
961                 memcpy(arr_conv_8_arr.ptr, res_var.data[i].compact_form, 64);
962                 (*env)->SetObjectArrayElement(env, res_arr, i, arr_conv_8_arr);
963         }
964         return res_arr;
965 }
966 void LDKCResult_1CVec_1SignatureZNoneZ_1get_1err (void* ctx_TODO, uint32_t arg) {
967         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
968         CHECK(!val->result_ok);
969         return *val->contents.err;
970 }
971 int8_tArray ChannelKeys_1get_1per_1commitment_1point(void* ctx_TODO, uint32_t this_arg, int64_t idx) {
972         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
973         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
974         memcpy(arg_arr.ptr, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
975         return arg_arr;
976 }
977
978 int8_tArray ChannelKeys_1release_1commitment_1secret(void* ctx_TODO, uint32_t this_arg, int64_t idx) {
979         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
980         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
981         memcpy(arg_arr.ptr, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
982         return arg_arr;
983 }
984
985 uint32_t ChannelKeys_1key_1derivation_1params(void* ctx_TODO, uint32_t this_arg) {
986         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
987         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
988         *ret_ref = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
989         return (long)ret_ref;
990 }
991
992 uint32_t ChannelKeys_1sign_1counterparty_1commitment(void* ctx_TODO, uint32_t this_arg, uint32_t commitment_tx) {
993         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
994         LDKCommitmentTransaction commitment_tx_conv;
995         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
996         commitment_tx_conv.is_owned = false;
997         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
998         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
999         return (long)ret_conv;
1000 }
1001
1002 uint32_t ChannelKeys_1sign_1holder_1commitment(void* ctx_TODO, uint32_t this_arg, uint32_t commitment_tx) {
1003         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1004         LDKHolderCommitmentTransaction commitment_tx_conv;
1005         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1006         commitment_tx_conv.is_owned = false;
1007         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1008         *ret_conv = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1009         return (long)ret_conv;
1010 }
1011
1012 uint32_t ChannelKeys_1sign_1holder_1commitment_1htlc_1transactions(void* ctx_TODO, uint32_t this_arg, uint32_t commitment_tx) {
1013         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1014         LDKHolderCommitmentTransaction commitment_tx_conv;
1015         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1016         commitment_tx_conv.is_owned = false;
1017         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1018         *ret_conv = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &commitment_tx_conv);
1019         return (long)ret_conv;
1020 }
1021
1022 uint32_t ChannelKeys_1sign_1justice_1transaction(void* ctx_TODO, uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
1023         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1024         LDKTransaction justice_tx_ref;
1025         justice_tx_ref.datalen = justice_tx.len;
1026         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1027         memcpy(justice_tx_ref.data, justice_tx.ptr, justice_tx_ref.datalen);
1028         justice_tx_ref.data_is_owned = true;
1029         unsigned char per_commitment_key_arr[32];
1030         CHECK(per_commitment_key.len == 32);
1031         memcpy(per_commitment_key_arr, per_commitment_key.ptr, 32);
1032         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1033         LDKHTLCOutputInCommitment htlc_conv;
1034         htlc_conv.inner = (void*)(htlc & (~1));
1035         htlc_conv.is_owned = false;
1036         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1037         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1038         return (long)ret_conv;
1039 }
1040
1041 uint32_t ChannelKeys_1sign_1counterparty_1htlc_1transaction(void* ctx_TODO, uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
1042         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1043         LDKTransaction htlc_tx_ref;
1044         htlc_tx_ref.datalen = htlc_tx.len;
1045         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1046         memcpy(htlc_tx_ref.data, htlc_tx.ptr, htlc_tx_ref.datalen);
1047         htlc_tx_ref.data_is_owned = true;
1048         LDKPublicKey per_commitment_point_ref;
1049         CHECK(per_commitment_point.len == 33);
1050         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
1051         LDKHTLCOutputInCommitment htlc_conv;
1052         htlc_conv.inner = (void*)(htlc & (~1));
1053         htlc_conv.is_owned = false;
1054         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1055         *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);
1056         return (long)ret_conv;
1057 }
1058
1059 uint32_t ChannelKeys_1sign_1closing_1transaction(void* ctx_TODO, uint32_t this_arg, int8_tArray closing_tx) {
1060         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1061         LDKTransaction closing_tx_ref;
1062         closing_tx_ref.datalen = closing_tx.len;
1063         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1064         memcpy(closing_tx_ref.data, closing_tx.ptr, closing_tx_ref.datalen);
1065         closing_tx_ref.data_is_owned = true;
1066         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1067         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1068         return (long)ret_conv;
1069 }
1070
1071 uint32_t ChannelKeys_1sign_1channel_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
1072         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1073         LDKUnsignedChannelAnnouncement msg_conv;
1074         msg_conv.inner = (void*)(msg & (~1));
1075         msg_conv.is_owned = false;
1076         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1077         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1078         return (long)ret_conv;
1079 }
1080
1081 void ChannelKeys_1ready_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t channel_parameters) {
1082         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1083         LDKChannelTransactionParameters channel_parameters_conv;
1084         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1085         channel_parameters_conv.is_owned = false;
1086         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1087 }
1088
1089 int8_tArray ChannelKeys_1write(void* ctx_TODO, uint32_t this_arg) {
1090         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1091         LDKCVec_u8Z arg_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1092         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
1093         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
1094         CVec_u8Z_free(arg_var);
1095         return arg_arr;
1096 }
1097
1098 LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* this_arg) {
1099         if (this_arg->set_pubkeys != NULL)
1100                 this_arg->set_pubkeys(this_arg);
1101         return this_arg->pubkeys;
1102 }
1103 uint32_t ChannelKeys_1get_1pubkeys(void* ctx_TODO, uint32_t this_arg) {
1104         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1105         LDKChannelPublicKeys ret_var = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
1106         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1107         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1108         long ret_ref = (long)ret_var.inner;
1109         if (ret_var.is_owned) {
1110                 ret_ref |= 1;
1111         }
1112         return ret_ref;
1113 }
1114
1115 uint32_t LDKC2Tuple_1BlockHashChannelMonitorZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) {
1116         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1117         LDKThirtyTwoBytes a_ref;
1118         CHECK(a.len == 32);
1119         memcpy(a_ref.data, a.ptr, 32);
1120         ret->a = a_ref;
1121         LDKChannelMonitor b_conv;
1122         b_conv.inner = (void*)(b & (~1));
1123         b_conv.is_owned = (b & 1) || (b == 0);
1124         // Warning: we may need a move here but can't clone!
1125         ret->b = b_conv;
1126         return (long)ret;
1127 }
1128 int8_tArray LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
1129         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
1130         int8_tArray a_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1131         memcpy(a_arr.ptr, tuple->a.data, 32);
1132         return a_arr;
1133 }
1134 uint32_t LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
1135         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
1136         LDKChannelMonitor b_var = tuple->b;
1137         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1138         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1139         long b_ref = (long)b_var.inner & ~1;
1140         return b_ref;
1141 }
1142 jboolean LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1143         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
1144 }
1145 uint32_t LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1146         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
1147         CHECK(val->result_ok);
1148         long res_ref = (long)&(*val->contents.result);
1149         return res_ref;
1150 }
1151 uint32_t LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1152         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
1153         CHECK(!val->result_ok);
1154         LDKDecodeError err_var = (*val->contents.err);
1155         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1156         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1157         long err_ref = (long)err_var.inner & ~1;
1158         return err_ref;
1159 }
1160 jboolean LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1161         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1162 }
1163 uint32_t LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1164         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
1165         CHECK(val->result_ok);
1166         long res_ref = (long)&(*val->contents.result);
1167         return res_ref;
1168 }
1169 uint32_t LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1170         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
1171         CHECK(!val->result_ok);
1172         LDKDecodeError err_var = (*val->contents.err);
1173         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1174         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1175         long err_ref = (long)err_var.inner & ~1;
1176         return err_ref;
1177 }
1178 jboolean LDKCResult_1ChanKeySignerDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1179         return ((LDKCResult_ChanKeySignerDecodeErrorZ*)arg)->result_ok;
1180 }
1181 uint32_t LDKCResult_1ChanKeySignerDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1182         LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
1183         CHECK(val->result_ok);
1184         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1185         *ret = (*val->contents.result);
1186         return (long)ret;
1187 }
1188 uint32_t LDKCResult_1ChanKeySignerDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1189         LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
1190         CHECK(!val->result_ok);
1191         LDKDecodeError err_var = (*val->contents.err);
1192         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1193         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1194         long err_ref = (long)err_var.inner & ~1;
1195         return err_ref;
1196 }
1197 jboolean LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1198         return ((LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg)->result_ok;
1199 }
1200 uint32_t LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1201         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
1202         CHECK(val->result_ok);
1203         LDKInMemoryChannelKeys res_var = (*val->contents.result);
1204         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1205         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1206         long res_ref = (long)res_var.inner & ~1;
1207         return res_ref;
1208 }
1209 uint32_t LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1210         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
1211         CHECK(!val->result_ok);
1212         LDKDecodeError err_var = (*val->contents.err);
1213         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1214         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1215         long err_ref = (long)err_var.inner & ~1;
1216         return err_ref;
1217 }
1218 jboolean LDKCResult_1TxOutAccessErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1219         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1220 }
1221 uint32_t LDKCResult_1TxOutAccessErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1222         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1223         CHECK(val->result_ok);
1224         long res_ref = (long)&(*val->contents.result);
1225         return (long)res_ref;
1226 }
1227 uint32_t LDKCResult_1TxOutAccessErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1228         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1229         CHECK(!val->result_ok);
1230         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
1231         return err_conv;
1232 }
1233 uint32_t LDKAPIError_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
1234         LDKAPIError *obj = (LDKAPIError*)ptr;
1235         switch(obj->tag) {
1236                 case LDKAPIError_APIMisuseError: {
1237                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
1238                         int8_tArray err_arr = { .len = err_var.datalen, .ptr = MALLOC(err_var.datalen, "Native int8_tArray Bytes") };
1239                         memcpy(err_arr.ptr, err_var.data, err_var.datalen);
1240                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
1241                 }
1242                 case LDKAPIError_FeeRateTooHigh: {
1243                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
1244                         int8_tArray err_arr = { .len = err_var.datalen, .ptr = MALLOC(err_var.datalen, "Native int8_tArray Bytes") };
1245                         memcpy(err_arr.ptr, err_var.data, err_var.datalen);
1246                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
1247                 }
1248                 case LDKAPIError_RouteError: {
1249                         LDKStr err_str = obj->route_error.err;
1250                         char* err_buf = MALLOC(err_str.len + 1, "str conv buf");
1251                         memcpy(err_buf, err_str.chars, err_str.len);
1252                         err_buf[err_str.len] = 0;
1253                         jstring err_conv = (*env)->NewStringUTF(env, err_str.chars);
1254                         FREE(err_buf);
1255                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
1256                 }
1257                 case LDKAPIError_ChannelUnavailable: {
1258                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
1259                         int8_tArray err_arr = { .len = err_var.datalen, .ptr = MALLOC(err_var.datalen, "Native int8_tArray Bytes") };
1260                         memcpy(err_arr.ptr, err_var.data, err_var.datalen);
1261                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
1262                 }
1263                 case LDKAPIError_MonitorUpdateFailed: {
1264                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
1265                 }
1266                 default: abort();
1267         }
1268 }
1269 jboolean LDKCResult_1NoneAPIErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1270         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
1271 }
1272 void LDKCResult_1NoneAPIErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1273         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
1274         CHECK(val->result_ok);
1275         return *val->contents.result;
1276 }
1277 uint32_t LDKCResult_1NoneAPIErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1278         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
1279         CHECK(!val->result_ok);
1280         long err_ref = (long)&(*val->contents.err);
1281         return err_ref;
1282 }
1283 static inline LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const LDKCResult_NoneAPIErrorZ *orig) {
1284         LDKCResult_NoneAPIErrorZ res = { .result_ok = orig->result_ok };
1285         if (orig->result_ok) {
1286                 res.contents.result = NULL;
1287         } else {
1288                 LDKAPIError* contents = MALLOC(sizeof(LDKAPIError), "LDKAPIError result Err clone");
1289                 *contents = APIError_clone(orig->contents.err);
1290                 res.contents.err = contents;
1291         }
1292         return res;
1293 }
1294 uint32_t LDKCVec_1ChannelDetailsZ_1new(void* ctx_TODO, uint32_tArray elems) {
1295         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1296         ret->datalen = elems.len;
1297         if (ret->datalen == 0) {
1298                 ret->data = NULL;
1299         } else {
1300                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1301                 uint32_t *java_elems = elems.ptr;
1302                 for (size_t i = 0; i < ret->datalen; i++) {
1303                         uint32_t arr_elem = java_elems[i];
1304                         LDKChannelDetails arr_elem_conv;
1305                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1306                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1307                         if (arr_elem_conv.inner != NULL)
1308                                 arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1309                         ret->data[i] = arr_elem_conv;
1310                 }
1311         }
1312         return (long)ret;
1313 }
1314 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1315         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1316         for (size_t i = 0; i < ret.datalen; i++) {
1317                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1318         }
1319         return ret;
1320 }
1321 jboolean LDKCResult_1NonePaymentSendFailureZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1322         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
1323 }
1324 void LDKCResult_1NonePaymentSendFailureZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1325         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
1326         CHECK(val->result_ok);
1327         return *val->contents.result;
1328 }
1329 uint32_t LDKCResult_1NonePaymentSendFailureZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1330         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
1331         CHECK(!val->result_ok);
1332         LDKPaymentSendFailure err_var = (*val->contents.err);
1333         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1334         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1335         long err_ref = (long)err_var.inner & ~1;
1336         return err_ref;
1337 }
1338 uint32_t LDKNetAddress_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
1339         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1340         switch(obj->tag) {
1341                 case LDKNetAddress_IPv4: {
1342                         int8_tArray addr_arr = { .len = 4, .ptr = MALLOC(4, "Native int8_tArray Bytes") };
1343                         memcpy(addr_arr.ptr, obj->i_pv4.addr.data, 4);
1344                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
1345                 }
1346                 case LDKNetAddress_IPv6: {
1347                         int8_tArray addr_arr = { .len = 16, .ptr = MALLOC(16, "Native int8_tArray Bytes") };
1348                         memcpy(addr_arr.ptr, obj->i_pv6.addr.data, 16);
1349                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
1350                 }
1351                 case LDKNetAddress_OnionV2: {
1352                         int8_tArray addr_arr = { .len = 10, .ptr = MALLOC(10, "Native int8_tArray Bytes") };
1353                         memcpy(addr_arr.ptr, obj->onion_v2.addr.data, 10);
1354                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
1355                 }
1356                 case LDKNetAddress_OnionV3: {
1357                         int8_tArray ed25519_pubkey_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1358                         memcpy(ed25519_pubkey_arr.ptr, obj->onion_v3.ed25519_pubkey.data, 32);
1359                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
1360                 }
1361                 default: abort();
1362         }
1363 }
1364 uint32_t LDKCVec_1NetAddressZ_1new(void* ctx_TODO, uint32_tArray elems) {
1365         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1366         ret->datalen = elems.len;
1367         if (ret->datalen == 0) {
1368                 ret->data = NULL;
1369         } else {
1370                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1371                 uint32_t *java_elems = elems.ptr;
1372                 for (size_t i = 0; i < ret->datalen; i++) {
1373                         uint32_t arr_elem = java_elems[i];
1374                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
1375                         FREE((void*)arr_elem);
1376                         ret->data[i] = arr_elem_conv;
1377                 }
1378         }
1379         return (long)ret;
1380 }
1381 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1382         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1383         for (size_t i = 0; i < ret.datalen; i++) {
1384                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1385         }
1386         return ret;
1387 }
1388 uint32_t LDKCVec_1ChannelMonitorZ_1new(void* ctx_TODO, uint32_tArray elems) {
1389         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
1390         ret->datalen = elems.len;
1391         if (ret->datalen == 0) {
1392                 ret->data = NULL;
1393         } else {
1394                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
1395                 uint32_t *java_elems = elems.ptr;
1396                 for (size_t i = 0; i < ret->datalen; i++) {
1397                         uint32_t arr_elem = java_elems[i];
1398                         LDKChannelMonitor arr_elem_conv;
1399                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1400                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1401                         // Warning: we may need a move here but can't clone!
1402                         ret->data[i] = arr_elem_conv;
1403                 }
1404         }
1405         return (long)ret;
1406 }
1407 uint32_t Watch_1watch_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
1408         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1409         LDKOutPoint funding_txo_conv;
1410         funding_txo_conv.inner = (void*)(funding_txo & (~1));
1411         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1412         if (funding_txo_conv.inner != NULL)
1413                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1414         LDKChannelMonitor monitor_conv;
1415         monitor_conv.inner = (void*)(monitor & (~1));
1416         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
1417         // Warning: we may need a move here but can't clone!
1418         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1419         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
1420         return (long)ret_conv;
1421 }
1422
1423 uint32_t Watch_1update_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
1424         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1425         LDKOutPoint funding_txo_conv;
1426         funding_txo_conv.inner = (void*)(funding_txo & (~1));
1427         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1428         if (funding_txo_conv.inner != NULL)
1429                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1430         LDKChannelMonitorUpdate update_conv;
1431         update_conv.inner = (void*)(update & (~1));
1432         update_conv.is_owned = (update & 1) || (update == 0);
1433         if (update_conv.inner != NULL)
1434                 update_conv = ChannelMonitorUpdate_clone(&update_conv);
1435         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1436         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
1437         return (long)ret_conv;
1438 }
1439
1440 uint32_tArray Watch_1release_1pending_1monitor_1events(void* ctx_TODO, uint32_t this_arg) {
1441         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1442         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
1443         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
1444         uint32_t *ret_arr_ptr = ret_arr.ptr;
1445         for (size_t o = 0; o < ret_var.datalen; o++) {
1446                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
1447                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1448                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1449                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
1450                 if (arr_conv_14_var.is_owned) {
1451                         arr_conv_14_ref |= 1;
1452                 }
1453                 ret_arr_ptr[o] = arr_conv_14_ref;
1454         }
1455         FREE(ret_var.data);
1456         return ret_arr;
1457 }
1458
1459 void BroadcasterInterface_1broadcast_1transaction(void* ctx_TODO, uint32_t this_arg, int8_tArray tx) {
1460         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
1461         LDKTransaction tx_ref;
1462         tx_ref.datalen = tx.len;
1463         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
1464         memcpy(tx_ref.data, tx.ptr, tx_ref.datalen);
1465         tx_ref.data_is_owned = true;
1466         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
1467 }
1468
1469 int8_tArray KeysInterface_1get_1node_1secret(void* ctx_TODO, uint32_t this_arg) {
1470         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1471         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1472         memcpy(arg_arr.ptr, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
1473         return arg_arr;
1474 }
1475
1476 int8_tArray KeysInterface_1get_1destination_1script(void* ctx_TODO, uint32_t this_arg) {
1477         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1478         LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
1479         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
1480         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
1481         CVec_u8Z_free(arg_var);
1482         return arg_arr;
1483 }
1484
1485 int8_tArray KeysInterface_1get_1shutdown_1pubkey(void* ctx_TODO, uint32_t this_arg) {
1486         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1487         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
1488         memcpy(arg_arr.ptr, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
1489         return arg_arr;
1490 }
1491
1492 uint32_t KeysInterface_1get_1channel_1keys(void* ctx_TODO, uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
1493         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1494         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1495         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
1496         return (long)ret;
1497 }
1498
1499 int8_tArray KeysInterface_1get_1secure_1random_1bytes(void* ctx_TODO, uint32_t this_arg) {
1500         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1501         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1502         memcpy(arg_arr.ptr, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
1503         return arg_arr;
1504 }
1505
1506 uint32_t KeysInterface_1read_1chan_1signer(void* ctx_TODO, uint32_t this_arg, int8_tArray reader) {
1507         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1508         LDKu8slice reader_ref;
1509         reader_ref.datalen = reader.len;
1510         reader_ref.data = reader.ptr;
1511         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
1512         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
1513         return (long)ret_conv;
1514 }
1515
1516 int32_t FeeEstimator_1get_1est_1sat_1per_11000_1weight(void* ctx_TODO, uint32_t this_arg, uint32_t confirmation_target) {
1517         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
1518         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
1519         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
1520         return ret_val;
1521 }
1522
1523 uint32_t LDKC2Tuple_1BlockHashChannelManagerZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) {
1524         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
1525         LDKThirtyTwoBytes a_ref;
1526         CHECK(a.len == 32);
1527         memcpy(a_ref.data, a.ptr, 32);
1528         ret->a = a_ref;
1529         LDKChannelManager b_conv;
1530         b_conv.inner = (void*)(b & (~1));
1531         b_conv.is_owned = (b & 1) || (b == 0);
1532         // Warning: we may need a move here but can't clone!
1533         ret->b = b_conv;
1534         return (long)ret;
1535 }
1536 int8_tArray LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
1537         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)ptr;
1538         int8_tArray a_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1539         memcpy(a_arr.ptr, tuple->a.data, 32);
1540         return a_arr;
1541 }
1542 uint32_t LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
1543         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)ptr;
1544         LDKChannelManager b_var = tuple->b;
1545         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1546         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1547         long b_ref = (long)b_var.inner & ~1;
1548         return b_ref;
1549 }
1550 jboolean LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1551         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
1552 }
1553 uint32_t LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1554         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg;
1555         CHECK(val->result_ok);
1556         long res_ref = (long)&(*val->contents.result);
1557         return res_ref;
1558 }
1559 uint32_t LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1560         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg;
1561         CHECK(!val->result_ok);
1562         LDKDecodeError err_var = (*val->contents.err);
1563         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1564         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1565         long err_ref = (long)err_var.inner & ~1;
1566         return err_ref;
1567 }
1568 jboolean LDKCResult_1NetAddressu8Z_1result_1ok (void* ctx_TODO, uint32_t arg) {
1569         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
1570 }
1571 uint32_t LDKCResult_1NetAddressu8Z_1get_1ok (void* ctx_TODO, uint32_t arg) {
1572         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)arg;
1573         CHECK(val->result_ok);
1574         long res_ref = (long)&(*val->contents.result);
1575         return res_ref;
1576 }
1577 int8_t LDKCResult_1NetAddressu8Z_1get_1err (void* ctx_TODO, uint32_t arg) {
1578         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)arg;
1579         CHECK(!val->result_ok);
1580         return *val->contents.err;
1581 }
1582 static inline LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const LDKCResult_NetAddressu8Z *orig) {
1583         LDKCResult_NetAddressu8Z res = { .result_ok = orig->result_ok };
1584         if (orig->result_ok) {
1585                 LDKNetAddress* contents = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress result OK clone");
1586                 *contents = NetAddress_clone(orig->contents.result);
1587                 res.contents.result = contents;
1588         } else {
1589                 int8_t* contents = MALLOC(sizeof(int8_t), "int8_t result Err clone");
1590                 *contents = *orig->contents.err;
1591                 res.contents.err = contents;
1592         }
1593         return res;
1594 }
1595 jboolean LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1596         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
1597 }
1598 uint32_t LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1599         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg;
1600         CHECK(val->result_ok);
1601         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
1602         *res_conv = (*val->contents.result);
1603         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
1604         return (long)res_conv;
1605 }
1606 uint32_t LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1607         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg;
1608         CHECK(!val->result_ok);
1609         LDKDecodeError err_var = (*val->contents.err);
1610         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1611         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1612         long err_ref = (long)err_var.inner & ~1;
1613         return err_ref;
1614 }
1615 uint32_t LDKCVec_1u64Z_1new(void* ctx_TODO, int64_tArray elems) {
1616         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1617         ret->datalen = elems.len;
1618         if (ret->datalen == 0) {
1619                 ret->data = NULL;
1620         } else {
1621                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1622                 int64_t *java_elems = elems.ptr;
1623                 for (size_t i = 0; i < ret->datalen; i++) {
1624                         ret->data[i] = java_elems[i];
1625                 }
1626         }
1627         return (long)ret;
1628 }
1629 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1630         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1631         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1632         return ret;
1633 }
1634 uint32_t LDKCVec_1UpdateAddHTLCZ_1new(void* ctx_TODO, uint32_tArray elems) {
1635         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
1636         ret->datalen = elems.len;
1637         if (ret->datalen == 0) {
1638                 ret->data = NULL;
1639         } else {
1640                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
1641                 uint32_t *java_elems = elems.ptr;
1642                 for (size_t i = 0; i < ret->datalen; i++) {
1643                         uint32_t arr_elem = java_elems[i];
1644                         LDKUpdateAddHTLC arr_elem_conv;
1645                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1646                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1647                         if (arr_elem_conv.inner != NULL)
1648                                 arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
1649                         ret->data[i] = arr_elem_conv;
1650                 }
1651         }
1652         return (long)ret;
1653 }
1654 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
1655         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
1656         for (size_t i = 0; i < ret.datalen; i++) {
1657                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
1658         }
1659         return ret;
1660 }
1661 uint32_t LDKCVec_1UpdateFulfillHTLCZ_1new(void* ctx_TODO, uint32_tArray elems) {
1662         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
1663         ret->datalen = elems.len;
1664         if (ret->datalen == 0) {
1665                 ret->data = NULL;
1666         } else {
1667                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
1668                 uint32_t *java_elems = elems.ptr;
1669                 for (size_t i = 0; i < ret->datalen; i++) {
1670                         uint32_t arr_elem = java_elems[i];
1671                         LDKUpdateFulfillHTLC arr_elem_conv;
1672                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1673                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1674                         if (arr_elem_conv.inner != NULL)
1675                                 arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
1676                         ret->data[i] = arr_elem_conv;
1677                 }
1678         }
1679         return (long)ret;
1680 }
1681 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
1682         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
1683         for (size_t i = 0; i < ret.datalen; i++) {
1684                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
1685         }
1686         return ret;
1687 }
1688 uint32_t LDKCVec_1UpdateFailHTLCZ_1new(void* ctx_TODO, uint32_tArray elems) {
1689         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
1690         ret->datalen = elems.len;
1691         if (ret->datalen == 0) {
1692                 ret->data = NULL;
1693         } else {
1694                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
1695                 uint32_t *java_elems = elems.ptr;
1696                 for (size_t i = 0; i < ret->datalen; i++) {
1697                         uint32_t arr_elem = java_elems[i];
1698                         LDKUpdateFailHTLC arr_elem_conv;
1699                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1700                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1701                         if (arr_elem_conv.inner != NULL)
1702                                 arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
1703                         ret->data[i] = arr_elem_conv;
1704                 }
1705         }
1706         return (long)ret;
1707 }
1708 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
1709         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
1710         for (size_t i = 0; i < ret.datalen; i++) {
1711                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
1712         }
1713         return ret;
1714 }
1715 uint32_t LDKCVec_1UpdateFailMalformedHTLCZ_1new(void* ctx_TODO, uint32_tArray elems) {
1716         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
1717         ret->datalen = elems.len;
1718         if (ret->datalen == 0) {
1719                 ret->data = NULL;
1720         } else {
1721                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
1722                 uint32_t *java_elems = elems.ptr;
1723                 for (size_t i = 0; i < ret->datalen; i++) {
1724                         uint32_t arr_elem = java_elems[i];
1725                         LDKUpdateFailMalformedHTLC arr_elem_conv;
1726                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1727                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1728                         if (arr_elem_conv.inner != NULL)
1729                                 arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
1730                         ret->data[i] = arr_elem_conv;
1731                 }
1732         }
1733         return (long)ret;
1734 }
1735 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
1736         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
1737         for (size_t i = 0; i < ret.datalen; i++) {
1738                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
1739         }
1740         return ret;
1741 }
1742 jboolean LDKCResult_1boolLightningErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1743         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
1744 }
1745 jboolean LDKCResult_1boolLightningErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1746         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
1747         CHECK(val->result_ok);
1748         return *val->contents.result;
1749 }
1750 uint32_t LDKCResult_1boolLightningErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1751         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
1752         CHECK(!val->result_ok);
1753         LDKLightningError err_var = (*val->contents.err);
1754         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1755         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1756         long err_ref = (long)err_var.inner & ~1;
1757         return err_ref;
1758 }
1759 uint32_t LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(void* ctx_TODO, uint32_t a, uint32_t b, uint32_t c) {
1760         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
1761         LDKChannelAnnouncement a_conv;
1762         a_conv.inner = (void*)(a & (~1));
1763         a_conv.is_owned = (a & 1) || (a == 0);
1764         if (a_conv.inner != NULL)
1765                 a_conv = ChannelAnnouncement_clone(&a_conv);
1766         ret->a = a_conv;
1767         LDKChannelUpdate b_conv;
1768         b_conv.inner = (void*)(b & (~1));
1769         b_conv.is_owned = (b & 1) || (b == 0);
1770         if (b_conv.inner != NULL)
1771                 b_conv = ChannelUpdate_clone(&b_conv);
1772         ret->b = b_conv;
1773         LDKChannelUpdate c_conv;
1774         c_conv.inner = (void*)(c & (~1));
1775         c_conv.is_owned = (c & 1) || (c == 0);
1776         if (c_conv.inner != NULL)
1777                 c_conv = ChannelUpdate_clone(&c_conv);
1778         ret->c = c_conv;
1779         return (long)ret;
1780 }
1781 static inline LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *orig) {
1782         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret = {
1783                 .a = ChannelAnnouncement_clone(&orig->a),
1784                 .b = ChannelUpdate_clone(&orig->b),
1785                 .c = ChannelUpdate_clone(&orig->c),
1786         };
1787         return ret;
1788 }
1789 uint32_t LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
1790         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
1791         LDKChannelAnnouncement a_var = tuple->a;
1792         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1793         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1794         long a_ref = (long)a_var.inner & ~1;
1795         return a_ref;
1796 }
1797 uint32_t LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
1798         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
1799         LDKChannelUpdate b_var = tuple->b;
1800         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1801         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1802         long b_ref = (long)b_var.inner & ~1;
1803         return b_ref;
1804 }
1805 uint32_t LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(void* ctx_TODO, uint32_t ptr) {
1806         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
1807         LDKChannelUpdate c_var = tuple->c;
1808         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1809         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1810         long c_ref = (long)c_var.inner & ~1;
1811         return c_ref;
1812 }
1813 uint32_t LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(void* ctx_TODO, uint32_tArray elems) {
1814         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
1815         ret->datalen = elems.len;
1816         if (ret->datalen == 0) {
1817                 ret->data = NULL;
1818         } else {
1819                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
1820                 uint32_t *java_elems = elems.ptr;
1821                 for (size_t i = 0; i < ret->datalen; i++) {
1822                         uint32_t arr_elem = java_elems[i];
1823                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_elem;
1824                         FREE((void*)arr_elem);
1825                         ret->data[i] = arr_elem_conv;
1826                 }
1827         }
1828         return (long)ret;
1829 }
1830 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
1831         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
1832         for (size_t i = 0; i < ret.datalen; i++) {
1833                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
1834         }
1835         return ret;
1836 }
1837 uint32_t LDKCVec_1NodeAnnouncementZ_1new(void* ctx_TODO, uint32_tArray elems) {
1838         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
1839         ret->datalen = elems.len;
1840         if (ret->datalen == 0) {
1841                 ret->data = NULL;
1842         } else {
1843                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
1844                 uint32_t *java_elems = elems.ptr;
1845                 for (size_t i = 0; i < ret->datalen; i++) {
1846                         uint32_t arr_elem = java_elems[i];
1847                         LDKNodeAnnouncement arr_elem_conv;
1848                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1849                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1850                         if (arr_elem_conv.inner != NULL)
1851                                 arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
1852                         ret->data[i] = arr_elem_conv;
1853                 }
1854         }
1855         return (long)ret;
1856 }
1857 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
1858         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
1859         for (size_t i = 0; i < ret.datalen; i++) {
1860                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
1861         }
1862         return ret;
1863 }
1864 jboolean LDKCResult_1NoneLightningErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1865         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
1866 }
1867 void LDKCResult_1NoneLightningErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1868         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)arg;
1869         CHECK(val->result_ok);
1870         return *val->contents.result;
1871 }
1872 uint32_t LDKCResult_1NoneLightningErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1873         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)arg;
1874         CHECK(!val->result_ok);
1875         LDKLightningError err_var = (*val->contents.err);
1876         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1877         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1878         long err_ref = (long)err_var.inner & ~1;
1879         return err_ref;
1880 }
1881 jboolean LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1882         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
1883 }
1884 uint32_t LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1885         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)arg;
1886         CHECK(val->result_ok);
1887         LDKChannelReestablish res_var = (*val->contents.result);
1888         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1889         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1890         long res_ref = (long)res_var.inner & ~1;
1891         return res_ref;
1892 }
1893 uint32_t LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1894         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)arg;
1895         CHECK(!val->result_ok);
1896         LDKDecodeError err_var = (*val->contents.err);
1897         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1898         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1899         long err_ref = (long)err_var.inner & ~1;
1900         return err_ref;
1901 }
1902 jboolean LDKCResult_1InitDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1903         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
1904 }
1905 uint32_t LDKCResult_1InitDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1906         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)arg;
1907         CHECK(val->result_ok);
1908         LDKInit res_var = (*val->contents.result);
1909         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1910         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1911         long res_ref = (long)res_var.inner & ~1;
1912         return res_ref;
1913 }
1914 uint32_t LDKCResult_1InitDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1915         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)arg;
1916         CHECK(!val->result_ok);
1917         LDKDecodeError err_var = (*val->contents.err);
1918         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1919         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1920         long err_ref = (long)err_var.inner & ~1;
1921         return err_ref;
1922 }
1923 jboolean LDKCResult_1PingDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1924         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
1925 }
1926 uint32_t LDKCResult_1PingDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1927         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)arg;
1928         CHECK(val->result_ok);
1929         LDKPing res_var = (*val->contents.result);
1930         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1931         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1932         long res_ref = (long)res_var.inner & ~1;
1933         return res_ref;
1934 }
1935 uint32_t LDKCResult_1PingDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1936         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)arg;
1937         CHECK(!val->result_ok);
1938         LDKDecodeError err_var = (*val->contents.err);
1939         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1940         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1941         long err_ref = (long)err_var.inner & ~1;
1942         return err_ref;
1943 }
1944 jboolean LDKCResult_1PongDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1945         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
1946 }
1947 uint32_t LDKCResult_1PongDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1948         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)arg;
1949         CHECK(val->result_ok);
1950         LDKPong res_var = (*val->contents.result);
1951         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1952         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1953         long res_ref = (long)res_var.inner & ~1;
1954         return res_ref;
1955 }
1956 uint32_t LDKCResult_1PongDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1957         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)arg;
1958         CHECK(!val->result_ok);
1959         LDKDecodeError err_var = (*val->contents.err);
1960         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1961         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1962         long err_ref = (long)err_var.inner & ~1;
1963         return err_ref;
1964 }
1965 jboolean LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1966         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
1967 }
1968 uint32_t LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1969         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg;
1970         CHECK(val->result_ok);
1971         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
1972         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1973         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1974         long res_ref = (long)res_var.inner & ~1;
1975         return res_ref;
1976 }
1977 uint32_t LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1978         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg;
1979         CHECK(!val->result_ok);
1980         LDKDecodeError err_var = (*val->contents.err);
1981         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1982         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1983         long err_ref = (long)err_var.inner & ~1;
1984         return err_ref;
1985 }
1986 jboolean LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1987         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
1988 }
1989 uint32_t LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1990         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg;
1991         CHECK(val->result_ok);
1992         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
1993         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1994         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1995         long res_ref = (long)res_var.inner & ~1;
1996         return res_ref;
1997 }
1998 uint32_t LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1999         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg;
2000         CHECK(!val->result_ok);
2001         LDKDecodeError err_var = (*val->contents.err);
2002         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2003         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2004         long err_ref = (long)err_var.inner & ~1;
2005         return err_ref;
2006 }
2007 jboolean LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2008         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
2009 }
2010 uint32_t LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2011         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)arg;
2012         CHECK(val->result_ok);
2013         LDKErrorMessage res_var = (*val->contents.result);
2014         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2015         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2016         long res_ref = (long)res_var.inner & ~1;
2017         return res_ref;
2018 }
2019 uint32_t LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2020         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)arg;
2021         CHECK(!val->result_ok);
2022         LDKDecodeError err_var = (*val->contents.err);
2023         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2024         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2025         long err_ref = (long)err_var.inner & ~1;
2026         return err_ref;
2027 }
2028 jboolean LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2029         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
2030 }
2031 uint32_t LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2032         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg;
2033         CHECK(val->result_ok);
2034         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
2035         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2036         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2037         long res_ref = (long)res_var.inner & ~1;
2038         return res_ref;
2039 }
2040 uint32_t LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2041         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg;
2042         CHECK(!val->result_ok);
2043         LDKDecodeError err_var = (*val->contents.err);
2044         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2045         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2046         long err_ref = (long)err_var.inner & ~1;
2047         return err_ref;
2048 }
2049 jboolean LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2050         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
2051 }
2052 uint32_t LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2053         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg;
2054         CHECK(val->result_ok);
2055         LDKQueryShortChannelIds res_var = (*val->contents.result);
2056         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2057         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2058         long res_ref = (long)res_var.inner & ~1;
2059         return res_ref;
2060 }
2061 uint32_t LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2062         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg;
2063         CHECK(!val->result_ok);
2064         LDKDecodeError err_var = (*val->contents.err);
2065         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2066         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2067         long err_ref = (long)err_var.inner & ~1;
2068         return err_ref;
2069 }
2070 jboolean LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2071         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
2072 }
2073 uint32_t LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2074         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg;
2075         CHECK(val->result_ok);
2076         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
2077         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2078         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2079         long res_ref = (long)res_var.inner & ~1;
2080         return res_ref;
2081 }
2082 uint32_t LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2083         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg;
2084         CHECK(!val->result_ok);
2085         LDKDecodeError err_var = (*val->contents.err);
2086         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2087         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2088         long err_ref = (long)err_var.inner & ~1;
2089         return err_ref;
2090 }
2091 jboolean LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2092         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
2093 }
2094 uint32_t LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2095         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)arg;
2096         CHECK(val->result_ok);
2097         LDKQueryChannelRange res_var = (*val->contents.result);
2098         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2099         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2100         long res_ref = (long)res_var.inner & ~1;
2101         return res_ref;
2102 }
2103 uint32_t LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2104         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)arg;
2105         CHECK(!val->result_ok);
2106         LDKDecodeError err_var = (*val->contents.err);
2107         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2108         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2109         long err_ref = (long)err_var.inner & ~1;
2110         return err_ref;
2111 }
2112 jboolean LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2113         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
2114 }
2115 uint32_t LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2116         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg;
2117         CHECK(val->result_ok);
2118         LDKReplyChannelRange res_var = (*val->contents.result);
2119         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2120         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2121         long res_ref = (long)res_var.inner & ~1;
2122         return res_ref;
2123 }
2124 uint32_t LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2125         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg;
2126         CHECK(!val->result_ok);
2127         LDKDecodeError err_var = (*val->contents.err);
2128         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2129         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2130         long err_ref = (long)err_var.inner & ~1;
2131         return err_ref;
2132 }
2133 jboolean LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2134         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
2135 }
2136 uint32_t LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2137         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg;
2138         CHECK(val->result_ok);
2139         LDKGossipTimestampFilter res_var = (*val->contents.result);
2140         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2141         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2142         long res_ref = (long)res_var.inner & ~1;
2143         return res_ref;
2144 }
2145 uint32_t LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2146         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg;
2147         CHECK(!val->result_ok);
2148         LDKDecodeError err_var = (*val->contents.err);
2149         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2150         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2151         long err_ref = (long)err_var.inner & ~1;
2152         return err_ref;
2153 }
2154 jboolean LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2155         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
2156 }
2157 int8_tArray LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2158         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
2159         CHECK(val->result_ok);
2160         LDKCVec_u8Z res_var = (*val->contents.result);
2161         int8_tArray res_arr = { .len = res_var.datalen, .ptr = MALLOC(res_var.datalen, "Native int8_tArray Bytes") };
2162         memcpy(res_arr.ptr, res_var.data, res_var.datalen);
2163         return res_arr;
2164 }
2165 uint32_t LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2166         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
2167         CHECK(!val->result_ok);
2168         LDKPeerHandleError err_var = (*val->contents.err);
2169         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2170         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2171         long err_ref = (long)err_var.inner & ~1;
2172         return err_ref;
2173 }
2174 jboolean LDKCResult_1NonePeerHandleErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2175         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
2176 }
2177 void LDKCResult_1NonePeerHandleErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2178         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
2179         CHECK(val->result_ok);
2180         return *val->contents.result;
2181 }
2182 uint32_t LDKCResult_1NonePeerHandleErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2183         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
2184         CHECK(!val->result_ok);
2185         LDKPeerHandleError err_var = (*val->contents.err);
2186         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2187         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2188         long err_ref = (long)err_var.inner & ~1;
2189         return err_ref;
2190 }
2191 jboolean LDKCResult_1boolPeerHandleErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2192         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
2193 }
2194 jboolean LDKCResult_1boolPeerHandleErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2195         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
2196         CHECK(val->result_ok);
2197         return *val->contents.result;
2198 }
2199 uint32_t LDKCResult_1boolPeerHandleErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2200         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
2201         CHECK(!val->result_ok);
2202         LDKPeerHandleError err_var = (*val->contents.err);
2203         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2204         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2205         long err_ref = (long)err_var.inner & ~1;
2206         return err_ref;
2207 }
2208 jboolean LDKCResult_1SecretKeySecpErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2209         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
2210 }
2211 int8_tArray LDKCResult_1SecretKeySecpErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2212         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
2213         CHECK(val->result_ok);
2214         int8_tArray res_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
2215         memcpy(res_arr.ptr, (*val->contents.result).bytes, 32);
2216         return res_arr;
2217 }
2218 uint32_t LDKCResult_1SecretKeySecpErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2219         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
2220         CHECK(!val->result_ok);
2221         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2222         return err_conv;
2223 }
2224 jboolean LDKCResult_1PublicKeySecpErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2225         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
2226 }
2227 int8_tArray LDKCResult_1PublicKeySecpErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2228         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
2229         CHECK(val->result_ok);
2230         int8_tArray res_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
2231         memcpy(res_arr.ptr, (*val->contents.result).compressed_form, 33);
2232         return res_arr;
2233 }
2234 uint32_t LDKCResult_1PublicKeySecpErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2235         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
2236         CHECK(!val->result_ok);
2237         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2238         return err_conv;
2239 }
2240 jboolean LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2241         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
2242 }
2243 uint32_t LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2244         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
2245         CHECK(val->result_ok);
2246         LDKTxCreationKeys res_var = (*val->contents.result);
2247         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2248         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2249         long res_ref = (long)res_var.inner & ~1;
2250         return res_ref;
2251 }
2252 uint32_t LDKCResult_1TxCreationKeysSecpErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2253         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
2254         CHECK(!val->result_ok);
2255         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2256         return err_conv;
2257 }
2258 jboolean LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2259         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
2260 }
2261 uint32_t LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2262         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)arg;
2263         CHECK(val->result_ok);
2264         LDKTrustedCommitmentTransaction 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 void LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2271         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)arg;
2272         CHECK(!val->result_ok);
2273         return *val->contents.err;
2274 }
2275 uint32_t LDKCVec_1RouteHopZ_1new(void* ctx_TODO, uint32_tArray elems) {
2276         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2277         ret->datalen = elems.len;
2278         if (ret->datalen == 0) {
2279                 ret->data = NULL;
2280         } else {
2281                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2282                 uint32_t *java_elems = elems.ptr;
2283                 for (size_t i = 0; i < ret->datalen; i++) {
2284                         uint32_t arr_elem = java_elems[i];
2285                         LDKRouteHop arr_elem_conv;
2286                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2287                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2288                         if (arr_elem_conv.inner != NULL)
2289                                 arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2290                         ret->data[i] = arr_elem_conv;
2291                 }
2292         }
2293         return (long)ret;
2294 }
2295 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2296         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2297         for (size_t i = 0; i < ret.datalen; i++) {
2298                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2299         }
2300         return ret;
2301 }
2302 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2303         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2304         for (size_t i = 0; i < ret.datalen; i++) {
2305                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2306         }
2307         return ret;
2308 }
2309 jboolean LDKCResult_1RouteDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2310         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2311 }
2312 uint32_t LDKCResult_1RouteDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2313         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)arg;
2314         CHECK(val->result_ok);
2315         LDKRoute res_var = (*val->contents.result);
2316         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2317         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2318         long res_ref = (long)res_var.inner & ~1;
2319         return res_ref;
2320 }
2321 uint32_t LDKCResult_1RouteDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2322         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)arg;
2323         CHECK(!val->result_ok);
2324         LDKDecodeError err_var = (*val->contents.err);
2325         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2326         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2327         long err_ref = (long)err_var.inner & ~1;
2328         return err_ref;
2329 }
2330 uint32_t LDKCVec_1RouteHintZ_1new(void* ctx_TODO, uint32_tArray elems) {
2331         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2332         ret->datalen = elems.len;
2333         if (ret->datalen == 0) {
2334                 ret->data = NULL;
2335         } else {
2336                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2337                 uint32_t *java_elems = elems.ptr;
2338                 for (size_t i = 0; i < ret->datalen; i++) {
2339                         uint32_t arr_elem = java_elems[i];
2340                         LDKRouteHint arr_elem_conv;
2341                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2342                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2343                         if (arr_elem_conv.inner != NULL)
2344                                 arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2345                         ret->data[i] = arr_elem_conv;
2346                 }
2347         }
2348         return (long)ret;
2349 }
2350 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2351         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2352         for (size_t i = 0; i < ret.datalen; i++) {
2353                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2354         }
2355         return ret;
2356 }
2357 jboolean LDKCResult_1RouteLightningErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2358         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
2359 }
2360 uint32_t LDKCResult_1RouteLightningErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2361         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
2362         CHECK(val->result_ok);
2363         LDKRoute res_var = (*val->contents.result);
2364         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2365         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2366         long res_ref = (long)res_var.inner & ~1;
2367         return res_ref;
2368 }
2369 uint32_t LDKCResult_1RouteLightningErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2370         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
2371         CHECK(!val->result_ok);
2372         LDKLightningError err_var = (*val->contents.err);
2373         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2374         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2375         long err_ref = (long)err_var.inner & ~1;
2376         return err_ref;
2377 }
2378 jboolean LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2379         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
2380 }
2381 uint32_t LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2382         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)arg;
2383         CHECK(val->result_ok);
2384         LDKRoutingFees res_var = (*val->contents.result);
2385         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2386         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2387         long res_ref = (long)res_var.inner & ~1;
2388         return res_ref;
2389 }
2390 uint32_t LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2391         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)arg;
2392         CHECK(!val->result_ok);
2393         LDKDecodeError err_var = (*val->contents.err);
2394         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2395         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2396         long err_ref = (long)err_var.inner & ~1;
2397         return err_ref;
2398 }
2399 jboolean LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2400         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
2401 }
2402 uint32_t LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2403         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg;
2404         CHECK(val->result_ok);
2405         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
2406         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2407         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2408         long res_ref = (long)res_var.inner & ~1;
2409         return res_ref;
2410 }
2411 uint32_t LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2412         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg;
2413         CHECK(!val->result_ok);
2414         LDKDecodeError err_var = (*val->contents.err);
2415         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2416         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2417         long err_ref = (long)err_var.inner & ~1;
2418         return err_ref;
2419 }
2420 jboolean LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2421         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
2422 }
2423 uint32_t LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2424         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)arg;
2425         CHECK(val->result_ok);
2426         LDKNodeInfo res_var = (*val->contents.result);
2427         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2428         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2429         long res_ref = (long)res_var.inner & ~1;
2430         return res_ref;
2431 }
2432 uint32_t LDKCResult_1NodeInfoDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2433         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)arg;
2434         CHECK(!val->result_ok);
2435         LDKDecodeError err_var = (*val->contents.err);
2436         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2437         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2438         long err_ref = (long)err_var.inner & ~1;
2439         return err_ref;
2440 }
2441 jboolean LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2442         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
2443 }
2444 uint32_t LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2445         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)arg;
2446         CHECK(val->result_ok);
2447         LDKNetworkGraph res_var = (*val->contents.result);
2448         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2449         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2450         long res_ref = (long)res_var.inner & ~1;
2451         return res_ref;
2452 }
2453 uint32_t LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2454         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)arg;
2455         CHECK(!val->result_ok);
2456         LDKDecodeError err_var = (*val->contents.err);
2457         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2458         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2459         long err_ref = (long)err_var.inner & ~1;
2460         return err_ref;
2461 }
2462 uint32_tArray MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(void* ctx_TODO, uint32_t this_arg) {
2463         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
2464         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
2465         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
2466         uint32_t *ret_arr_ptr = ret_arr.ptr;
2467         for (size_t s = 0; s < ret_var.datalen; s++) {
2468                 LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
2469                 *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
2470                 long arr_conv_18_ref = (long)arr_conv_18_copy;
2471                 ret_arr_ptr[s] = arr_conv_18_ref;
2472         }
2473         FREE(ret_var.data);
2474         return ret_arr;
2475 }
2476
2477 uint32_tArray EventsProvider_1get_1and_1clear_1pending_1events(void* ctx_TODO, uint32_t this_arg) {
2478         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
2479         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
2480         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
2481         uint32_t *ret_arr_ptr = ret_arr.ptr;
2482         for (size_t h = 0; h < ret_var.datalen; h++) {
2483                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
2484                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
2485                 long arr_conv_7_ref = (long)arr_conv_7_copy;
2486                 ret_arr_ptr[h] = arr_conv_7_ref;
2487         }
2488         FREE(ret_var.data);
2489         return ret_arr;
2490 }
2491
2492 uint32_t Access_1get_1utxo(void* ctx_TODO, uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
2493         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
2494         unsigned char genesis_hash_arr[32];
2495         CHECK(genesis_hash.len == 32);
2496         memcpy(genesis_hash_arr, genesis_hash.ptr, 32);
2497         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
2498         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
2499         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
2500         return (long)ret_conv;
2501 }
2502
2503 void Filter_1register_1tx(void* ctx_TODO, uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
2504         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2505         unsigned char txid_arr[32];
2506         CHECK(txid.len == 32);
2507         memcpy(txid_arr, txid.ptr, 32);
2508         unsigned char (*txid_ref)[32] = &txid_arr;
2509         LDKu8slice script_pubkey_ref;
2510         script_pubkey_ref.datalen = script_pubkey.len;
2511         script_pubkey_ref.data = script_pubkey.ptr;
2512         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
2513 }
2514
2515 void Filter_1register_1output(void* ctx_TODO, uint32_t this_arg, uint32_t outpoint, int8_tArray script_pubkey) {
2516         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2517         LDKOutPoint outpoint_conv;
2518         outpoint_conv.inner = (void*)(outpoint & (~1));
2519         outpoint_conv.is_owned = false;
2520         LDKu8slice script_pubkey_ref;
2521         script_pubkey_ref.datalen = script_pubkey.len;
2522         script_pubkey_ref.data = script_pubkey.ptr;
2523         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
2524 }
2525
2526 uint32_t Persist_1persist_1new_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t id, uint32_t data) {
2527         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
2528         LDKOutPoint id_conv;
2529         id_conv.inner = (void*)(id & (~1));
2530         id_conv.is_owned = (id & 1) || (id == 0);
2531         if (id_conv.inner != NULL)
2532                 id_conv = OutPoint_clone(&id_conv);
2533         LDKChannelMonitor data_conv;
2534         data_conv.inner = (void*)(data & (~1));
2535         data_conv.is_owned = false;
2536         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2537         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
2538         return (long)ret_conv;
2539 }
2540
2541 uint32_t Persist_1update_1persisted_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
2542         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
2543         LDKOutPoint id_conv;
2544         id_conv.inner = (void*)(id & (~1));
2545         id_conv.is_owned = (id & 1) || (id == 0);
2546         if (id_conv.inner != NULL)
2547                 id_conv = OutPoint_clone(&id_conv);
2548         LDKChannelMonitorUpdate update_conv;
2549         update_conv.inner = (void*)(update & (~1));
2550         update_conv.is_owned = false;
2551         LDKChannelMonitor data_conv;
2552         data_conv.inner = (void*)(data & (~1));
2553         data_conv.is_owned = false;
2554         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2555         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
2556         return (long)ret_conv;
2557 }
2558
2559 void ChannelMessageHandler_1handle_1open_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
2560         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2561         LDKPublicKey their_node_id_ref;
2562         CHECK(their_node_id.len == 33);
2563         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2564         LDKInitFeatures their_features_conv;
2565         their_features_conv.inner = (void*)(their_features & (~1));
2566         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
2567         // Warning: we may need a move here but can't clone!
2568         LDKOpenChannel msg_conv;
2569         msg_conv.inner = (void*)(msg & (~1));
2570         msg_conv.is_owned = false;
2571         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
2572 }
2573
2574 void ChannelMessageHandler_1handle_1accept_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
2575         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2576         LDKPublicKey their_node_id_ref;
2577         CHECK(their_node_id.len == 33);
2578         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2579         LDKInitFeatures their_features_conv;
2580         their_features_conv.inner = (void*)(their_features & (~1));
2581         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
2582         // Warning: we may need a move here but can't clone!
2583         LDKAcceptChannel msg_conv;
2584         msg_conv.inner = (void*)(msg & (~1));
2585         msg_conv.is_owned = false;
2586         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
2587 }
2588
2589 void ChannelMessageHandler_1handle_1funding_1created(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2590         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2591         LDKPublicKey their_node_id_ref;
2592         CHECK(their_node_id.len == 33);
2593         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2594         LDKFundingCreated msg_conv;
2595         msg_conv.inner = (void*)(msg & (~1));
2596         msg_conv.is_owned = false;
2597         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2598 }
2599
2600 void ChannelMessageHandler_1handle_1funding_1signed(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2601         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2602         LDKPublicKey their_node_id_ref;
2603         CHECK(their_node_id.len == 33);
2604         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2605         LDKFundingSigned msg_conv;
2606         msg_conv.inner = (void*)(msg & (~1));
2607         msg_conv.is_owned = false;
2608         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2609 }
2610
2611 void ChannelMessageHandler_1handle_1funding_1locked(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2612         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2613         LDKPublicKey their_node_id_ref;
2614         CHECK(their_node_id.len == 33);
2615         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2616         LDKFundingLocked msg_conv;
2617         msg_conv.inner = (void*)(msg & (~1));
2618         msg_conv.is_owned = false;
2619         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2620 }
2621
2622 void ChannelMessageHandler_1handle_1shutdown(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2623         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2624         LDKPublicKey their_node_id_ref;
2625         CHECK(their_node_id.len == 33);
2626         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2627         LDKShutdown msg_conv;
2628         msg_conv.inner = (void*)(msg & (~1));
2629         msg_conv.is_owned = false;
2630         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2631 }
2632
2633 void ChannelMessageHandler_1handle_1closing_1signed(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2634         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2635         LDKPublicKey their_node_id_ref;
2636         CHECK(their_node_id.len == 33);
2637         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2638         LDKClosingSigned msg_conv;
2639         msg_conv.inner = (void*)(msg & (~1));
2640         msg_conv.is_owned = false;
2641         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2642 }
2643
2644 void ChannelMessageHandler_1handle_1update_1add_1htlc(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2645         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2646         LDKPublicKey their_node_id_ref;
2647         CHECK(their_node_id.len == 33);
2648         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2649         LDKUpdateAddHTLC msg_conv;
2650         msg_conv.inner = (void*)(msg & (~1));
2651         msg_conv.is_owned = false;
2652         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2653 }
2654
2655 void ChannelMessageHandler_1handle_1update_1fulfill_1htlc(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2656         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2657         LDKPublicKey their_node_id_ref;
2658         CHECK(their_node_id.len == 33);
2659         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2660         LDKUpdateFulfillHTLC msg_conv;
2661         msg_conv.inner = (void*)(msg & (~1));
2662         msg_conv.is_owned = false;
2663         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2664 }
2665
2666 void ChannelMessageHandler_1handle_1update_1fail_1htlc(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2667         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2668         LDKPublicKey their_node_id_ref;
2669         CHECK(their_node_id.len == 33);
2670         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2671         LDKUpdateFailHTLC msg_conv;
2672         msg_conv.inner = (void*)(msg & (~1));
2673         msg_conv.is_owned = false;
2674         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2675 }
2676
2677 void ChannelMessageHandler_1handle_1update_1fail_1malformed_1htlc(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2678         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2679         LDKPublicKey their_node_id_ref;
2680         CHECK(their_node_id.len == 33);
2681         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2682         LDKUpdateFailMalformedHTLC msg_conv;
2683         msg_conv.inner = (void*)(msg & (~1));
2684         msg_conv.is_owned = false;
2685         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2686 }
2687
2688 void ChannelMessageHandler_1handle_1commitment_1signed(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2689         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2690         LDKPublicKey their_node_id_ref;
2691         CHECK(their_node_id.len == 33);
2692         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2693         LDKCommitmentSigned msg_conv;
2694         msg_conv.inner = (void*)(msg & (~1));
2695         msg_conv.is_owned = false;
2696         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2697 }
2698
2699 void ChannelMessageHandler_1handle_1revoke_1and_1ack(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2700         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2701         LDKPublicKey their_node_id_ref;
2702         CHECK(their_node_id.len == 33);
2703         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2704         LDKRevokeAndACK msg_conv;
2705         msg_conv.inner = (void*)(msg & (~1));
2706         msg_conv.is_owned = false;
2707         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2708 }
2709
2710 void ChannelMessageHandler_1handle_1update_1fee(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2711         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2712         LDKPublicKey their_node_id_ref;
2713         CHECK(their_node_id.len == 33);
2714         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2715         LDKUpdateFee msg_conv;
2716         msg_conv.inner = (void*)(msg & (~1));
2717         msg_conv.is_owned = false;
2718         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2719 }
2720
2721 void ChannelMessageHandler_1handle_1announcement_1signatures(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2722         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2723         LDKPublicKey their_node_id_ref;
2724         CHECK(their_node_id.len == 33);
2725         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2726         LDKAnnouncementSignatures msg_conv;
2727         msg_conv.inner = (void*)(msg & (~1));
2728         msg_conv.is_owned = false;
2729         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2730 }
2731
2732 void ChannelMessageHandler_1peer_1disconnected(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
2733         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2734         LDKPublicKey their_node_id_ref;
2735         CHECK(their_node_id.len == 33);
2736         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2737         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
2738 }
2739
2740 void ChannelMessageHandler_1peer_1connected(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2741         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2742         LDKPublicKey their_node_id_ref;
2743         CHECK(their_node_id.len == 33);
2744         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2745         LDKInit msg_conv;
2746         msg_conv.inner = (void*)(msg & (~1));
2747         msg_conv.is_owned = false;
2748         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2749 }
2750
2751 void ChannelMessageHandler_1handle_1channel_1reestablish(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2752         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2753         LDKPublicKey their_node_id_ref;
2754         CHECK(their_node_id.len == 33);
2755         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2756         LDKChannelReestablish msg_conv;
2757         msg_conv.inner = (void*)(msg & (~1));
2758         msg_conv.is_owned = false;
2759         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2760 }
2761
2762 void ChannelMessageHandler_1handle_1error(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2763         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
2764         LDKPublicKey their_node_id_ref;
2765         CHECK(their_node_id.len == 33);
2766         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2767         LDKErrorMessage msg_conv;
2768         msg_conv.inner = (void*)(msg & (~1));
2769         msg_conv.is_owned = false;
2770         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
2771 }
2772
2773 uint32_t RoutingMessageHandler_1handle_1node_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
2774         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2775         LDKNodeAnnouncement msg_conv;
2776         msg_conv.inner = (void*)(msg & (~1));
2777         msg_conv.is_owned = false;
2778         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
2779         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
2780         return (long)ret_conv;
2781 }
2782
2783 uint32_t RoutingMessageHandler_1handle_1channel_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
2784         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2785         LDKChannelAnnouncement msg_conv;
2786         msg_conv.inner = (void*)(msg & (~1));
2787         msg_conv.is_owned = false;
2788         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
2789         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
2790         return (long)ret_conv;
2791 }
2792
2793 uint32_t RoutingMessageHandler_1handle_1channel_1update(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
2794         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2795         LDKChannelUpdate msg_conv;
2796         msg_conv.inner = (void*)(msg & (~1));
2797         msg_conv.is_owned = false;
2798         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
2799         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
2800         return (long)ret_conv;
2801 }
2802
2803 void RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(void* ctx_TODO, uint32_t this_arg, uint32_t update) {
2804         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2805         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
2806         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
2807 }
2808
2809 uint32_tArray RoutingMessageHandler_1get_1next_1channel_1announcements(void* ctx_TODO, uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
2810         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2811         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
2812         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
2813         uint32_t *ret_arr_ptr = ret_arr.ptr;
2814         for (size_t l = 0; l < ret_var.datalen; l++) {
2815                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arr_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
2816                 *arr_conv_63_ref = ret_var.data[l];
2817                 arr_conv_63_ref->a = ChannelAnnouncement_clone(&arr_conv_63_ref->a);
2818                 arr_conv_63_ref->b = ChannelUpdate_clone(&arr_conv_63_ref->b);
2819                 arr_conv_63_ref->c = ChannelUpdate_clone(&arr_conv_63_ref->c);
2820                 ret_arr_ptr[l] = (long)arr_conv_63_ref;
2821         }
2822         FREE(ret_var.data);
2823         return ret_arr;
2824 }
2825
2826 uint32_tArray RoutingMessageHandler_1get_1next_1node_1announcements(void* ctx_TODO, uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
2827         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2828         LDKPublicKey starting_point_ref;
2829         CHECK(starting_point.len == 33);
2830         memcpy(starting_point_ref.compressed_form, starting_point.ptr, 33);
2831         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
2832         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
2833         uint32_t *ret_arr_ptr = ret_arr.ptr;
2834         for (size_t s = 0; s < ret_var.datalen; s++) {
2835                 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
2836                 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2837                 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2838                 long arr_conv_18_ref = (long)arr_conv_18_var.inner;
2839                 if (arr_conv_18_var.is_owned) {
2840                         arr_conv_18_ref |= 1;
2841                 }
2842                 ret_arr_ptr[s] = arr_conv_18_ref;
2843         }
2844         FREE(ret_var.data);
2845         return ret_arr;
2846 }
2847
2848 void RoutingMessageHandler_1sync_1routing_1table(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
2849         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2850         LDKPublicKey their_node_id_ref;
2851         CHECK(their_node_id.len == 33);
2852         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2853         LDKInit init_conv;
2854         init_conv.inner = (void*)(init & (~1));
2855         init_conv.is_owned = false;
2856         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
2857 }
2858
2859 uint32_t RoutingMessageHandler_1handle_1reply_1channel_1range(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2860         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2861         LDKPublicKey their_node_id_ref;
2862         CHECK(their_node_id.len == 33);
2863         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2864         LDKReplyChannelRange msg_conv;
2865         msg_conv.inner = (void*)(msg & (~1));
2866         msg_conv.is_owned = (msg & 1) || (msg == 0);
2867         if (msg_conv.inner != NULL)
2868                 msg_conv = ReplyChannelRange_clone(&msg_conv);
2869         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
2870         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
2871         return (long)ret_conv;
2872 }
2873
2874 uint32_t RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2875         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2876         LDKPublicKey their_node_id_ref;
2877         CHECK(their_node_id.len == 33);
2878         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2879         LDKReplyShortChannelIdsEnd msg_conv;
2880         msg_conv.inner = (void*)(msg & (~1));
2881         msg_conv.is_owned = (msg & 1) || (msg == 0);
2882         if (msg_conv.inner != NULL)
2883                 msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
2884         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
2885         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
2886         return (long)ret_conv;
2887 }
2888
2889 uint32_t RoutingMessageHandler_1handle_1query_1channel_1range(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2890         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2891         LDKPublicKey their_node_id_ref;
2892         CHECK(their_node_id.len == 33);
2893         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2894         LDKQueryChannelRange msg_conv;
2895         msg_conv.inner = (void*)(msg & (~1));
2896         msg_conv.is_owned = (msg & 1) || (msg == 0);
2897         if (msg_conv.inner != NULL)
2898                 msg_conv = QueryChannelRange_clone(&msg_conv);
2899         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
2900         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
2901         return (long)ret_conv;
2902 }
2903
2904 uint32_t RoutingMessageHandler_1handle_1query_1short_1channel_1ids(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
2905         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
2906         LDKPublicKey their_node_id_ref;
2907         CHECK(their_node_id.len == 33);
2908         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
2909         LDKQueryShortChannelIds msg_conv;
2910         msg_conv.inner = (void*)(msg & (~1));
2911         msg_conv.is_owned = (msg & 1) || (msg == 0);
2912         if (msg_conv.inner != NULL)
2913                 msg_conv = QueryShortChannelIds_clone(&msg_conv);
2914         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
2915         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
2916         return (long)ret_conv;
2917 }
2918
2919 int64_t SocketDescriptor_1send_1data(void* ctx_TODO, uint32_t this_arg, int8_tArray data, jboolean resume_read) {
2920         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
2921         LDKu8slice data_ref;
2922         data_ref.datalen = data.len;
2923         data_ref.data = data.ptr;
2924         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
2925         return ret_val;
2926 }
2927
2928 void SocketDescriptor_1disconnect_1socket(void* ctx_TODO, uint32_t this_arg) {
2929         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
2930         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
2931 }
2932
2933 int64_t SocketDescriptor_1hash(void* ctx_TODO, uint32_t this_arg) {
2934         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
2935         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
2936         return ret_val;
2937 }
2938
2939 void Transaction_1free(void* ctx_TODO, int8_tArray _res) {
2940         LDKTransaction _res_ref;
2941         _res_ref.datalen = _res.len;
2942         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
2943         memcpy(_res_ref.data, _res.ptr, _res_ref.datalen);
2944         _res_ref.data_is_owned = true;
2945         Transaction_free(_res_ref);
2946 }
2947
2948 void TxOut_1free(void* ctx_TODO, uint32_t _res) {
2949         LDKTxOut _res_conv = *(LDKTxOut*)_res;
2950         FREE((void*)_res);
2951         TxOut_free(_res_conv);
2952 }
2953
2954 void CVec_1SpendableOutputDescriptorZ_1free(void* ctx_TODO, uint32_tArray _res) {
2955         LDKCVec_SpendableOutputDescriptorZ _res_constr;
2956         _res_constr.datalen = _res.len;
2957         if (_res_constr.datalen > 0)
2958                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
2959         else
2960                 _res_constr.data = NULL;
2961         uint32_t* _res_vals = (uint32_t*) _res.ptr;
2962         for (size_t b = 0; b < _res_constr.datalen; b++) {
2963                 uint32_t arr_conv_27 = _res_vals[b];
2964                 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)arr_conv_27;
2965                 FREE((void*)arr_conv_27);
2966                 _res_constr.data[b] = arr_conv_27_conv;
2967         }
2968         CVec_SpendableOutputDescriptorZ_free(_res_constr);
2969 }
2970
2971 void CVec_1MessageSendEventZ_1free(void* ctx_TODO, uint32_tArray _res) {
2972         LDKCVec_MessageSendEventZ _res_constr;
2973         _res_constr.datalen = _res.len;
2974         if (_res_constr.datalen > 0)
2975                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
2976         else
2977                 _res_constr.data = NULL;
2978         uint32_t* _res_vals = (uint32_t*) _res.ptr;
2979         for (size_t s = 0; s < _res_constr.datalen; s++) {
2980                 uint32_t arr_conv_18 = _res_vals[s];
2981                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
2982                 FREE((void*)arr_conv_18);
2983                 _res_constr.data[s] = arr_conv_18_conv;
2984         }
2985         CVec_MessageSendEventZ_free(_res_constr);
2986 }
2987
2988 void CVec_1EventZ_1free(void* ctx_TODO, uint32_tArray _res) {
2989         LDKCVec_EventZ _res_constr;
2990         _res_constr.datalen = _res.len;
2991         if (_res_constr.datalen > 0)
2992                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
2993         else
2994                 _res_constr.data = NULL;
2995         uint32_t* _res_vals = (uint32_t*) _res.ptr;
2996         for (size_t h = 0; h < _res_constr.datalen; h++) {
2997                 uint32_t arr_conv_7 = _res_vals[h];
2998                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
2999                 FREE((void*)arr_conv_7);
3000                 _res_constr.data[h] = arr_conv_7_conv;
3001         }
3002         CVec_EventZ_free(_res_constr);
3003 }
3004
3005 void C2Tuple_1usizeTransactionZ_1free(void* ctx_TODO, uint32_t _res) {
3006         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)_res;
3007         FREE((void*)_res);
3008         C2Tuple_usizeTransactionZ_free(_res_conv);
3009 }
3010
3011 uint32_t C2Tuple_1usizeTransactionZ_1new(void* ctx_TODO, int64_t a, int8_tArray b) {
3012         LDKTransaction b_ref;
3013         b_ref.datalen = b.len;
3014         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
3015         memcpy(b_ref.data, b.ptr, b_ref.datalen);
3016         b_ref.data_is_owned = true;
3017         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3018         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
3019         // XXX: We likely need to clone here, but no _clone fn is available for byte[]
3020         return (long)ret_ref;
3021 }
3022
3023 void CVec_1C2Tuple_1usizeTransactionZZ_1free(void* ctx_TODO, uint32_tArray _res) {
3024         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
3025         _res_constr.datalen = _res.len;
3026         if (_res_constr.datalen > 0)
3027                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
3028         else
3029                 _res_constr.data = NULL;
3030         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3031         for (size_t y = 0; y < _res_constr.datalen; y++) {
3032                 uint32_t arr_conv_24 = _res_vals[y];
3033                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_24;
3034                 FREE((void*)arr_conv_24);
3035                 _res_constr.data[y] = arr_conv_24_conv;
3036         }
3037         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
3038 }
3039
3040 uint32_t CResult_1NoneChannelMonitorUpdateErrZ_1ok(void* ctx_TODO) {
3041         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3042         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
3043         return (long)ret_conv;
3044 }
3045
3046 uint32_t CResult_1NoneChannelMonitorUpdateErrZ_1err(void* ctx_TODO, uint32_t e) {
3047         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
3048         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3049         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
3050         return (long)ret_conv;
3051 }
3052
3053 void CResult_1NoneChannelMonitorUpdateErrZ_1free(void* ctx_TODO, uint32_t _res) {
3054         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)_res;
3055         FREE((void*)_res);
3056         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
3057 }
3058
3059 void CVec_1MonitorEventZ_1free(void* ctx_TODO, uint32_tArray _res) {
3060         LDKCVec_MonitorEventZ _res_constr;
3061         _res_constr.datalen = _res.len;
3062         if (_res_constr.datalen > 0)
3063                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3064         else
3065                 _res_constr.data = NULL;
3066         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3067         for (size_t o = 0; o < _res_constr.datalen; o++) {
3068                 uint32_t arr_conv_14 = _res_vals[o];
3069                 LDKMonitorEvent arr_conv_14_conv;
3070                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
3071                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
3072                 _res_constr.data[o] = arr_conv_14_conv;
3073         }
3074         CVec_MonitorEventZ_free(_res_constr);
3075 }
3076
3077 uint32_t CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3078         LDKChannelMonitorUpdate o_conv;
3079         o_conv.inner = (void*)(o & (~1));
3080         o_conv.is_owned = (o & 1) || (o == 0);
3081         if (o_conv.inner != NULL)
3082                 o_conv = ChannelMonitorUpdate_clone(&o_conv);
3083         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
3084         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
3085         return (long)ret_conv;
3086 }
3087
3088 uint32_t CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3089         LDKDecodeError e_conv;
3090         e_conv.inner = (void*)(e & (~1));
3091         e_conv.is_owned = (e & 1) || (e == 0);
3092         // Warning: we may need a move here but can't clone!
3093         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
3094         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
3095         return (long)ret_conv;
3096 }
3097
3098 void CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3099         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)_res;
3100         FREE((void*)_res);
3101         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
3102 }
3103
3104 uint32_t CResult_1NoneMonitorUpdateErrorZ_1ok(void* ctx_TODO) {
3105         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
3106         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
3107         return (long)ret_conv;
3108 }
3109
3110 uint32_t CResult_1NoneMonitorUpdateErrorZ_1err(void* ctx_TODO, uint32_t e) {
3111         LDKMonitorUpdateError e_conv;
3112         e_conv.inner = (void*)(e & (~1));
3113         e_conv.is_owned = (e & 1) || (e == 0);
3114         // Warning: we may need a move here but can't clone!
3115         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
3116         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
3117         return (long)ret_conv;
3118 }
3119
3120 void CResult_1NoneMonitorUpdateErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3121         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)_res;
3122         FREE((void*)_res);
3123         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
3124 }
3125
3126 void C2Tuple_1OutPointScriptZ_1free(void* ctx_TODO, uint32_t _res) {
3127         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)_res;
3128         FREE((void*)_res);
3129         C2Tuple_OutPointScriptZ_free(_res_conv);
3130 }
3131
3132 uint32_t C2Tuple_1OutPointScriptZ_1new(void* ctx_TODO, uint32_t a, int8_tArray b) {
3133         LDKOutPoint a_conv;
3134         a_conv.inner = (void*)(a & (~1));
3135         a_conv.is_owned = (a & 1) || (a == 0);
3136         if (a_conv.inner != NULL)
3137                 a_conv = OutPoint_clone(&a_conv);
3138         LDKCVec_u8Z b_ref;
3139         b_ref.datalen = b.len;
3140         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3141         memcpy(b_ref.data, b.ptr, b_ref.datalen);
3142         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3143         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
3144         ret_ref->a = OutPoint_clone(&ret_ref->a);
3145         ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
3146         return (long)ret_ref;
3147 }
3148
3149 void CVec_1TransactionZ_1free(void* ctx_TODO, uint32_tArray _res) {
3150         LDKCVec_TransactionZ _res_constr;
3151         _res_constr.datalen = _res.len;
3152         if (_res_constr.datalen > 0)
3153                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
3154         else
3155                 _res_constr.data = NULL;
3156         int8_tArray* _res_vals = (int8_tArray*) _res.ptr;
3157         for (size_t i = 0; i < _res_constr.datalen; i++) {
3158                 int8_tArray arr_conv_8 = _res_vals[i];
3159                 LDKTransaction arr_conv_8_ref;
3160                 arr_conv_8_ref.datalen = arr_conv_8.len;
3161                 arr_conv_8_ref.data = MALLOC(arr_conv_8_ref.datalen, "LDKTransaction Bytes");
3162                 memcpy(arr_conv_8_ref.data, arr_conv_8.ptr, arr_conv_8_ref.datalen);
3163                 arr_conv_8_ref.data_is_owned = true;
3164                 _res_constr.data[i] = arr_conv_8_ref;
3165         }
3166         CVec_TransactionZ_free(_res_constr);
3167 }
3168
3169 void C2Tuple_1u32TxOutZ_1free(void* ctx_TODO, uint32_t _res) {
3170         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)_res;
3171         FREE((void*)_res);
3172         C2Tuple_u32TxOutZ_free(_res_conv);
3173 }
3174
3175 uint32_t C2Tuple_1u32TxOutZ_1new(void* ctx_TODO, int32_t a, uint32_t b) {
3176         LDKTxOut b_conv = *(LDKTxOut*)b;
3177         FREE((void*)b);
3178         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3179         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
3180         // XXX: We likely need to clone here, but no _clone fn is available for TxOut
3181         return (long)ret_ref;
3182 }
3183
3184 void CVec_1C2Tuple_1u32TxOutZZ_1free(void* ctx_TODO, uint32_tArray _res) {
3185         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
3186         _res_constr.datalen = _res.len;
3187         if (_res_constr.datalen > 0)
3188                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3189         else
3190                 _res_constr.data = NULL;
3191         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3192         for (size_t a = 0; a < _res_constr.datalen; a++) {
3193                 uint32_t arr_conv_26 = _res_vals[a];
3194                 LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_26;
3195                 FREE((void*)arr_conv_26);
3196                 _res_constr.data[a] = arr_conv_26_conv;
3197         }
3198         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
3199 }
3200
3201 void C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(void* ctx_TODO, uint32_t _res) {
3202         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)_res;
3203         FREE((void*)_res);
3204         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
3205 }
3206
3207 uint32_t C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(void* ctx_TODO, int8_tArray a, uint32_tArray b) {
3208         LDKThirtyTwoBytes a_ref;
3209         CHECK(a.len == 32);
3210         memcpy(a_ref.data, a.ptr, 32);
3211         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3212         b_constr.datalen = b.len;
3213         if (b_constr.datalen > 0)
3214                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3215         else
3216                 b_constr.data = NULL;
3217         uint32_t* b_vals = (uint32_t*) b.ptr;
3218         for (size_t a = 0; a < b_constr.datalen; a++) {
3219                 uint32_t arr_conv_26 = b_vals[a];
3220                 LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_26;
3221                 FREE((void*)arr_conv_26);
3222                 b_constr.data[a] = arr_conv_26_conv;
3223         }
3224         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3225         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
3226         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
3227         // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Integer, TxOut>[]
3228         return (long)ret_ref;
3229 }
3230
3231 void CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(void* ctx_TODO, uint32_tArray _res) {
3232         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
3233         _res_constr.datalen = _res.len;
3234         if (_res_constr.datalen > 0)
3235                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
3236         else
3237                 _res_constr.data = NULL;
3238         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3239         for (size_t u = 0; u < _res_constr.datalen; u++) {
3240                 uint32_t arr_conv_46 = _res_vals[u];
3241                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)arr_conv_46;
3242                 FREE((void*)arr_conv_46);
3243                 _res_constr.data[u] = arr_conv_46_conv;
3244         }
3245         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
3246 }
3247
3248 void C2Tuple_1BlockHashChannelMonitorZ_1free(void* ctx_TODO, uint32_t _res) {
3249         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)_res;
3250         FREE((void*)_res);
3251         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
3252 }
3253
3254 uint32_t C2Tuple_1BlockHashChannelMonitorZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) {
3255         LDKThirtyTwoBytes a_ref;
3256         CHECK(a.len == 32);
3257         memcpy(a_ref.data, a.ptr, 32);
3258         LDKChannelMonitor b_conv;
3259         b_conv.inner = (void*)(b & (~1));
3260         b_conv.is_owned = (b & 1) || (b == 0);
3261         // Warning: we may need a move here but can't clone!
3262         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3263         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
3264         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
3265         // XXX: We likely need to clone here, but no _clone fn is available for ChannelMonitor
3266         return (long)ret_ref;
3267 }
3268
3269 uint32_t CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3270         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)o;
3271         FREE((void*)o);
3272         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
3273         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
3274         return (long)ret_conv;
3275 }
3276
3277 uint32_t CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3278         LDKDecodeError e_conv;
3279         e_conv.inner = (void*)(e & (~1));
3280         e_conv.is_owned = (e & 1) || (e == 0);
3281         // Warning: we may need a move here but can't clone!
3282         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
3283         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
3284         return (long)ret_conv;
3285 }
3286
3287 void CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3288         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)_res;
3289         FREE((void*)_res);
3290         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
3291 }
3292
3293 void C2Tuple_1u64u64Z_1free(void* ctx_TODO, uint32_t _res) {
3294         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)_res;
3295         FREE((void*)_res);
3296         C2Tuple_u64u64Z_free(_res_conv);
3297 }
3298
3299 uint32_t C2Tuple_1u64u64Z_1new(void* ctx_TODO, int64_t a, int64_t b) {
3300         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3301         *ret_ref = C2Tuple_u64u64Z_new(a, b);
3302         return (long)ret_ref;
3303 }
3304
3305 uint32_t CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3306         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)o;
3307         FREE((void*)o);
3308         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
3309         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
3310         return (long)ret_conv;
3311 }
3312
3313 uint32_t CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3314         LDKDecodeError e_conv;
3315         e_conv.inner = (void*)(e & (~1));
3316         e_conv.is_owned = (e & 1) || (e == 0);
3317         // Warning: we may need a move here but can't clone!
3318         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
3319         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
3320         return (long)ret_conv;
3321 }
3322
3323 void CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3324         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)_res;
3325         FREE((void*)_res);
3326         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
3327 }
3328
3329 void CVec_1SignatureZ_1free(void* ctx_TODO, uint32_tArray _res) {
3330         LDKCVec_SignatureZ _res_constr;
3331         _res_constr.datalen = _res.len;
3332         if (_res_constr.datalen > 0)
3333                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
3334         else
3335                 _res_constr.data = NULL;
3336         int8_tArray* _res_vals = (int8_tArray*) _res.ptr;
3337         for (size_t i = 0; i < _res_constr.datalen; i++) {
3338                 int8_tArray arr_conv_8 = _res_vals[i];
3339                 LDKSignature arr_conv_8_ref;
3340                 CHECK(arr_conv_8.len == 64);
3341                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
3342                 _res_constr.data[i] = arr_conv_8_ref;
3343         }
3344         CVec_SignatureZ_free(_res_constr);
3345 }
3346
3347 void C2Tuple_1SignatureCVec_1SignatureZZ_1free(void* ctx_TODO, uint32_t _res) {
3348         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)_res;
3349         FREE((void*)_res);
3350         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
3351 }
3352
3353 uint32_t C2Tuple_1SignatureCVec_1SignatureZZ_1new(void* ctx_TODO, int8_tArray a, uint32_tArray b) {
3354         LDKSignature a_ref;
3355         CHECK(a.len == 64);
3356         memcpy(a_ref.compact_form, a.ptr, 64);
3357         LDKCVec_SignatureZ b_constr;
3358         b_constr.datalen = b.len;
3359         if (b_constr.datalen > 0)
3360                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
3361         else
3362                 b_constr.data = NULL;
3363         int8_tArray* b_vals = (int8_tArray*) b.ptr;
3364         for (size_t i = 0; i < b_constr.datalen; i++) {
3365                 int8_tArray arr_conv_8 = b_vals[i];
3366                 LDKSignature arr_conv_8_ref;
3367                 CHECK(arr_conv_8.len == 64);
3368                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
3369                 b_constr.data[i] = arr_conv_8_ref;
3370         }
3371         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3372         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
3373         // XXX: We likely need to clone here, but no _clone fn is available for byte[]
3374         // XXX: We likely need to clone here, but no _clone fn is available for byte[][]
3375         return (long)ret_ref;
3376 }
3377
3378 uint32_t CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(void* ctx_TODO, uint32_t o) {
3379         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)o;
3380         FREE((void*)o);
3381         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3382         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
3383         return (long)ret_conv;
3384 }
3385
3386 uint32_t CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(void* ctx_TODO) {
3387         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3388         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
3389         return (long)ret_conv;
3390 }
3391
3392 void CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(void* ctx_TODO, uint32_t _res) {
3393         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)_res;
3394         FREE((void*)_res);
3395         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
3396 }
3397
3398 uint32_t CResult_1SignatureNoneZ_1ok(void* ctx_TODO, int8_tArray o) {
3399         LDKSignature o_ref;
3400         CHECK(o.len == 64);
3401         memcpy(o_ref.compact_form, o.ptr, 64);
3402         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3403         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
3404         return (long)ret_conv;
3405 }
3406
3407 uint32_t CResult_1SignatureNoneZ_1err(void* ctx_TODO) {
3408         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3409         *ret_conv = CResult_SignatureNoneZ_err();
3410         return (long)ret_conv;
3411 }
3412
3413 void CResult_1SignatureNoneZ_1free(void* ctx_TODO, uint32_t _res) {
3414         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)_res;
3415         FREE((void*)_res);
3416         CResult_SignatureNoneZ_free(_res_conv);
3417 }
3418
3419 uint32_t CResult_1CVec_1SignatureZNoneZ_1ok(void* ctx_TODO, uint32_tArray o) {
3420         LDKCVec_SignatureZ o_constr;
3421         o_constr.datalen = o.len;
3422         if (o_constr.datalen > 0)
3423                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
3424         else
3425                 o_constr.data = NULL;
3426         int8_tArray* o_vals = (int8_tArray*) o.ptr;
3427         for (size_t i = 0; i < o_constr.datalen; i++) {
3428                 int8_tArray arr_conv_8 = o_vals[i];
3429                 LDKSignature arr_conv_8_ref;
3430                 CHECK(arr_conv_8.len == 64);
3431                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
3432                 o_constr.data[i] = arr_conv_8_ref;
3433         }
3434         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
3435         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
3436         return (long)ret_conv;
3437 }
3438
3439 uint32_t CResult_1CVec_1SignatureZNoneZ_1err(void* ctx_TODO) {
3440         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
3441         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
3442         return (long)ret_conv;
3443 }
3444
3445 void CResult_1CVec_1SignatureZNoneZ_1free(void* ctx_TODO, uint32_t _res) {
3446         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)_res;
3447         FREE((void*)_res);
3448         CResult_CVec_SignatureZNoneZ_free(_res_conv);
3449 }
3450
3451 uint32_t CResult_1ChanKeySignerDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3452         LDKChannelKeys o_conv = *(LDKChannelKeys*)o;
3453         if (o_conv.free == LDKChannelKeys_JCalls_free) {
3454                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
3455                 LDKChannelKeys_JCalls_clone(o_conv.this_arg);
3456         }
3457         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
3458         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_ok(o_conv);
3459         return (long)ret_conv;
3460 }
3461
3462 uint32_t CResult_1ChanKeySignerDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3463         LDKDecodeError e_conv;
3464         e_conv.inner = (void*)(e & (~1));
3465         e_conv.is_owned = (e & 1) || (e == 0);
3466         // Warning: we may need a move here but can't clone!
3467         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
3468         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_err(e_conv);
3469         return (long)ret_conv;
3470 }
3471
3472 void CResult_1ChanKeySignerDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3473         LDKCResult_ChanKeySignerDecodeErrorZ _res_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)_res;
3474         FREE((void*)_res);
3475         CResult_ChanKeySignerDecodeErrorZ_free(_res_conv);
3476 }
3477
3478 uint32_t CResult_1InMemoryChannelKeysDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3479         LDKInMemoryChannelKeys o_conv;
3480         o_conv.inner = (void*)(o & (~1));
3481         o_conv.is_owned = (o & 1) || (o == 0);
3482         if (o_conv.inner != NULL)
3483                 o_conv = InMemoryChannelKeys_clone(&o_conv);
3484         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
3485         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_ok(o_conv);
3486         return (long)ret_conv;
3487 }
3488
3489 uint32_t CResult_1InMemoryChannelKeysDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3490         LDKDecodeError e_conv;
3491         e_conv.inner = (void*)(e & (~1));
3492         e_conv.is_owned = (e & 1) || (e == 0);
3493         // Warning: we may need a move here but can't clone!
3494         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
3495         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_err(e_conv);
3496         return (long)ret_conv;
3497 }
3498
3499 void CResult_1InMemoryChannelKeysDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3500         LDKCResult_InMemoryChannelKeysDecodeErrorZ _res_conv = *(LDKCResult_InMemoryChannelKeysDecodeErrorZ*)_res;
3501         FREE((void*)_res);
3502         CResult_InMemoryChannelKeysDecodeErrorZ_free(_res_conv);
3503 }
3504
3505 uint32_t CResult_1TxOutAccessErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3506         LDKTxOut o_conv = *(LDKTxOut*)o;
3507         FREE((void*)o);
3508         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3509         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
3510         return (long)ret_conv;
3511 }
3512
3513 uint32_t CResult_1TxOutAccessErrorZ_1err(void* ctx_TODO, uint32_t e) {
3514         LDKAccessError e_conv = LDKAccessError_from_js(e);
3515         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3516         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
3517         return (long)ret_conv;
3518 }
3519
3520 void CResult_1TxOutAccessErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3521         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)_res;
3522         FREE((void*)_res);
3523         CResult_TxOutAccessErrorZ_free(_res_conv);
3524 }
3525
3526 uint32_t CResult_1NoneAPIErrorZ_1ok(void* ctx_TODO) {
3527         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3528         *ret_conv = CResult_NoneAPIErrorZ_ok();
3529         return (long)ret_conv;
3530 }
3531
3532 uint32_t CResult_1NoneAPIErrorZ_1err(void* ctx_TODO, uint32_t e) {
3533         LDKAPIError e_conv = *(LDKAPIError*)e;
3534         FREE((void*)e);
3535         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3536         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
3537         return (long)ret_conv;
3538 }
3539
3540 void CResult_1NoneAPIErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3541         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)_res;
3542         FREE((void*)_res);
3543         CResult_NoneAPIErrorZ_free(_res_conv);
3544 }
3545
3546 void CVec_1ChannelDetailsZ_1free(void* ctx_TODO, uint32_tArray _res) {
3547         LDKCVec_ChannelDetailsZ _res_constr;
3548         _res_constr.datalen = _res.len;
3549         if (_res_constr.datalen > 0)
3550                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
3551         else
3552                 _res_constr.data = NULL;
3553         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3554         for (size_t q = 0; q < _res_constr.datalen; q++) {
3555                 uint32_t arr_conv_16 = _res_vals[q];
3556                 LDKChannelDetails arr_conv_16_conv;
3557                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
3558                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
3559                 _res_constr.data[q] = arr_conv_16_conv;
3560         }
3561         CVec_ChannelDetailsZ_free(_res_constr);
3562 }
3563
3564 uint32_t CResult_1NonePaymentSendFailureZ_1ok(void* ctx_TODO) {
3565         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
3566         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
3567         return (long)ret_conv;
3568 }
3569
3570 uint32_t CResult_1NonePaymentSendFailureZ_1err(void* ctx_TODO, uint32_t e) {
3571         LDKPaymentSendFailure e_conv;
3572         e_conv.inner = (void*)(e & (~1));
3573         e_conv.is_owned = (e & 1) || (e == 0);
3574         // Warning: we may need a move here but can't clone!
3575         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
3576         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
3577         return (long)ret_conv;
3578 }
3579
3580 void CResult_1NonePaymentSendFailureZ_1free(void* ctx_TODO, uint32_t _res) {
3581         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)_res;
3582         FREE((void*)_res);
3583         CResult_NonePaymentSendFailureZ_free(_res_conv);
3584 }
3585
3586 void CVec_1NetAddressZ_1free(void* ctx_TODO, uint32_tArray _res) {
3587         LDKCVec_NetAddressZ _res_constr;
3588         _res_constr.datalen = _res.len;
3589         if (_res_constr.datalen > 0)
3590                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
3591         else
3592                 _res_constr.data = NULL;
3593         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3594         for (size_t m = 0; m < _res_constr.datalen; m++) {
3595                 uint32_t arr_conv_12 = _res_vals[m];
3596                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
3597                 FREE((void*)arr_conv_12);
3598                 _res_constr.data[m] = arr_conv_12_conv;
3599         }
3600         CVec_NetAddressZ_free(_res_constr);
3601 }
3602
3603 void CVec_1ChannelMonitorZ_1free(void* ctx_TODO, uint32_tArray _res) {
3604         LDKCVec_ChannelMonitorZ _res_constr;
3605         _res_constr.datalen = _res.len;
3606         if (_res_constr.datalen > 0)
3607                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
3608         else
3609                 _res_constr.data = NULL;
3610         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3611         for (size_t q = 0; q < _res_constr.datalen; q++) {
3612                 uint32_t arr_conv_16 = _res_vals[q];
3613                 LDKChannelMonitor arr_conv_16_conv;
3614                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
3615                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
3616                 _res_constr.data[q] = arr_conv_16_conv;
3617         }
3618         CVec_ChannelMonitorZ_free(_res_constr);
3619 }
3620
3621 void C2Tuple_1BlockHashChannelManagerZ_1free(void* ctx_TODO, uint32_t _res) {
3622         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)_res;
3623         FREE((void*)_res);
3624         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
3625 }
3626
3627 uint32_t C2Tuple_1BlockHashChannelManagerZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) {
3628         LDKThirtyTwoBytes a_ref;
3629         CHECK(a.len == 32);
3630         memcpy(a_ref.data, a.ptr, 32);
3631         LDKChannelManager b_conv;
3632         b_conv.inner = (void*)(b & (~1));
3633         b_conv.is_owned = (b & 1) || (b == 0);
3634         // Warning: we may need a move here but can't clone!
3635         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
3636         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
3637         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
3638         // XXX: We likely need to clone here, but no _clone fn is available for ChannelManager
3639         return (long)ret_ref;
3640 }
3641
3642 uint32_t CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3643         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)o;
3644         FREE((void*)o);
3645         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
3646         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
3647         return (long)ret_conv;
3648 }
3649
3650 uint32_t CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3651         LDKDecodeError e_conv;
3652         e_conv.inner = (void*)(e & (~1));
3653         e_conv.is_owned = (e & 1) || (e == 0);
3654         // Warning: we may need a move here but can't clone!
3655         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
3656         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
3657         return (long)ret_conv;
3658 }
3659
3660 void CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3661         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)_res;
3662         FREE((void*)_res);
3663         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
3664 }
3665
3666 uint32_t CResult_1NetAddressu8Z_1ok(void* ctx_TODO, uint32_t o) {
3667         LDKNetAddress o_conv = *(LDKNetAddress*)o;
3668         FREE((void*)o);
3669         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3670         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
3671         return (long)ret_conv;
3672 }
3673
3674 uint32_t CResult_1NetAddressu8Z_1err(void* ctx_TODO, int8_t e) {
3675         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
3676         *ret_conv = CResult_NetAddressu8Z_err(e);
3677         return (long)ret_conv;
3678 }
3679
3680 void CResult_1NetAddressu8Z_1free(void* ctx_TODO, uint32_t _res) {
3681         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)_res;
3682         FREE((void*)_res);
3683         CResult_NetAddressu8Z_free(_res_conv);
3684 }
3685
3686 uint32_t CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3687         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)o;
3688         FREE((void*)o);
3689         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
3690         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
3691         return (long)ret_conv;
3692 }
3693
3694 uint32_t CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3695         LDKDecodeError e_conv;
3696         e_conv.inner = (void*)(e & (~1));
3697         e_conv.is_owned = (e & 1) || (e == 0);
3698         // Warning: we may need a move here but can't clone!
3699         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
3700         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
3701         return (long)ret_conv;
3702 }
3703
3704 void CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3705         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)_res;
3706         FREE((void*)_res);
3707         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
3708 }
3709
3710 void CVec_1u64Z_1free(void* ctx_TODO, int64_tArray _res) {
3711         LDKCVec_u64Z _res_constr;
3712         _res_constr.datalen = _res.len;
3713         if (_res_constr.datalen > 0)
3714                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
3715         else
3716                 _res_constr.data = NULL;
3717         int64_t* _res_vals = (int64_t*) _res.ptr;
3718         for (size_t g = 0; g < _res_constr.datalen; g++) {
3719                 int64_t arr_conv_6 = _res_vals[g];
3720                 _res_constr.data[g] = arr_conv_6;
3721         }
3722         CVec_u64Z_free(_res_constr);
3723 }
3724
3725 void CVec_1UpdateAddHTLCZ_1free(void* ctx_TODO, uint32_tArray _res) {
3726         LDKCVec_UpdateAddHTLCZ _res_constr;
3727         _res_constr.datalen = _res.len;
3728         if (_res_constr.datalen > 0)
3729                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
3730         else
3731                 _res_constr.data = NULL;
3732         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3733         for (size_t p = 0; p < _res_constr.datalen; p++) {
3734                 uint32_t arr_conv_15 = _res_vals[p];
3735                 LDKUpdateAddHTLC arr_conv_15_conv;
3736                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
3737                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
3738                 _res_constr.data[p] = arr_conv_15_conv;
3739         }
3740         CVec_UpdateAddHTLCZ_free(_res_constr);
3741 }
3742
3743 void CVec_1UpdateFulfillHTLCZ_1free(void* ctx_TODO, uint32_tArray _res) {
3744         LDKCVec_UpdateFulfillHTLCZ _res_constr;
3745         _res_constr.datalen = _res.len;
3746         if (_res_constr.datalen > 0)
3747                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
3748         else
3749                 _res_constr.data = NULL;
3750         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3751         for (size_t t = 0; t < _res_constr.datalen; t++) {
3752                 uint32_t arr_conv_19 = _res_vals[t];
3753                 LDKUpdateFulfillHTLC arr_conv_19_conv;
3754                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
3755                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
3756                 _res_constr.data[t] = arr_conv_19_conv;
3757         }
3758         CVec_UpdateFulfillHTLCZ_free(_res_constr);
3759 }
3760
3761 void CVec_1UpdateFailHTLCZ_1free(void* ctx_TODO, uint32_tArray _res) {
3762         LDKCVec_UpdateFailHTLCZ _res_constr;
3763         _res_constr.datalen = _res.len;
3764         if (_res_constr.datalen > 0)
3765                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
3766         else
3767                 _res_constr.data = NULL;
3768         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3769         for (size_t q = 0; q < _res_constr.datalen; q++) {
3770                 uint32_t arr_conv_16 = _res_vals[q];
3771                 LDKUpdateFailHTLC arr_conv_16_conv;
3772                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
3773                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
3774                 _res_constr.data[q] = arr_conv_16_conv;
3775         }
3776         CVec_UpdateFailHTLCZ_free(_res_constr);
3777 }
3778
3779 void CVec_1UpdateFailMalformedHTLCZ_1free(void* ctx_TODO, uint32_tArray _res) {
3780         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
3781         _res_constr.datalen = _res.len;
3782         if (_res_constr.datalen > 0)
3783                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
3784         else
3785                 _res_constr.data = NULL;
3786         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3787         for (size_t z = 0; z < _res_constr.datalen; z++) {
3788                 uint32_t arr_conv_25 = _res_vals[z];
3789                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
3790                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
3791                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
3792                 _res_constr.data[z] = arr_conv_25_conv;
3793         }
3794         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
3795 }
3796
3797 uint32_t CResult_1boolLightningErrorZ_1ok(void* ctx_TODO, jboolean o) {
3798         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3799         *ret_conv = CResult_boolLightningErrorZ_ok(o);
3800         return (long)ret_conv;
3801 }
3802
3803 uint32_t CResult_1boolLightningErrorZ_1err(void* ctx_TODO, uint32_t e) {
3804         LDKLightningError e_conv;
3805         e_conv.inner = (void*)(e & (~1));
3806         e_conv.is_owned = (e & 1) || (e == 0);
3807         // Warning: we may need a move here but can't clone!
3808         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3809         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
3810         return (long)ret_conv;
3811 }
3812
3813 void CResult_1boolLightningErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3814         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)_res;
3815         FREE((void*)_res);
3816         CResult_boolLightningErrorZ_free(_res_conv);
3817 }
3818
3819 void C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(void* ctx_TODO, uint32_t _res) {
3820         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)_res;
3821         FREE((void*)_res);
3822         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
3823 }
3824
3825 uint32_t C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(void* ctx_TODO, uint32_t a, uint32_t b, uint32_t c) {
3826         LDKChannelAnnouncement a_conv;
3827         a_conv.inner = (void*)(a & (~1));
3828         a_conv.is_owned = (a & 1) || (a == 0);
3829         if (a_conv.inner != NULL)
3830                 a_conv = ChannelAnnouncement_clone(&a_conv);
3831         LDKChannelUpdate b_conv;
3832         b_conv.inner = (void*)(b & (~1));
3833         b_conv.is_owned = (b & 1) || (b == 0);
3834         if (b_conv.inner != NULL)
3835                 b_conv = ChannelUpdate_clone(&b_conv);
3836         LDKChannelUpdate c_conv;
3837         c_conv.inner = (void*)(c & (~1));
3838         c_conv.is_owned = (c & 1) || (c == 0);
3839         if (c_conv.inner != NULL)
3840                 c_conv = ChannelUpdate_clone(&c_conv);
3841         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3842         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
3843         ret_ref->a = ChannelAnnouncement_clone(&ret_ref->a);
3844         ret_ref->b = ChannelUpdate_clone(&ret_ref->b);
3845         ret_ref->c = ChannelUpdate_clone(&ret_ref->c);
3846         return (long)ret_ref;
3847 }
3848
3849 void CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(void* ctx_TODO, uint32_tArray _res) {
3850         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
3851         _res_constr.datalen = _res.len;
3852         if (_res_constr.datalen > 0)
3853                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
3854         else
3855                 _res_constr.data = NULL;
3856         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3857         for (size_t l = 0; l < _res_constr.datalen; l++) {
3858                 uint32_t arr_conv_63 = _res_vals[l];
3859                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
3860                 FREE((void*)arr_conv_63);
3861                 _res_constr.data[l] = arr_conv_63_conv;
3862         }
3863         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
3864 }
3865
3866 void CVec_1NodeAnnouncementZ_1free(void* ctx_TODO, uint32_tArray _res) {
3867         LDKCVec_NodeAnnouncementZ _res_constr;
3868         _res_constr.datalen = _res.len;
3869         if (_res_constr.datalen > 0)
3870                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
3871         else
3872                 _res_constr.data = NULL;
3873         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3874         for (size_t s = 0; s < _res_constr.datalen; s++) {
3875                 uint32_t arr_conv_18 = _res_vals[s];
3876                 LDKNodeAnnouncement arr_conv_18_conv;
3877                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
3878                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
3879                 _res_constr.data[s] = arr_conv_18_conv;
3880         }
3881         CVec_NodeAnnouncementZ_free(_res_constr);
3882 }
3883
3884 uint32_t CResult_1NoneLightningErrorZ_1ok(void* ctx_TODO) {
3885         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
3886         *ret_conv = CResult_NoneLightningErrorZ_ok();
3887         return (long)ret_conv;
3888 }
3889
3890 uint32_t CResult_1NoneLightningErrorZ_1err(void* ctx_TODO, uint32_t e) {
3891         LDKLightningError e_conv;
3892         e_conv.inner = (void*)(e & (~1));
3893         e_conv.is_owned = (e & 1) || (e == 0);
3894         // Warning: we may need a move here but can't clone!
3895         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
3896         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
3897         return (long)ret_conv;
3898 }
3899
3900 void CResult_1NoneLightningErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3901         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)_res;
3902         FREE((void*)_res);
3903         CResult_NoneLightningErrorZ_free(_res_conv);
3904 }
3905
3906 uint32_t CResult_1ChannelReestablishDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3907         LDKChannelReestablish o_conv;
3908         o_conv.inner = (void*)(o & (~1));
3909         o_conv.is_owned = (o & 1) || (o == 0);
3910         if (o_conv.inner != NULL)
3911                 o_conv = ChannelReestablish_clone(&o_conv);
3912         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
3913         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
3914         return (long)ret_conv;
3915 }
3916
3917 uint32_t CResult_1ChannelReestablishDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3918         LDKDecodeError e_conv;
3919         e_conv.inner = (void*)(e & (~1));
3920         e_conv.is_owned = (e & 1) || (e == 0);
3921         // Warning: we may need a move here but can't clone!
3922         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
3923         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
3924         return (long)ret_conv;
3925 }
3926
3927 void CResult_1ChannelReestablishDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3928         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)_res;
3929         FREE((void*)_res);
3930         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
3931 }
3932
3933 uint32_t CResult_1InitDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3934         LDKInit o_conv;
3935         o_conv.inner = (void*)(o & (~1));
3936         o_conv.is_owned = (o & 1) || (o == 0);
3937         if (o_conv.inner != NULL)
3938                 o_conv = Init_clone(&o_conv);
3939         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
3940         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
3941         return (long)ret_conv;
3942 }
3943
3944 uint32_t CResult_1InitDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3945         LDKDecodeError e_conv;
3946         e_conv.inner = (void*)(e & (~1));
3947         e_conv.is_owned = (e & 1) || (e == 0);
3948         // Warning: we may need a move here but can't clone!
3949         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
3950         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
3951         return (long)ret_conv;
3952 }
3953
3954 void CResult_1InitDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3955         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)_res;
3956         FREE((void*)_res);
3957         CResult_InitDecodeErrorZ_free(_res_conv);
3958 }
3959
3960 uint32_t CResult_1PingDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3961         LDKPing o_conv;
3962         o_conv.inner = (void*)(o & (~1));
3963         o_conv.is_owned = (o & 1) || (o == 0);
3964         if (o_conv.inner != NULL)
3965                 o_conv = Ping_clone(&o_conv);
3966         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
3967         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
3968         return (long)ret_conv;
3969 }
3970
3971 uint32_t CResult_1PingDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3972         LDKDecodeError e_conv;
3973         e_conv.inner = (void*)(e & (~1));
3974         e_conv.is_owned = (e & 1) || (e == 0);
3975         // Warning: we may need a move here but can't clone!
3976         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
3977         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
3978         return (long)ret_conv;
3979 }
3980
3981 void CResult_1PingDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3982         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)_res;
3983         FREE((void*)_res);
3984         CResult_PingDecodeErrorZ_free(_res_conv);
3985 }
3986
3987 uint32_t CResult_1PongDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3988         LDKPong o_conv;
3989         o_conv.inner = (void*)(o & (~1));
3990         o_conv.is_owned = (o & 1) || (o == 0);
3991         if (o_conv.inner != NULL)
3992                 o_conv = Pong_clone(&o_conv);
3993         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
3994         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
3995         return (long)ret_conv;
3996 }
3997
3998 uint32_t CResult_1PongDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3999         LDKDecodeError e_conv;
4000         e_conv.inner = (void*)(e & (~1));
4001         e_conv.is_owned = (e & 1) || (e == 0);
4002         // Warning: we may need a move here but can't clone!
4003         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
4004         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
4005         return (long)ret_conv;
4006 }
4007
4008 void CResult_1PongDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4009         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)_res;
4010         FREE((void*)_res);
4011         CResult_PongDecodeErrorZ_free(_res_conv);
4012 }
4013
4014 uint32_t CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4015         LDKUnsignedChannelAnnouncement o_conv;
4016         o_conv.inner = (void*)(o & (~1));
4017         o_conv.is_owned = (o & 1) || (o == 0);
4018         if (o_conv.inner != NULL)
4019                 o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
4020         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
4021         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
4022         return (long)ret_conv;
4023 }
4024
4025 uint32_t CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4026         LDKDecodeError e_conv;
4027         e_conv.inner = (void*)(e & (~1));
4028         e_conv.is_owned = (e & 1) || (e == 0);
4029         // Warning: we may need a move here but can't clone!
4030         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
4031         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
4032         return (long)ret_conv;
4033 }
4034
4035 void CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4036         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)_res;
4037         FREE((void*)_res);
4038         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
4039 }
4040
4041 uint32_t CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4042         LDKUnsignedChannelUpdate o_conv;
4043         o_conv.inner = (void*)(o & (~1));
4044         o_conv.is_owned = (o & 1) || (o == 0);
4045         if (o_conv.inner != NULL)
4046                 o_conv = UnsignedChannelUpdate_clone(&o_conv);
4047         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
4048         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
4049         return (long)ret_conv;
4050 }
4051
4052 uint32_t CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4053         LDKDecodeError e_conv;
4054         e_conv.inner = (void*)(e & (~1));
4055         e_conv.is_owned = (e & 1) || (e == 0);
4056         // Warning: we may need a move here but can't clone!
4057         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
4058         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
4059         return (long)ret_conv;
4060 }
4061
4062 void CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4063         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)_res;
4064         FREE((void*)_res);
4065         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
4066 }
4067
4068 uint32_t CResult_1ErrorMessageDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4069         LDKErrorMessage o_conv;
4070         o_conv.inner = (void*)(o & (~1));
4071         o_conv.is_owned = (o & 1) || (o == 0);
4072         if (o_conv.inner != NULL)
4073                 o_conv = ErrorMessage_clone(&o_conv);
4074         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
4075         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
4076         return (long)ret_conv;
4077 }
4078
4079 uint32_t CResult_1ErrorMessageDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4080         LDKDecodeError e_conv;
4081         e_conv.inner = (void*)(e & (~1));
4082         e_conv.is_owned = (e & 1) || (e == 0);
4083         // Warning: we may need a move here but can't clone!
4084         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
4085         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
4086         return (long)ret_conv;
4087 }
4088
4089 void CResult_1ErrorMessageDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4090         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)_res;
4091         FREE((void*)_res);
4092         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
4093 }
4094
4095 uint32_t CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4096         LDKUnsignedNodeAnnouncement o_conv;
4097         o_conv.inner = (void*)(o & (~1));
4098         o_conv.is_owned = (o & 1) || (o == 0);
4099         if (o_conv.inner != NULL)
4100                 o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
4101         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
4102         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
4103         return (long)ret_conv;
4104 }
4105
4106 uint32_t CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4107         LDKDecodeError e_conv;
4108         e_conv.inner = (void*)(e & (~1));
4109         e_conv.is_owned = (e & 1) || (e == 0);
4110         // Warning: we may need a move here but can't clone!
4111         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
4112         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
4113         return (long)ret_conv;
4114 }
4115
4116 void CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4117         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)_res;
4118         FREE((void*)_res);
4119         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
4120 }
4121
4122 uint32_t CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4123         LDKQueryShortChannelIds o_conv;
4124         o_conv.inner = (void*)(o & (~1));
4125         o_conv.is_owned = (o & 1) || (o == 0);
4126         if (o_conv.inner != NULL)
4127                 o_conv = QueryShortChannelIds_clone(&o_conv);
4128         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
4129         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
4130         return (long)ret_conv;
4131 }
4132
4133 uint32_t CResult_1QueryShortChannelIdsDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4134         LDKDecodeError e_conv;
4135         e_conv.inner = (void*)(e & (~1));
4136         e_conv.is_owned = (e & 1) || (e == 0);
4137         // Warning: we may need a move here but can't clone!
4138         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
4139         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
4140         return (long)ret_conv;
4141 }
4142
4143 void CResult_1QueryShortChannelIdsDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4144         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)_res;
4145         FREE((void*)_res);
4146         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
4147 }
4148
4149 uint32_t CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4150         LDKReplyShortChannelIdsEnd o_conv;
4151         o_conv.inner = (void*)(o & (~1));
4152         o_conv.is_owned = (o & 1) || (o == 0);
4153         if (o_conv.inner != NULL)
4154                 o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
4155         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
4156         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
4157         return (long)ret_conv;
4158 }
4159
4160 uint32_t CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4161         LDKDecodeError e_conv;
4162         e_conv.inner = (void*)(e & (~1));
4163         e_conv.is_owned = (e & 1) || (e == 0);
4164         // Warning: we may need a move here but can't clone!
4165         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
4166         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
4167         return (long)ret_conv;
4168 }
4169
4170 void CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4171         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)_res;
4172         FREE((void*)_res);
4173         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
4174 }
4175
4176 uint32_t CResult_1QueryChannelRangeDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4177         LDKQueryChannelRange o_conv;
4178         o_conv.inner = (void*)(o & (~1));
4179         o_conv.is_owned = (o & 1) || (o == 0);
4180         if (o_conv.inner != NULL)
4181                 o_conv = QueryChannelRange_clone(&o_conv);
4182         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
4183         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
4184         return (long)ret_conv;
4185 }
4186
4187 uint32_t CResult_1QueryChannelRangeDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4188         LDKDecodeError e_conv;
4189         e_conv.inner = (void*)(e & (~1));
4190         e_conv.is_owned = (e & 1) || (e == 0);
4191         // Warning: we may need a move here but can't clone!
4192         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
4193         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
4194         return (long)ret_conv;
4195 }
4196
4197 void CResult_1QueryChannelRangeDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4198         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)_res;
4199         FREE((void*)_res);
4200         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
4201 }
4202
4203 uint32_t CResult_1ReplyChannelRangeDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4204         LDKReplyChannelRange o_conv;
4205         o_conv.inner = (void*)(o & (~1));
4206         o_conv.is_owned = (o & 1) || (o == 0);
4207         if (o_conv.inner != NULL)
4208                 o_conv = ReplyChannelRange_clone(&o_conv);
4209         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
4210         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
4211         return (long)ret_conv;
4212 }
4213
4214 uint32_t CResult_1ReplyChannelRangeDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4215         LDKDecodeError e_conv;
4216         e_conv.inner = (void*)(e & (~1));
4217         e_conv.is_owned = (e & 1) || (e == 0);
4218         // Warning: we may need a move here but can't clone!
4219         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
4220         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
4221         return (long)ret_conv;
4222 }
4223
4224 void CResult_1ReplyChannelRangeDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4225         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)_res;
4226         FREE((void*)_res);
4227         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
4228 }
4229
4230 uint32_t CResult_1GossipTimestampFilterDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4231         LDKGossipTimestampFilter o_conv;
4232         o_conv.inner = (void*)(o & (~1));
4233         o_conv.is_owned = (o & 1) || (o == 0);
4234         if (o_conv.inner != NULL)
4235                 o_conv = GossipTimestampFilter_clone(&o_conv);
4236         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
4237         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
4238         return (long)ret_conv;
4239 }
4240
4241 uint32_t CResult_1GossipTimestampFilterDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4242         LDKDecodeError e_conv;
4243         e_conv.inner = (void*)(e & (~1));
4244         e_conv.is_owned = (e & 1) || (e == 0);
4245         // Warning: we may need a move here but can't clone!
4246         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
4247         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
4248         return (long)ret_conv;
4249 }
4250
4251 void CResult_1GossipTimestampFilterDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4252         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)_res;
4253         FREE((void*)_res);
4254         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
4255 }
4256
4257 void CVec_1PublicKeyZ_1free(void* ctx_TODO, uint32_tArray _res) {
4258         LDKCVec_PublicKeyZ _res_constr;
4259         _res_constr.datalen = _res.len;
4260         if (_res_constr.datalen > 0)
4261                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
4262         else
4263                 _res_constr.data = NULL;
4264         int8_tArray* _res_vals = (int8_tArray*) _res.ptr;
4265         for (size_t i = 0; i < _res_constr.datalen; i++) {
4266                 int8_tArray arr_conv_8 = _res_vals[i];
4267                 LDKPublicKey arr_conv_8_ref;
4268                 CHECK(arr_conv_8.len == 33);
4269                 memcpy(arr_conv_8_ref.compressed_form, arr_conv_8.ptr, 33);
4270                 _res_constr.data[i] = arr_conv_8_ref;
4271         }
4272         CVec_PublicKeyZ_free(_res_constr);
4273 }
4274
4275 void CVec_1u8Z_1free(void* ctx_TODO, int8_tArray _res) {
4276         LDKCVec_u8Z _res_ref;
4277         _res_ref.datalen = _res.len;
4278         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
4279         memcpy(_res_ref.data, _res.ptr, _res_ref.datalen);
4280         CVec_u8Z_free(_res_ref);
4281 }
4282
4283 uint32_t CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(void* ctx_TODO, int8_tArray o) {
4284         LDKCVec_u8Z o_ref;
4285         o_ref.datalen = o.len;
4286         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
4287         memcpy(o_ref.data, o.ptr, o_ref.datalen);
4288         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4289         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
4290         return (long)ret_conv;
4291 }
4292
4293 uint32_t CResult_1CVec_1u8ZPeerHandleErrorZ_1err(void* ctx_TODO, uint32_t e) {
4294         LDKPeerHandleError e_conv;
4295         e_conv.inner = (void*)(e & (~1));
4296         e_conv.is_owned = (e & 1) || (e == 0);
4297         // Warning: we may need a move here but can't clone!
4298         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4299         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
4300         return (long)ret_conv;
4301 }
4302
4303 void CResult_1CVec_1u8ZPeerHandleErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4304         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)_res;
4305         FREE((void*)_res);
4306         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
4307 }
4308
4309 uint32_t CResult_1NonePeerHandleErrorZ_1ok(void* ctx_TODO) {
4310         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4311         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
4312         return (long)ret_conv;
4313 }
4314
4315 uint32_t CResult_1NonePeerHandleErrorZ_1err(void* ctx_TODO, uint32_t e) {
4316         LDKPeerHandleError e_conv;
4317         e_conv.inner = (void*)(e & (~1));
4318         e_conv.is_owned = (e & 1) || (e == 0);
4319         // Warning: we may need a move here but can't clone!
4320         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4321         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
4322         return (long)ret_conv;
4323 }
4324
4325 void CResult_1NonePeerHandleErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4326         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)_res;
4327         FREE((void*)_res);
4328         CResult_NonePeerHandleErrorZ_free(_res_conv);
4329 }
4330
4331 uint32_t CResult_1boolPeerHandleErrorZ_1ok(void* ctx_TODO, jboolean o) {
4332         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4333         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
4334         return (long)ret_conv;
4335 }
4336
4337 uint32_t CResult_1boolPeerHandleErrorZ_1err(void* ctx_TODO, uint32_t e) {
4338         LDKPeerHandleError e_conv;
4339         e_conv.inner = (void*)(e & (~1));
4340         e_conv.is_owned = (e & 1) || (e == 0);
4341         // Warning: we may need a move here but can't clone!
4342         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4343         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
4344         return (long)ret_conv;
4345 }
4346
4347 void CResult_1boolPeerHandleErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4348         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)_res;
4349         FREE((void*)_res);
4350         CResult_boolPeerHandleErrorZ_free(_res_conv);
4351 }
4352
4353 uint32_t CResult_1SecretKeySecpErrorZ_1ok(void* ctx_TODO, int8_tArray o) {
4354         LDKSecretKey o_ref;
4355         CHECK(o.len == 32);
4356         memcpy(o_ref.bytes, o.ptr, 32);
4357         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4358         *ret_conv = CResult_SecretKeySecpErrorZ_ok(o_ref);
4359         return (long)ret_conv;
4360 }
4361
4362 uint32_t CResult_1SecretKeySecpErrorZ_1err(void* ctx_TODO, uint32_t e) {
4363         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
4364         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4365         *ret_conv = CResult_SecretKeySecpErrorZ_err(e_conv);
4366         return (long)ret_conv;
4367 }
4368
4369 void CResult_1SecretKeySecpErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4370         LDKCResult_SecretKeySecpErrorZ _res_conv = *(LDKCResult_SecretKeySecpErrorZ*)_res;
4371         FREE((void*)_res);
4372         CResult_SecretKeySecpErrorZ_free(_res_conv);
4373 }
4374
4375 uint32_t CResult_1PublicKeySecpErrorZ_1ok(void* ctx_TODO, int8_tArray o) {
4376         LDKPublicKey o_ref;
4377         CHECK(o.len == 33);
4378         memcpy(o_ref.compressed_form, o.ptr, 33);
4379         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4380         *ret_conv = CResult_PublicKeySecpErrorZ_ok(o_ref);
4381         return (long)ret_conv;
4382 }
4383
4384 uint32_t CResult_1PublicKeySecpErrorZ_1err(void* ctx_TODO, uint32_t e) {
4385         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
4386         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4387         *ret_conv = CResult_PublicKeySecpErrorZ_err(e_conv);
4388         return (long)ret_conv;
4389 }
4390
4391 void CResult_1PublicKeySecpErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4392         LDKCResult_PublicKeySecpErrorZ _res_conv = *(LDKCResult_PublicKeySecpErrorZ*)_res;
4393         FREE((void*)_res);
4394         CResult_PublicKeySecpErrorZ_free(_res_conv);
4395 }
4396
4397 uint32_t CResult_1TxCreationKeysSecpErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4398         LDKTxCreationKeys o_conv;
4399         o_conv.inner = (void*)(o & (~1));
4400         o_conv.is_owned = (o & 1) || (o == 0);
4401         if (o_conv.inner != NULL)
4402                 o_conv = TxCreationKeys_clone(&o_conv);
4403         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4404         *ret_conv = CResult_TxCreationKeysSecpErrorZ_ok(o_conv);
4405         return (long)ret_conv;
4406 }
4407
4408 uint32_t CResult_1TxCreationKeysSecpErrorZ_1err(void* ctx_TODO, uint32_t e) {
4409         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
4410         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
4411         *ret_conv = CResult_TxCreationKeysSecpErrorZ_err(e_conv);
4412         return (long)ret_conv;
4413 }
4414
4415 void CResult_1TxCreationKeysSecpErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4416         LDKCResult_TxCreationKeysSecpErrorZ _res_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)_res;
4417         FREE((void*)_res);
4418         CResult_TxCreationKeysSecpErrorZ_free(_res_conv);
4419 }
4420
4421 uint32_t CResult_1TrustedCommitmentTransactionNoneZ_1ok(void* ctx_TODO, uint32_t o) {
4422         LDKTrustedCommitmentTransaction o_conv;
4423         o_conv.inner = (void*)(o & (~1));
4424         o_conv.is_owned = (o & 1) || (o == 0);
4425         // Warning: we may need a move here but can't clone!
4426         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
4427         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
4428         return (long)ret_conv;
4429 }
4430
4431 uint32_t CResult_1TrustedCommitmentTransactionNoneZ_1err(void* ctx_TODO) {
4432         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
4433         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
4434         return (long)ret_conv;
4435 }
4436
4437 void CResult_1TrustedCommitmentTransactionNoneZ_1free(void* ctx_TODO, uint32_t _res) {
4438         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)_res;
4439         FREE((void*)_res);
4440         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
4441 }
4442
4443 void CVec_1RouteHopZ_1free(void* ctx_TODO, uint32_tArray _res) {
4444         LDKCVec_RouteHopZ _res_constr;
4445         _res_constr.datalen = _res.len;
4446         if (_res_constr.datalen > 0)
4447                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
4448         else
4449                 _res_constr.data = NULL;
4450         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4451         for (size_t k = 0; k < _res_constr.datalen; k++) {
4452                 uint32_t arr_conv_10 = _res_vals[k];
4453                 LDKRouteHop arr_conv_10_conv;
4454                 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
4455                 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
4456                 _res_constr.data[k] = arr_conv_10_conv;
4457         }
4458         CVec_RouteHopZ_free(_res_constr);
4459 }
4460
4461 void CVec_1CVec_1RouteHopZZ_1free(void* ctx_TODO, uint32_tArray _res) {
4462         LDKCVec_CVec_RouteHopZZ _res_constr;
4463         _res_constr.datalen = _res.len;
4464         if (_res_constr.datalen > 0)
4465                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
4466         else
4467                 _res_constr.data = NULL;
4468         uint32_tArray* _res_vals = (uint32_tArray*) _res.ptr;
4469         for (size_t m = 0; m < _res_constr.datalen; m++) {
4470                 uint32_tArray arr_conv_12 = _res_vals[m];
4471                 LDKCVec_RouteHopZ arr_conv_12_constr;
4472                 arr_conv_12_constr.datalen = arr_conv_12.len;
4473                 if (arr_conv_12_constr.datalen > 0)
4474                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
4475                 else
4476                         arr_conv_12_constr.data = NULL;
4477                 uint32_t* arr_conv_12_vals = (uint32_t*) arr_conv_12.ptr;
4478                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
4479                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
4480                         LDKRouteHop arr_conv_10_conv;
4481                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
4482                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
4483                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
4484                 }
4485                 _res_constr.data[m] = arr_conv_12_constr;
4486         }
4487         CVec_CVec_RouteHopZZ_free(_res_constr);
4488 }
4489
4490 uint32_t CResult_1RouteDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4491         LDKRoute o_conv;
4492         o_conv.inner = (void*)(o & (~1));
4493         o_conv.is_owned = (o & 1) || (o == 0);
4494         if (o_conv.inner != NULL)
4495                 o_conv = Route_clone(&o_conv);
4496         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
4497         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
4498         return (long)ret_conv;
4499 }
4500
4501 uint32_t CResult_1RouteDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4502         LDKDecodeError e_conv;
4503         e_conv.inner = (void*)(e & (~1));
4504         e_conv.is_owned = (e & 1) || (e == 0);
4505         // Warning: we may need a move here but can't clone!
4506         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
4507         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
4508         return (long)ret_conv;
4509 }
4510
4511 void CResult_1RouteDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4512         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)_res;
4513         FREE((void*)_res);
4514         CResult_RouteDecodeErrorZ_free(_res_conv);
4515 }
4516
4517 void CVec_1RouteHintZ_1free(void* ctx_TODO, uint32_tArray _res) {
4518         LDKCVec_RouteHintZ _res_constr;
4519         _res_constr.datalen = _res.len;
4520         if (_res_constr.datalen > 0)
4521                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
4522         else
4523                 _res_constr.data = NULL;
4524         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4525         for (size_t l = 0; l < _res_constr.datalen; l++) {
4526                 uint32_t arr_conv_11 = _res_vals[l];
4527                 LDKRouteHint arr_conv_11_conv;
4528                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
4529                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
4530                 _res_constr.data[l] = arr_conv_11_conv;
4531         }
4532         CVec_RouteHintZ_free(_res_constr);
4533 }
4534
4535 uint32_t CResult_1RouteLightningErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4536         LDKRoute o_conv;
4537         o_conv.inner = (void*)(o & (~1));
4538         o_conv.is_owned = (o & 1) || (o == 0);
4539         if (o_conv.inner != NULL)
4540                 o_conv = Route_clone(&o_conv);
4541         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4542         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
4543         return (long)ret_conv;
4544 }
4545
4546 uint32_t CResult_1RouteLightningErrorZ_1err(void* ctx_TODO, uint32_t e) {
4547         LDKLightningError e_conv;
4548         e_conv.inner = (void*)(e & (~1));
4549         e_conv.is_owned = (e & 1) || (e == 0);
4550         // Warning: we may need a move here but can't clone!
4551         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
4552         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
4553         return (long)ret_conv;
4554 }
4555
4556 void CResult_1RouteLightningErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4557         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)_res;
4558         FREE((void*)_res);
4559         CResult_RouteLightningErrorZ_free(_res_conv);
4560 }
4561
4562 uint32_t CResult_1RoutingFeesDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4563         LDKRoutingFees o_conv;
4564         o_conv.inner = (void*)(o & (~1));
4565         o_conv.is_owned = (o & 1) || (o == 0);
4566         if (o_conv.inner != NULL)
4567                 o_conv = RoutingFees_clone(&o_conv);
4568         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
4569         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
4570         return (long)ret_conv;
4571 }
4572
4573 uint32_t CResult_1RoutingFeesDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4574         LDKDecodeError e_conv;
4575         e_conv.inner = (void*)(e & (~1));
4576         e_conv.is_owned = (e & 1) || (e == 0);
4577         // Warning: we may need a move here but can't clone!
4578         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
4579         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
4580         return (long)ret_conv;
4581 }
4582
4583 void CResult_1RoutingFeesDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4584         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)_res;
4585         FREE((void*)_res);
4586         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
4587 }
4588
4589 uint32_t CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4590         LDKNodeAnnouncementInfo o_conv;
4591         o_conv.inner = (void*)(o & (~1));
4592         o_conv.is_owned = (o & 1) || (o == 0);
4593         // Warning: we may need a move here but can't clone!
4594         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
4595         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
4596         return (long)ret_conv;
4597 }
4598
4599 uint32_t CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4600         LDKDecodeError e_conv;
4601         e_conv.inner = (void*)(e & (~1));
4602         e_conv.is_owned = (e & 1) || (e == 0);
4603         // Warning: we may need a move here but can't clone!
4604         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
4605         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
4606         return (long)ret_conv;
4607 }
4608
4609 void CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4610         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)_res;
4611         FREE((void*)_res);
4612         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
4613 }
4614
4615 uint32_t CResult_1NodeInfoDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4616         LDKNodeInfo o_conv;
4617         o_conv.inner = (void*)(o & (~1));
4618         o_conv.is_owned = (o & 1) || (o == 0);
4619         // Warning: we may need a move here but can't clone!
4620         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
4621         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
4622         return (long)ret_conv;
4623 }
4624
4625 uint32_t CResult_1NodeInfoDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4626         LDKDecodeError e_conv;
4627         e_conv.inner = (void*)(e & (~1));
4628         e_conv.is_owned = (e & 1) || (e == 0);
4629         // Warning: we may need a move here but can't clone!
4630         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
4631         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
4632         return (long)ret_conv;
4633 }
4634
4635 void CResult_1NodeInfoDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4636         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)_res;
4637         FREE((void*)_res);
4638         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
4639 }
4640
4641 uint32_t CResult_1NetworkGraphDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4642         LDKNetworkGraph o_conv;
4643         o_conv.inner = (void*)(o & (~1));
4644         o_conv.is_owned = (o & 1) || (o == 0);
4645         // Warning: we may need a move here but can't clone!
4646         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
4647         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
4648         return (long)ret_conv;
4649 }
4650
4651 uint32_t CResult_1NetworkGraphDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4652         LDKDecodeError e_conv;
4653         e_conv.inner = (void*)(e & (~1));
4654         e_conv.is_owned = (e & 1) || (e == 0);
4655         // Warning: we may need a move here but can't clone!
4656         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
4657         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
4658         return (long)ret_conv;
4659 }
4660
4661 void CResult_1NetworkGraphDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4662         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)_res;
4663         FREE((void*)_res);
4664         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
4665 }
4666
4667 void Event_1free(void* ctx_TODO, uint32_t this_ptr) {
4668         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
4669         FREE((void*)this_ptr);
4670         Event_free(this_ptr_conv);
4671 }
4672
4673 uint32_t Event_1clone(void* ctx_TODO, uint32_t orig) {
4674         LDKEvent* orig_conv = (LDKEvent*)orig;
4675         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
4676         *ret_copy = Event_clone(orig_conv);
4677         long ret_ref = (long)ret_copy;
4678         return ret_ref;
4679 }
4680
4681 int8_tArray Event_1write(void* ctx_TODO, uint32_t obj) {
4682         LDKEvent* obj_conv = (LDKEvent*)obj;
4683         LDKCVec_u8Z arg_var = Event_write(obj_conv);
4684         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
4685         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
4686         CVec_u8Z_free(arg_var);
4687         return arg_arr;
4688 }
4689
4690 void MessageSendEvent_1free(void* ctx_TODO, uint32_t this_ptr) {
4691         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
4692         FREE((void*)this_ptr);
4693         MessageSendEvent_free(this_ptr_conv);
4694 }
4695
4696 uint32_t MessageSendEvent_1clone(void* ctx_TODO, uint32_t orig) {
4697         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
4698         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
4699         *ret_copy = MessageSendEvent_clone(orig_conv);
4700         long ret_ref = (long)ret_copy;
4701         return ret_ref;
4702 }
4703
4704 void MessageSendEventsProvider_1free(void* ctx_TODO, uint32_t this_ptr) {
4705         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
4706         FREE((void*)this_ptr);
4707         MessageSendEventsProvider_free(this_ptr_conv);
4708 }
4709
4710 void EventsProvider_1free(void* ctx_TODO, uint32_t this_ptr) {
4711         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
4712         FREE((void*)this_ptr);
4713         EventsProvider_free(this_ptr_conv);
4714 }
4715
4716 void APIError_1free(void* ctx_TODO, uint32_t this_ptr) {
4717         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
4718         FREE((void*)this_ptr);
4719         APIError_free(this_ptr_conv);
4720 }
4721
4722 uint32_t APIError_1clone(void* ctx_TODO, uint32_t orig) {
4723         LDKAPIError* orig_conv = (LDKAPIError*)orig;
4724         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
4725         *ret_copy = APIError_clone(orig_conv);
4726         long ret_ref = (long)ret_copy;
4727         return ret_ref;
4728 }
4729
4730 uint32_t Level_1clone(void* ctx_TODO, uint32_t orig) {
4731         LDKLevel* orig_conv = (LDKLevel*)orig;
4732         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
4733         return ret_conv;
4734 }
4735
4736 uint32_t Level_1max(void* ctx_TODO) {
4737         uint32_t ret_conv = LDKLevel_to_js(Level_max());
4738         return ret_conv;
4739 }
4740
4741 void Logger_1free(void* ctx_TODO, uint32_t this_ptr) {
4742         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
4743         FREE((void*)this_ptr);
4744         Logger_free(this_ptr_conv);
4745 }
4746
4747 void ChannelHandshakeConfig_1free(void* ctx_TODO, uint32_t this_ptr) {
4748         LDKChannelHandshakeConfig this_ptr_conv;
4749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4750         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4751         ChannelHandshakeConfig_free(this_ptr_conv);
4752 }
4753
4754 uint32_t ChannelHandshakeConfig_1clone(void* ctx_TODO, uint32_t orig) {
4755         LDKChannelHandshakeConfig orig_conv;
4756         orig_conv.inner = (void*)(orig & (~1));
4757         orig_conv.is_owned = false;
4758         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
4759         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4760         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4761         long ret_ref = (long)ret_var.inner;
4762         if (ret_var.is_owned) {
4763                 ret_ref |= 1;
4764         }
4765         return ret_ref;
4766 }
4767
4768 int32_t ChannelHandshakeConfig_1get_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr) {
4769         LDKChannelHandshakeConfig this_ptr_conv;
4770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4771         this_ptr_conv.is_owned = false;
4772         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
4773         return ret_val;
4774 }
4775
4776 void ChannelHandshakeConfig_1set_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
4777         LDKChannelHandshakeConfig this_ptr_conv;
4778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4779         this_ptr_conv.is_owned = false;
4780         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
4781 }
4782
4783 jshort ChannelHandshakeConfig_1get_1our_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr) {
4784         LDKChannelHandshakeConfig this_ptr_conv;
4785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4786         this_ptr_conv.is_owned = false;
4787         jshort ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
4788         return ret_val;
4789 }
4790
4791 void ChannelHandshakeConfig_1set_1our_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
4792         LDKChannelHandshakeConfig this_ptr_conv;
4793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4794         this_ptr_conv.is_owned = false;
4795         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
4796 }
4797
4798 int64_t ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
4799         LDKChannelHandshakeConfig this_ptr_conv;
4800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4801         this_ptr_conv.is_owned = false;
4802         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
4803         return ret_val;
4804 }
4805
4806 void ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
4807         LDKChannelHandshakeConfig this_ptr_conv;
4808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4809         this_ptr_conv.is_owned = false;
4810         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
4811 }
4812
4813 uint32_t ChannelHandshakeConfig_1new(void* ctx_TODO, int32_t minimum_depth_arg, jshort our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
4814         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
4815         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4816         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4817         long ret_ref = (long)ret_var.inner;
4818         if (ret_var.is_owned) {
4819                 ret_ref |= 1;
4820         }
4821         return ret_ref;
4822 }
4823
4824 uint32_t ChannelHandshakeConfig_1default(void* ctx_TODO) {
4825         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
4826         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4827         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4828         long ret_ref = (long)ret_var.inner;
4829         if (ret_var.is_owned) {
4830                 ret_ref |= 1;
4831         }
4832         return ret_ref;
4833 }
4834
4835 void ChannelHandshakeLimits_1free(void* ctx_TODO, uint32_t this_ptr) {
4836         LDKChannelHandshakeLimits this_ptr_conv;
4837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4838         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
4839         ChannelHandshakeLimits_free(this_ptr_conv);
4840 }
4841
4842 uint32_t ChannelHandshakeLimits_1clone(void* ctx_TODO, uint32_t orig) {
4843         LDKChannelHandshakeLimits orig_conv;
4844         orig_conv.inner = (void*)(orig & (~1));
4845         orig_conv.is_owned = false;
4846         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
4847         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4848         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4849         long ret_ref = (long)ret_var.inner;
4850         if (ret_var.is_owned) {
4851                 ret_ref |= 1;
4852         }
4853         return ret_ref;
4854 }
4855
4856 int64_t ChannelHandshakeLimits_1get_1min_1funding_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
4857         LDKChannelHandshakeLimits this_ptr_conv;
4858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4859         this_ptr_conv.is_owned = false;
4860         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
4861         return ret_val;
4862 }
4863
4864 void ChannelHandshakeLimits_1set_1min_1funding_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
4865         LDKChannelHandshakeLimits this_ptr_conv;
4866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4867         this_ptr_conv.is_owned = false;
4868         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
4869 }
4870
4871 int64_t ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
4872         LDKChannelHandshakeLimits this_ptr_conv;
4873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4874         this_ptr_conv.is_owned = false;
4875         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
4876         return ret_val;
4877 }
4878
4879 void ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
4880         LDKChannelHandshakeLimits this_ptr_conv;
4881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4882         this_ptr_conv.is_owned = false;
4883         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
4884 }
4885
4886 int64_t ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr) {
4887         LDKChannelHandshakeLimits this_ptr_conv;
4888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4889         this_ptr_conv.is_owned = false;
4890         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
4891         return ret_val;
4892 }
4893
4894 void ChannelHandshakeLimits_1set_1min_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
4895         LDKChannelHandshakeLimits this_ptr_conv;
4896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4897         this_ptr_conv.is_owned = false;
4898         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
4899 }
4900
4901 int64_t ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
4902         LDKChannelHandshakeLimits this_ptr_conv;
4903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4904         this_ptr_conv.is_owned = false;
4905         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
4906         return ret_val;
4907 }
4908
4909 void ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
4910         LDKChannelHandshakeLimits this_ptr_conv;
4911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4912         this_ptr_conv.is_owned = false;
4913         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
4914 }
4915
4916 jshort ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr) {
4917         LDKChannelHandshakeLimits this_ptr_conv;
4918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4919         this_ptr_conv.is_owned = false;
4920         jshort ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
4921         return ret_val;
4922 }
4923
4924 void ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr, jshort val) {
4925         LDKChannelHandshakeLimits this_ptr_conv;
4926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4927         this_ptr_conv.is_owned = false;
4928         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
4929 }
4930
4931 int64_t ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
4932         LDKChannelHandshakeLimits this_ptr_conv;
4933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4934         this_ptr_conv.is_owned = false;
4935         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
4936         return ret_val;
4937 }
4938
4939 void ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
4940         LDKChannelHandshakeLimits this_ptr_conv;
4941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4942         this_ptr_conv.is_owned = false;
4943         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
4944 }
4945
4946 int64_t ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
4947         LDKChannelHandshakeLimits this_ptr_conv;
4948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4949         this_ptr_conv.is_owned = false;
4950         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
4951         return ret_val;
4952 }
4953
4954 void ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
4955         LDKChannelHandshakeLimits this_ptr_conv;
4956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4957         this_ptr_conv.is_owned = false;
4958         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
4959 }
4960
4961 int32_t ChannelHandshakeLimits_1get_1max_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr) {
4962         LDKChannelHandshakeLimits this_ptr_conv;
4963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4964         this_ptr_conv.is_owned = false;
4965         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
4966         return ret_val;
4967 }
4968
4969 void ChannelHandshakeLimits_1set_1max_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
4970         LDKChannelHandshakeLimits this_ptr_conv;
4971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4972         this_ptr_conv.is_owned = false;
4973         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
4974 }
4975
4976 jboolean ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(void* ctx_TODO, uint32_t this_ptr) {
4977         LDKChannelHandshakeLimits this_ptr_conv;
4978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4979         this_ptr_conv.is_owned = false;
4980         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
4981         return ret_val;
4982 }
4983
4984 void ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
4985         LDKChannelHandshakeLimits this_ptr_conv;
4986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4987         this_ptr_conv.is_owned = false;
4988         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
4989 }
4990
4991 jshort ChannelHandshakeLimits_1get_1their_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr) {
4992         LDKChannelHandshakeLimits this_ptr_conv;
4993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
4994         this_ptr_conv.is_owned = false;
4995         jshort ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
4996         return ret_val;
4997 }
4998
4999 void ChannelHandshakeLimits_1set_1their_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
5000         LDKChannelHandshakeLimits this_ptr_conv;
5001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5002         this_ptr_conv.is_owned = false;
5003         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
5004 }
5005
5006 uint32_t ChannelHandshakeLimits_1new(void* ctx_TODO, 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, jshort 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, jshort their_to_self_delay_arg) {
5007         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);
5008         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5009         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5010         long ret_ref = (long)ret_var.inner;
5011         if (ret_var.is_owned) {
5012                 ret_ref |= 1;
5013         }
5014         return ret_ref;
5015 }
5016
5017 uint32_t ChannelHandshakeLimits_1default(void* ctx_TODO) {
5018         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
5019         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5020         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5021         long ret_ref = (long)ret_var.inner;
5022         if (ret_var.is_owned) {
5023                 ret_ref |= 1;
5024         }
5025         return ret_ref;
5026 }
5027
5028 void ChannelConfig_1free(void* ctx_TODO, uint32_t this_ptr) {
5029         LDKChannelConfig this_ptr_conv;
5030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5031         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5032         ChannelConfig_free(this_ptr_conv);
5033 }
5034
5035 uint32_t ChannelConfig_1clone(void* ctx_TODO, uint32_t orig) {
5036         LDKChannelConfig orig_conv;
5037         orig_conv.inner = (void*)(orig & (~1));
5038         orig_conv.is_owned = false;
5039         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
5040         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5041         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5042         long ret_ref = (long)ret_var.inner;
5043         if (ret_var.is_owned) {
5044                 ret_ref |= 1;
5045         }
5046         return ret_ref;
5047 }
5048
5049 int32_t ChannelConfig_1get_1fee_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr) {
5050         LDKChannelConfig this_ptr_conv;
5051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5052         this_ptr_conv.is_owned = false;
5053         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
5054         return ret_val;
5055 }
5056
5057 void ChannelConfig_1set_1fee_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
5058         LDKChannelConfig this_ptr_conv;
5059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5060         this_ptr_conv.is_owned = false;
5061         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
5062 }
5063
5064 jboolean ChannelConfig_1get_1announced_1channel(void* ctx_TODO, uint32_t this_ptr) {
5065         LDKChannelConfig this_ptr_conv;
5066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5067         this_ptr_conv.is_owned = false;
5068         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
5069         return ret_val;
5070 }
5071
5072 void ChannelConfig_1set_1announced_1channel(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
5073         LDKChannelConfig this_ptr_conv;
5074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5075         this_ptr_conv.is_owned = false;
5076         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
5077 }
5078
5079 jboolean ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
5080         LDKChannelConfig this_ptr_conv;
5081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5082         this_ptr_conv.is_owned = false;
5083         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
5084         return ret_val;
5085 }
5086
5087 void ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
5088         LDKChannelConfig this_ptr_conv;
5089         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5090         this_ptr_conv.is_owned = false;
5091         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
5092 }
5093
5094 uint32_t ChannelConfig_1new(void* ctx_TODO, int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
5095         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
5096         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5097         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5098         long ret_ref = (long)ret_var.inner;
5099         if (ret_var.is_owned) {
5100                 ret_ref |= 1;
5101         }
5102         return ret_ref;
5103 }
5104
5105 uint32_t ChannelConfig_1default(void* ctx_TODO) {
5106         LDKChannelConfig ret_var = ChannelConfig_default();
5107         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5108         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5109         long ret_ref = (long)ret_var.inner;
5110         if (ret_var.is_owned) {
5111                 ret_ref |= 1;
5112         }
5113         return ret_ref;
5114 }
5115
5116 int8_tArray ChannelConfig_1write(void* ctx_TODO, uint32_t obj) {
5117         LDKChannelConfig obj_conv;
5118         obj_conv.inner = (void*)(obj & (~1));
5119         obj_conv.is_owned = false;
5120         LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
5121         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
5122         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
5123         CVec_u8Z_free(arg_var);
5124         return arg_arr;
5125 }
5126
5127 uint32_t ChannelConfig_1read(void* ctx_TODO, int8_tArray ser) {
5128         LDKu8slice ser_ref;
5129         ser_ref.datalen = ser.len;
5130         ser_ref.data = ser.ptr;
5131         LDKChannelConfig ret_var = ChannelConfig_read(ser_ref);
5132         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5133         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5134         long ret_ref = (long)ret_var.inner;
5135         if (ret_var.is_owned) {
5136                 ret_ref |= 1;
5137         }
5138         return ret_ref;
5139 }
5140
5141 void UserConfig_1free(void* ctx_TODO, uint32_t this_ptr) {
5142         LDKUserConfig this_ptr_conv;
5143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5144         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5145         UserConfig_free(this_ptr_conv);
5146 }
5147
5148 uint32_t UserConfig_1clone(void* ctx_TODO, uint32_t orig) {
5149         LDKUserConfig orig_conv;
5150         orig_conv.inner = (void*)(orig & (~1));
5151         orig_conv.is_owned = false;
5152         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
5153         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5154         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5155         long ret_ref = (long)ret_var.inner;
5156         if (ret_var.is_owned) {
5157                 ret_ref |= 1;
5158         }
5159         return ret_ref;
5160 }
5161
5162 uint32_t UserConfig_1get_1own_1channel_1config(void* ctx_TODO, uint32_t this_ptr) {
5163         LDKUserConfig this_ptr_conv;
5164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5165         this_ptr_conv.is_owned = false;
5166         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
5167         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5168         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5169         long ret_ref = (long)ret_var.inner;
5170         if (ret_var.is_owned) {
5171                 ret_ref |= 1;
5172         }
5173         return ret_ref;
5174 }
5175
5176 void UserConfig_1set_1own_1channel_1config(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
5177         LDKUserConfig this_ptr_conv;
5178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5179         this_ptr_conv.is_owned = false;
5180         LDKChannelHandshakeConfig val_conv;
5181         val_conv.inner = (void*)(val & (~1));
5182         val_conv.is_owned = (val & 1) || (val == 0);
5183         if (val_conv.inner != NULL)
5184                 val_conv = ChannelHandshakeConfig_clone(&val_conv);
5185         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
5186 }
5187
5188 uint32_t UserConfig_1get_1peer_1channel_1config_1limits(void* ctx_TODO, uint32_t this_ptr) {
5189         LDKUserConfig this_ptr_conv;
5190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5191         this_ptr_conv.is_owned = false;
5192         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
5193         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5194         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5195         long ret_ref = (long)ret_var.inner;
5196         if (ret_var.is_owned) {
5197                 ret_ref |= 1;
5198         }
5199         return ret_ref;
5200 }
5201
5202 void UserConfig_1set_1peer_1channel_1config_1limits(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
5203         LDKUserConfig this_ptr_conv;
5204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5205         this_ptr_conv.is_owned = false;
5206         LDKChannelHandshakeLimits val_conv;
5207         val_conv.inner = (void*)(val & (~1));
5208         val_conv.is_owned = (val & 1) || (val == 0);
5209         if (val_conv.inner != NULL)
5210                 val_conv = ChannelHandshakeLimits_clone(&val_conv);
5211         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
5212 }
5213
5214 uint32_t UserConfig_1get_1channel_1options(void* ctx_TODO, uint32_t this_ptr) {
5215         LDKUserConfig this_ptr_conv;
5216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5217         this_ptr_conv.is_owned = false;
5218         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
5219         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5220         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5221         long ret_ref = (long)ret_var.inner;
5222         if (ret_var.is_owned) {
5223                 ret_ref |= 1;
5224         }
5225         return ret_ref;
5226 }
5227
5228 void UserConfig_1set_1channel_1options(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
5229         LDKUserConfig this_ptr_conv;
5230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5231         this_ptr_conv.is_owned = false;
5232         LDKChannelConfig val_conv;
5233         val_conv.inner = (void*)(val & (~1));
5234         val_conv.is_owned = (val & 1) || (val == 0);
5235         if (val_conv.inner != NULL)
5236                 val_conv = ChannelConfig_clone(&val_conv);
5237         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
5238 }
5239
5240 uint32_t UserConfig_1new(void* ctx_TODO, uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg) {
5241         LDKChannelHandshakeConfig own_channel_config_arg_conv;
5242         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
5243         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
5244         if (own_channel_config_arg_conv.inner != NULL)
5245                 own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
5246         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
5247         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
5248         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
5249         if (peer_channel_config_limits_arg_conv.inner != NULL)
5250                 peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
5251         LDKChannelConfig channel_options_arg_conv;
5252         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
5253         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
5254         if (channel_options_arg_conv.inner != NULL)
5255                 channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
5256         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
5257         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5258         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5259         long ret_ref = (long)ret_var.inner;
5260         if (ret_var.is_owned) {
5261                 ret_ref |= 1;
5262         }
5263         return ret_ref;
5264 }
5265
5266 uint32_t UserConfig_1default(void* ctx_TODO) {
5267         LDKUserConfig ret_var = UserConfig_default();
5268         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5269         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5270         long ret_ref = (long)ret_var.inner;
5271         if (ret_var.is_owned) {
5272                 ret_ref |= 1;
5273         }
5274         return ret_ref;
5275 }
5276
5277 uint32_t AccessError_1clone(void* ctx_TODO, uint32_t orig) {
5278         LDKAccessError* orig_conv = (LDKAccessError*)orig;
5279         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
5280         return ret_conv;
5281 }
5282
5283 void Access_1free(void* ctx_TODO, uint32_t this_ptr) {
5284         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
5285         FREE((void*)this_ptr);
5286         Access_free(this_ptr_conv);
5287 }
5288
5289 void Watch_1free(void* ctx_TODO, uint32_t this_ptr) {
5290         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
5291         FREE((void*)this_ptr);
5292         Watch_free(this_ptr_conv);
5293 }
5294
5295 void Filter_1free(void* ctx_TODO, uint32_t this_ptr) {
5296         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
5297         FREE((void*)this_ptr);
5298         Filter_free(this_ptr_conv);
5299 }
5300
5301 void BroadcasterInterface_1free(void* ctx_TODO, uint32_t this_ptr) {
5302         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
5303         FREE((void*)this_ptr);
5304         BroadcasterInterface_free(this_ptr_conv);
5305 }
5306
5307 uint32_t ConfirmationTarget_1clone(void* ctx_TODO, uint32_t orig) {
5308         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)orig;
5309         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
5310         return ret_conv;
5311 }
5312
5313 void FeeEstimator_1free(void* ctx_TODO, uint32_t this_ptr) {
5314         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
5315         FREE((void*)this_ptr);
5316         FeeEstimator_free(this_ptr_conv);
5317 }
5318
5319 void ChainMonitor_1free(void* ctx_TODO, uint32_t this_ptr) {
5320         LDKChainMonitor this_ptr_conv;
5321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5322         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5323         ChainMonitor_free(this_ptr_conv);
5324 }
5325
5326 void ChainMonitor_1block_1connected(void* ctx_TODO, uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5327         LDKChainMonitor this_arg_conv;
5328         this_arg_conv.inner = (void*)(this_arg & (~1));
5329         this_arg_conv.is_owned = false;
5330         unsigned char header_arr[80];
5331         CHECK(header.len == 80);
5332         memcpy(header_arr, header.ptr, 80);
5333         unsigned char (*header_ref)[80] = &header_arr;
5334         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5335         txdata_constr.datalen = txdata.len;
5336         if (txdata_constr.datalen > 0)
5337                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5338         else
5339                 txdata_constr.data = NULL;
5340         uint32_t* txdata_vals = (uint32_t*) txdata.ptr;
5341         for (size_t y = 0; y < txdata_constr.datalen; y++) {
5342                 uint32_t arr_conv_24 = txdata_vals[y];
5343                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_24;
5344                 FREE((void*)arr_conv_24);
5345                 txdata_constr.data[y] = arr_conv_24_conv;
5346         }
5347         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
5348 }
5349
5350 void ChainMonitor_1block_1disconnected(void* ctx_TODO, uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
5351         LDKChainMonitor this_arg_conv;
5352         this_arg_conv.inner = (void*)(this_arg & (~1));
5353         this_arg_conv.is_owned = false;
5354         unsigned char header_arr[80];
5355         CHECK(header.len == 80);
5356         memcpy(header_arr, header.ptr, 80);
5357         unsigned char (*header_ref)[80] = &header_arr;
5358         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
5359 }
5360
5361 uint32_t ChainMonitor_1new(void* ctx_TODO, uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
5362         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
5363         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5364         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5365                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5366                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5367         }
5368         LDKLogger logger_conv = *(LDKLogger*)logger;
5369         if (logger_conv.free == LDKLogger_JCalls_free) {
5370                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5371                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5372         }
5373         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
5374         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
5375                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5376                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
5377         }
5378         LDKPersist persister_conv = *(LDKPersist*)persister;
5379         if (persister_conv.free == LDKPersist_JCalls_free) {
5380                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5381                 LDKPersist_JCalls_clone(persister_conv.this_arg);
5382         }
5383         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
5384         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5385         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5386         long ret_ref = (long)ret_var.inner;
5387         if (ret_var.is_owned) {
5388                 ret_ref |= 1;
5389         }
5390         return ret_ref;
5391 }
5392
5393 uint32_t ChainMonitor_1as_1Watch(void* ctx_TODO, uint32_t this_arg) {
5394         LDKChainMonitor this_arg_conv;
5395         this_arg_conv.inner = (void*)(this_arg & (~1));
5396         this_arg_conv.is_owned = false;
5397         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
5398         *ret = ChainMonitor_as_Watch(&this_arg_conv);
5399         return (long)ret;
5400 }
5401
5402 uint32_t ChainMonitor_1as_1EventsProvider(void* ctx_TODO, uint32_t this_arg) {
5403         LDKChainMonitor this_arg_conv;
5404         this_arg_conv.inner = (void*)(this_arg & (~1));
5405         this_arg_conv.is_owned = false;
5406         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
5407         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
5408         return (long)ret;
5409 }
5410
5411 void ChannelMonitorUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
5412         LDKChannelMonitorUpdate this_ptr_conv;
5413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5414         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5415         ChannelMonitorUpdate_free(this_ptr_conv);
5416 }
5417
5418 uint32_t ChannelMonitorUpdate_1clone(void* ctx_TODO, uint32_t orig) {
5419         LDKChannelMonitorUpdate orig_conv;
5420         orig_conv.inner = (void*)(orig & (~1));
5421         orig_conv.is_owned = false;
5422         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
5423         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5424         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5425         long ret_ref = (long)ret_var.inner;
5426         if (ret_var.is_owned) {
5427                 ret_ref |= 1;
5428         }
5429         return ret_ref;
5430 }
5431
5432 int64_t ChannelMonitorUpdate_1get_1update_1id(void* ctx_TODO, uint32_t this_ptr) {
5433         LDKChannelMonitorUpdate this_ptr_conv;
5434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5435         this_ptr_conv.is_owned = false;
5436         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
5437         return ret_val;
5438 }
5439
5440 void ChannelMonitorUpdate_1set_1update_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
5441         LDKChannelMonitorUpdate this_ptr_conv;
5442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5443         this_ptr_conv.is_owned = false;
5444         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
5445 }
5446
5447 int8_tArray ChannelMonitorUpdate_1write(void* ctx_TODO, uint32_t obj) {
5448         LDKChannelMonitorUpdate obj_conv;
5449         obj_conv.inner = (void*)(obj & (~1));
5450         obj_conv.is_owned = false;
5451         LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
5452         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
5453         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
5454         CVec_u8Z_free(arg_var);
5455         return arg_arr;
5456 }
5457
5458 uint32_t ChannelMonitorUpdate_1read(void* ctx_TODO, int8_tArray ser) {
5459         LDKu8slice ser_ref;
5460         ser_ref.datalen = ser.len;
5461         ser_ref.data = ser.ptr;
5462         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
5463         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
5464         return (long)ret_conv;
5465 }
5466
5467 uint32_t ChannelMonitorUpdateErr_1clone(void* ctx_TODO, uint32_t orig) {
5468         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)orig;
5469         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
5470         return ret_conv;
5471 }
5472
5473 void MonitorUpdateError_1free(void* ctx_TODO, uint32_t this_ptr) {
5474         LDKMonitorUpdateError this_ptr_conv;
5475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5476         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5477         MonitorUpdateError_free(this_ptr_conv);
5478 }
5479
5480 void MonitorEvent_1free(void* ctx_TODO, uint32_t this_ptr) {
5481         LDKMonitorEvent this_ptr_conv;
5482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5483         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5484         MonitorEvent_free(this_ptr_conv);
5485 }
5486
5487 uint32_t MonitorEvent_1clone(void* ctx_TODO, uint32_t orig) {
5488         LDKMonitorEvent orig_conv;
5489         orig_conv.inner = (void*)(orig & (~1));
5490         orig_conv.is_owned = false;
5491         LDKMonitorEvent ret_var = MonitorEvent_clone(&orig_conv);
5492         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5493         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5494         long ret_ref = (long)ret_var.inner;
5495         if (ret_var.is_owned) {
5496                 ret_ref |= 1;
5497         }
5498         return ret_ref;
5499 }
5500
5501 void HTLCUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
5502         LDKHTLCUpdate this_ptr_conv;
5503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5504         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5505         HTLCUpdate_free(this_ptr_conv);
5506 }
5507
5508 uint32_t HTLCUpdate_1clone(void* ctx_TODO, uint32_t orig) {
5509         LDKHTLCUpdate orig_conv;
5510         orig_conv.inner = (void*)(orig & (~1));
5511         orig_conv.is_owned = false;
5512         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
5513         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5514         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5515         long ret_ref = (long)ret_var.inner;
5516         if (ret_var.is_owned) {
5517                 ret_ref |= 1;
5518         }
5519         return ret_ref;
5520 }
5521
5522 int8_tArray HTLCUpdate_1write(void* ctx_TODO, uint32_t obj) {
5523         LDKHTLCUpdate obj_conv;
5524         obj_conv.inner = (void*)(obj & (~1));
5525         obj_conv.is_owned = false;
5526         LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
5527         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
5528         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
5529         CVec_u8Z_free(arg_var);
5530         return arg_arr;
5531 }
5532
5533 uint32_t HTLCUpdate_1read(void* ctx_TODO, int8_tArray ser) {
5534         LDKu8slice ser_ref;
5535         ser_ref.datalen = ser.len;
5536         ser_ref.data = ser.ptr;
5537         LDKHTLCUpdate ret_var = HTLCUpdate_read(ser_ref);
5538         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5539         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5540         long ret_ref = (long)ret_var.inner;
5541         if (ret_var.is_owned) {
5542                 ret_ref |= 1;
5543         }
5544         return ret_ref;
5545 }
5546
5547 void ChannelMonitor_1free(void* ctx_TODO, uint32_t this_ptr) {
5548         LDKChannelMonitor this_ptr_conv;
5549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5550         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5551         ChannelMonitor_free(this_ptr_conv);
5552 }
5553
5554 int8_tArray ChannelMonitor_1write(void* ctx_TODO, uint32_t obj) {
5555         LDKChannelMonitor obj_conv;
5556         obj_conv.inner = (void*)(obj & (~1));
5557         obj_conv.is_owned = false;
5558         LDKCVec_u8Z arg_var = ChannelMonitor_write(&obj_conv);
5559         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
5560         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
5561         CVec_u8Z_free(arg_var);
5562         return arg_arr;
5563 }
5564
5565 uint32_t ChannelMonitor_1update_1monitor(void* ctx_TODO, uint32_t this_arg, uint32_t updates, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
5566         LDKChannelMonitor this_arg_conv;
5567         this_arg_conv.inner = (void*)(this_arg & (~1));
5568         this_arg_conv.is_owned = false;
5569         LDKChannelMonitorUpdate updates_conv;
5570         updates_conv.inner = (void*)(updates & (~1));
5571         updates_conv.is_owned = false;
5572         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
5573         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator;
5574         LDKLogger* logger_conv = (LDKLogger*)logger;
5575         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
5576         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
5577         return (long)ret_conv;
5578 }
5579
5580 int64_t ChannelMonitor_1get_1latest_1update_1id(void* ctx_TODO, uint32_t this_arg) {
5581         LDKChannelMonitor this_arg_conv;
5582         this_arg_conv.inner = (void*)(this_arg & (~1));
5583         this_arg_conv.is_owned = false;
5584         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
5585         return ret_val;
5586 }
5587
5588 uint32_t ChannelMonitor_1get_1funding_1txo(void* ctx_TODO, uint32_t this_arg) {
5589         LDKChannelMonitor this_arg_conv;
5590         this_arg_conv.inner = (void*)(this_arg & (~1));
5591         this_arg_conv.is_owned = false;
5592         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
5593         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
5594         ret_ref->a = OutPoint_clone(&ret_ref->a);
5595         ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
5596         return (long)ret_ref;
5597 }
5598
5599 uint32_tArray ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(void* ctx_TODO, uint32_t this_arg) {
5600         LDKChannelMonitor this_arg_conv;
5601         this_arg_conv.inner = (void*)(this_arg & (~1));
5602         this_arg_conv.is_owned = false;
5603         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
5604         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
5605         uint32_t *ret_arr_ptr = ret_arr.ptr;
5606         for (size_t o = 0; o < ret_var.datalen; o++) {
5607                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
5608                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5609                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5610                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
5611                 if (arr_conv_14_var.is_owned) {
5612                         arr_conv_14_ref |= 1;
5613                 }
5614                 ret_arr_ptr[o] = arr_conv_14_ref;
5615         }
5616         FREE(ret_var.data);
5617         return ret_arr;
5618 }
5619
5620 uint32_tArray ChannelMonitor_1get_1and_1clear_1pending_1events(void* ctx_TODO, uint32_t this_arg) {
5621         LDKChannelMonitor this_arg_conv;
5622         this_arg_conv.inner = (void*)(this_arg & (~1));
5623         this_arg_conv.is_owned = false;
5624         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
5625         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
5626         uint32_t *ret_arr_ptr = ret_arr.ptr;
5627         for (size_t h = 0; h < ret_var.datalen; h++) {
5628                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
5629                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
5630                 long arr_conv_7_ref = (long)arr_conv_7_copy;
5631                 ret_arr_ptr[h] = arr_conv_7_ref;
5632         }
5633         FREE(ret_var.data);
5634         return ret_arr;
5635 }
5636
5637 uint32_tArray ChannelMonitor_1get_1latest_1holder_1commitment_1txn(void* ctx_TODO, uint32_t this_arg, uint32_t logger) {
5638         LDKChannelMonitor this_arg_conv;
5639         this_arg_conv.inner = (void*)(this_arg & (~1));
5640         this_arg_conv.is_owned = false;
5641         LDKLogger* logger_conv = (LDKLogger*)logger;
5642         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
5643         uint32_tArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5644         for (size_t i = 0; i < ret_var.datalen; i++) {
5645                 LDKTransaction arr_conv_8_var = ret_var.data[i];
5646                 int8_tArray arr_conv_8_arr = { .len = arr_conv_8_var.datalen, .ptr = MALLOC(arr_conv_8_var.datalen, "Native int8_tArray Bytes") };
5647                 memcpy(arr_conv_8_arr.ptr, arr_conv_8_var.data, arr_conv_8_var.datalen);
5648                 Transaction_free(arr_conv_8_var);
5649                 (*env)->SetObjectArrayElement(env, ret_arr, i, arr_conv_8_arr);
5650         }
5651         FREE(ret_var.data);
5652         return ret_arr;
5653 }
5654
5655 uint32_tArray ChannelMonitor_1block_1connected(void* ctx_TODO, uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
5656         LDKChannelMonitor this_arg_conv;
5657         this_arg_conv.inner = (void*)(this_arg & (~1));
5658         this_arg_conv.is_owned = false;
5659         unsigned char header_arr[80];
5660         CHECK(header.len == 80);
5661         memcpy(header_arr, header.ptr, 80);
5662         unsigned char (*header_ref)[80] = &header_arr;
5663         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5664         txdata_constr.datalen = txdata.len;
5665         if (txdata_constr.datalen > 0)
5666                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5667         else
5668                 txdata_constr.data = NULL;
5669         uint32_t* txdata_vals = (uint32_t*) txdata.ptr;
5670         for (size_t y = 0; y < txdata_constr.datalen; y++) {
5671                 uint32_t arr_conv_24 = txdata_vals[y];
5672                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_24;
5673                 FREE((void*)arr_conv_24);
5674                 txdata_constr.data[y] = arr_conv_24_conv;
5675         }
5676         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5677         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5679                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5680         }
5681         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5682         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5683                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5684                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5685         }
5686         LDKLogger logger_conv = *(LDKLogger*)logger;
5687         if (logger_conv.free == LDKLogger_JCalls_free) {
5688                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5689                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5690         }
5691         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);
5692         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
5693         uint32_t *ret_arr_ptr = ret_arr.ptr;
5694         for (size_t u = 0; u < ret_var.datalen; u++) {
5695                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arr_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
5696                 *arr_conv_46_ref = ret_var.data[u];
5697                 arr_conv_46_ref->a = ThirtyTwoBytes_clone(&arr_conv_46_ref->a);
5698                 // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Integer, TxOut>[]
5699                 ret_arr_ptr[u] = (long)arr_conv_46_ref;
5700         }
5701         FREE(ret_var.data);
5702         return ret_arr;
5703 }
5704
5705 void ChannelMonitor_1block_1disconnected(void* ctx_TODO, uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
5706         LDKChannelMonitor this_arg_conv;
5707         this_arg_conv.inner = (void*)(this_arg & (~1));
5708         this_arg_conv.is_owned = false;
5709         unsigned char header_arr[80];
5710         CHECK(header.len == 80);
5711         memcpy(header_arr, header.ptr, 80);
5712         unsigned char (*header_ref)[80] = &header_arr;
5713         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5714         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5715                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5716                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5717         }
5718         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
5719         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
5720                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5721                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
5722         }
5723         LDKLogger logger_conv = *(LDKLogger*)logger;
5724         if (logger_conv.free == LDKLogger_JCalls_free) {
5725                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5726                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5727         }
5728         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
5729 }
5730
5731 void Persist_1free(void* ctx_TODO, uint32_t this_ptr) {
5732         LDKPersist this_ptr_conv = *(LDKPersist*)this_ptr;
5733         FREE((void*)this_ptr);
5734         Persist_free(this_ptr_conv);
5735 }
5736
5737 uint32_t C2Tuple_1BlockHashChannelMonitorZ_1read(void* ctx_TODO, int8_tArray ser, uint32_t arg) {
5738         LDKu8slice ser_ref;
5739         ser_ref.datalen = ser.len;
5740         ser_ref.data = ser.ptr;
5741         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
5742         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
5743         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
5744         return (long)ret_conv;
5745 }
5746
5747 void OutPoint_1free(void* ctx_TODO, uint32_t this_ptr) {
5748         LDKOutPoint this_ptr_conv;
5749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5750         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5751         OutPoint_free(this_ptr_conv);
5752 }
5753
5754 uint32_t OutPoint_1clone(void* ctx_TODO, uint32_t orig) {
5755         LDKOutPoint orig_conv;
5756         orig_conv.inner = (void*)(orig & (~1));
5757         orig_conv.is_owned = false;
5758         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
5759         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5760         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5761         long ret_ref = (long)ret_var.inner;
5762         if (ret_var.is_owned) {
5763                 ret_ref |= 1;
5764         }
5765         return ret_ref;
5766 }
5767
5768 int8_tArray OutPoint_1get_1txid(void* ctx_TODO, uint32_t this_ptr) {
5769         LDKOutPoint this_ptr_conv;
5770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5771         this_ptr_conv.is_owned = false;
5772         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
5773         memcpy(ret_arr.ptr, *OutPoint_get_txid(&this_ptr_conv), 32);
5774         return ret_arr;
5775 }
5776
5777 void OutPoint_1set_1txid(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
5778         LDKOutPoint this_ptr_conv;
5779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5780         this_ptr_conv.is_owned = false;
5781         LDKThirtyTwoBytes val_ref;
5782         CHECK(val.len == 32);
5783         memcpy(val_ref.data, val.ptr, 32);
5784         OutPoint_set_txid(&this_ptr_conv, val_ref);
5785 }
5786
5787 jshort OutPoint_1get_1index(void* ctx_TODO, uint32_t this_ptr) {
5788         LDKOutPoint this_ptr_conv;
5789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5790         this_ptr_conv.is_owned = false;
5791         jshort ret_val = OutPoint_get_index(&this_ptr_conv);
5792         return ret_val;
5793 }
5794
5795 void OutPoint_1set_1index(void* ctx_TODO, uint32_t this_ptr, jshort val) {
5796         LDKOutPoint this_ptr_conv;
5797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5798         this_ptr_conv.is_owned = false;
5799         OutPoint_set_index(&this_ptr_conv, val);
5800 }
5801
5802 uint32_t OutPoint_1new(void* ctx_TODO, int8_tArray txid_arg, jshort index_arg) {
5803         LDKThirtyTwoBytes txid_arg_ref;
5804         CHECK(txid_arg.len == 32);
5805         memcpy(txid_arg_ref.data, txid_arg.ptr, 32);
5806         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
5807         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5808         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5809         long ret_ref = (long)ret_var.inner;
5810         if (ret_var.is_owned) {
5811                 ret_ref |= 1;
5812         }
5813         return ret_ref;
5814 }
5815
5816 int8_tArray OutPoint_1to_1channel_1id(void* ctx_TODO, uint32_t this_arg) {
5817         LDKOutPoint this_arg_conv;
5818         this_arg_conv.inner = (void*)(this_arg & (~1));
5819         this_arg_conv.is_owned = false;
5820         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
5821         memcpy(arg_arr.ptr, OutPoint_to_channel_id(&this_arg_conv).data, 32);
5822         return arg_arr;
5823 }
5824
5825 int8_tArray OutPoint_1write(void* ctx_TODO, uint32_t obj) {
5826         LDKOutPoint obj_conv;
5827         obj_conv.inner = (void*)(obj & (~1));
5828         obj_conv.is_owned = false;
5829         LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
5830         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
5831         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
5832         CVec_u8Z_free(arg_var);
5833         return arg_arr;
5834 }
5835
5836 uint32_t OutPoint_1read(void* ctx_TODO, int8_tArray ser) {
5837         LDKu8slice ser_ref;
5838         ser_ref.datalen = ser.len;
5839         ser_ref.data = ser.ptr;
5840         LDKOutPoint ret_var = OutPoint_read(ser_ref);
5841         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5842         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5843         long ret_ref = (long)ret_var.inner;
5844         if (ret_var.is_owned) {
5845                 ret_ref |= 1;
5846         }
5847         return ret_ref;
5848 }
5849
5850 void SpendableOutputDescriptor_1free(void* ctx_TODO, uint32_t this_ptr) {
5851         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
5852         FREE((void*)this_ptr);
5853         SpendableOutputDescriptor_free(this_ptr_conv);
5854 }
5855
5856 uint32_t SpendableOutputDescriptor_1clone(void* ctx_TODO, uint32_t orig) {
5857         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
5858         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5859         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
5860         long ret_ref = (long)ret_copy;
5861         return ret_ref;
5862 }
5863
5864 int8_tArray SpendableOutputDescriptor_1write(void* ctx_TODO, uint32_t obj) {
5865         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
5866         LDKCVec_u8Z arg_var = SpendableOutputDescriptor_write(obj_conv);
5867         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
5868         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
5869         CVec_u8Z_free(arg_var);
5870         return arg_arr;
5871 }
5872
5873 uint32_t SpendableOutputDescriptor_1read(void* ctx_TODO, int8_tArray ser) {
5874         LDKu8slice ser_ref;
5875         ser_ref.datalen = ser.len;
5876         ser_ref.data = ser.ptr;
5877         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
5878         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
5879         return (long)ret_conv;
5880 }
5881
5882 uint32_t ChannelKeys_1clone(void* ctx_TODO, uint32_t orig) {
5883         LDKChannelKeys* orig_conv = (LDKChannelKeys*)orig;
5884         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
5885         *ret = ChannelKeys_clone(orig_conv);
5886         return (long)ret;
5887 }
5888
5889 void ChannelKeys_1free(void* ctx_TODO, uint32_t this_ptr) {
5890         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
5891         FREE((void*)this_ptr);
5892         ChannelKeys_free(this_ptr_conv);
5893 }
5894
5895 void KeysInterface_1free(void* ctx_TODO, uint32_t this_ptr) {
5896         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
5897         FREE((void*)this_ptr);
5898         KeysInterface_free(this_ptr_conv);
5899 }
5900
5901 void InMemoryChannelKeys_1free(void* ctx_TODO, uint32_t this_ptr) {
5902         LDKInMemoryChannelKeys this_ptr_conv;
5903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5904         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5905         InMemoryChannelKeys_free(this_ptr_conv);
5906 }
5907
5908 uint32_t InMemoryChannelKeys_1clone(void* ctx_TODO, uint32_t orig) {
5909         LDKInMemoryChannelKeys orig_conv;
5910         orig_conv.inner = (void*)(orig & (~1));
5911         orig_conv.is_owned = false;
5912         LDKInMemoryChannelKeys ret_var = InMemoryChannelKeys_clone(&orig_conv);
5913         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5914         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5915         long ret_ref = (long)ret_var.inner;
5916         if (ret_var.is_owned) {
5917                 ret_ref |= 1;
5918         }
5919         return ret_ref;
5920 }
5921
5922 int8_tArray InMemoryChannelKeys_1get_1funding_1key(void* ctx_TODO, uint32_t this_ptr) {
5923         LDKInMemoryChannelKeys this_ptr_conv;
5924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5925         this_ptr_conv.is_owned = false;
5926         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
5927         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv), 32);
5928         return ret_arr;
5929 }
5930
5931 void InMemoryChannelKeys_1set_1funding_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
5932         LDKInMemoryChannelKeys this_ptr_conv;
5933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5934         this_ptr_conv.is_owned = false;
5935         LDKSecretKey val_ref;
5936         CHECK(val.len == 32);
5937         memcpy(val_ref.bytes, val.ptr, 32);
5938         InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
5939 }
5940
5941 int8_tArray InMemoryChannelKeys_1get_1revocation_1base_1key(void* ctx_TODO, uint32_t this_ptr) {
5942         LDKInMemoryChannelKeys this_ptr_conv;
5943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5944         this_ptr_conv.is_owned = false;
5945         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
5946         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv), 32);
5947         return ret_arr;
5948 }
5949
5950 void InMemoryChannelKeys_1set_1revocation_1base_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
5951         LDKInMemoryChannelKeys this_ptr_conv;
5952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5953         this_ptr_conv.is_owned = false;
5954         LDKSecretKey val_ref;
5955         CHECK(val.len == 32);
5956         memcpy(val_ref.bytes, val.ptr, 32);
5957         InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
5958 }
5959
5960 int8_tArray InMemoryChannelKeys_1get_1payment_1key(void* ctx_TODO, uint32_t this_ptr) {
5961         LDKInMemoryChannelKeys this_ptr_conv;
5962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5963         this_ptr_conv.is_owned = false;
5964         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
5965         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv), 32);
5966         return ret_arr;
5967 }
5968
5969 void InMemoryChannelKeys_1set_1payment_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
5970         LDKInMemoryChannelKeys this_ptr_conv;
5971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5972         this_ptr_conv.is_owned = false;
5973         LDKSecretKey val_ref;
5974         CHECK(val.len == 32);
5975         memcpy(val_ref.bytes, val.ptr, 32);
5976         InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
5977 }
5978
5979 int8_tArray InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(void* ctx_TODO, uint32_t this_ptr) {
5980         LDKInMemoryChannelKeys this_ptr_conv;
5981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5982         this_ptr_conv.is_owned = false;
5983         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
5984         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv), 32);
5985         return ret_arr;
5986 }
5987
5988 void InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
5989         LDKInMemoryChannelKeys this_ptr_conv;
5990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5991         this_ptr_conv.is_owned = false;
5992         LDKSecretKey val_ref;
5993         CHECK(val.len == 32);
5994         memcpy(val_ref.bytes, val.ptr, 32);
5995         InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
5996 }
5997
5998 int8_tArray InMemoryChannelKeys_1get_1htlc_1base_1key(void* ctx_TODO, uint32_t this_ptr) {
5999         LDKInMemoryChannelKeys this_ptr_conv;
6000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6001         this_ptr_conv.is_owned = false;
6002         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6003         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv), 32);
6004         return ret_arr;
6005 }
6006
6007 void InMemoryChannelKeys_1set_1htlc_1base_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6008         LDKInMemoryChannelKeys this_ptr_conv;
6009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6010         this_ptr_conv.is_owned = false;
6011         LDKSecretKey val_ref;
6012         CHECK(val.len == 32);
6013         memcpy(val_ref.bytes, val.ptr, 32);
6014         InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
6015 }
6016
6017 int8_tArray InMemoryChannelKeys_1get_1commitment_1seed(void* ctx_TODO, uint32_t this_ptr) {
6018         LDKInMemoryChannelKeys this_ptr_conv;
6019         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6020         this_ptr_conv.is_owned = false;
6021         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6022         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv), 32);
6023         return ret_arr;
6024 }
6025
6026 void InMemoryChannelKeys_1set_1commitment_1seed(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6027         LDKInMemoryChannelKeys this_ptr_conv;
6028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6029         this_ptr_conv.is_owned = false;
6030         LDKThirtyTwoBytes val_ref;
6031         CHECK(val.len == 32);
6032         memcpy(val_ref.data, val.ptr, 32);
6033         InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
6034 }
6035
6036 uint32_t InMemoryChannelKeys_1new(void* ctx_TODO, 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) {
6037         LDKSecretKey funding_key_ref;
6038         CHECK(funding_key.len == 32);
6039         memcpy(funding_key_ref.bytes, funding_key.ptr, 32);
6040         LDKSecretKey revocation_base_key_ref;
6041         CHECK(revocation_base_key.len == 32);
6042         memcpy(revocation_base_key_ref.bytes, revocation_base_key.ptr, 32);
6043         LDKSecretKey payment_key_ref;
6044         CHECK(payment_key.len == 32);
6045         memcpy(payment_key_ref.bytes, payment_key.ptr, 32);
6046         LDKSecretKey delayed_payment_base_key_ref;
6047         CHECK(delayed_payment_base_key.len == 32);
6048         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key.ptr, 32);
6049         LDKSecretKey htlc_base_key_ref;
6050         CHECK(htlc_base_key.len == 32);
6051         memcpy(htlc_base_key_ref.bytes, htlc_base_key.ptr, 32);
6052         LDKThirtyTwoBytes commitment_seed_ref;
6053         CHECK(commitment_seed.len == 32);
6054         memcpy(commitment_seed_ref.data, commitment_seed.ptr, 32);
6055         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
6056         FREE((void*)key_derivation_params);
6057         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);
6058         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6059         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6060         long ret_ref = (long)ret_var.inner;
6061         if (ret_var.is_owned) {
6062                 ret_ref |= 1;
6063         }
6064         return ret_ref;
6065 }
6066
6067 uint32_t InMemoryChannelKeys_1counterparty_1pubkeys(void* ctx_TODO, uint32_t this_arg) {
6068         LDKInMemoryChannelKeys this_arg_conv;
6069         this_arg_conv.inner = (void*)(this_arg & (~1));
6070         this_arg_conv.is_owned = false;
6071         LDKChannelPublicKeys ret_var = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
6072         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6073         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6074         long ret_ref = (long)ret_var.inner;
6075         if (ret_var.is_owned) {
6076                 ret_ref |= 1;
6077         }
6078         return ret_ref;
6079 }
6080
6081 jshort InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_arg) {
6082         LDKInMemoryChannelKeys this_arg_conv;
6083         this_arg_conv.inner = (void*)(this_arg & (~1));
6084         this_arg_conv.is_owned = false;
6085         jshort ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
6086         return ret_val;
6087 }
6088
6089 jshort InMemoryChannelKeys_1holder_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_arg) {
6090         LDKInMemoryChannelKeys this_arg_conv;
6091         this_arg_conv.inner = (void*)(this_arg & (~1));
6092         this_arg_conv.is_owned = false;
6093         jshort ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
6094         return ret_val;
6095 }
6096
6097 jboolean InMemoryChannelKeys_1is_1outbound(void* ctx_TODO, uint32_t this_arg) {
6098         LDKInMemoryChannelKeys this_arg_conv;
6099         this_arg_conv.inner = (void*)(this_arg & (~1));
6100         this_arg_conv.is_owned = false;
6101         jboolean ret_val = InMemoryChannelKeys_is_outbound(&this_arg_conv);
6102         return ret_val;
6103 }
6104
6105 uint32_t InMemoryChannelKeys_1funding_1outpoint(void* ctx_TODO, uint32_t this_arg) {
6106         LDKInMemoryChannelKeys this_arg_conv;
6107         this_arg_conv.inner = (void*)(this_arg & (~1));
6108         this_arg_conv.is_owned = false;
6109         LDKOutPoint ret_var = InMemoryChannelKeys_funding_outpoint(&this_arg_conv);
6110         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6111         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6112         long ret_ref = (long)ret_var.inner;
6113         if (ret_var.is_owned) {
6114                 ret_ref |= 1;
6115         }
6116         return ret_ref;
6117 }
6118
6119 uint32_t InMemoryChannelKeys_1get_1channel_1parameters(void* ctx_TODO, uint32_t this_arg) {
6120         LDKInMemoryChannelKeys this_arg_conv;
6121         this_arg_conv.inner = (void*)(this_arg & (~1));
6122         this_arg_conv.is_owned = false;
6123         LDKChannelTransactionParameters ret_var = InMemoryChannelKeys_get_channel_parameters(&this_arg_conv);
6124         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6125         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6126         long ret_ref = (long)ret_var.inner;
6127         if (ret_var.is_owned) {
6128                 ret_ref |= 1;
6129         }
6130         return ret_ref;
6131 }
6132
6133 uint32_t InMemoryChannelKeys_1as_1ChannelKeys(void* ctx_TODO, uint32_t this_arg) {
6134         LDKInMemoryChannelKeys this_arg_conv;
6135         this_arg_conv.inner = (void*)(this_arg & (~1));
6136         this_arg_conv.is_owned = false;
6137         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
6138         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
6139         return (long)ret;
6140 }
6141
6142 int8_tArray InMemoryChannelKeys_1write(void* ctx_TODO, uint32_t obj) {
6143         LDKInMemoryChannelKeys obj_conv;
6144         obj_conv.inner = (void*)(obj & (~1));
6145         obj_conv.is_owned = false;
6146         LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
6147         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
6148         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
6149         CVec_u8Z_free(arg_var);
6150         return arg_arr;
6151 }
6152
6153 uint32_t InMemoryChannelKeys_1read(void* ctx_TODO, int8_tArray ser) {
6154         LDKu8slice ser_ref;
6155         ser_ref.datalen = ser.len;
6156         ser_ref.data = ser.ptr;
6157         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
6158         *ret_conv = InMemoryChannelKeys_read(ser_ref);
6159         return (long)ret_conv;
6160 }
6161
6162 void KeysManager_1free(void* ctx_TODO, uint32_t this_ptr) {
6163         LDKKeysManager this_ptr_conv;
6164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6165         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6166         KeysManager_free(this_ptr_conv);
6167 }
6168
6169 uint32_t KeysManager_1new(void* ctx_TODO, int8_tArray seed, uint32_t network, int64_t starting_time_secs, int32_t starting_time_nanos) {
6170         unsigned char seed_arr[32];
6171         CHECK(seed.len == 32);
6172         memcpy(seed_arr, seed.ptr, 32);
6173         unsigned char (*seed_ref)[32] = &seed_arr;
6174         LDKNetwork network_conv = LDKNetwork_from_js(network);
6175         LDKKeysManager ret_var = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
6176         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6177         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6178         long ret_ref = (long)ret_var.inner;
6179         if (ret_var.is_owned) {
6180                 ret_ref |= 1;
6181         }
6182         return ret_ref;
6183 }
6184
6185 uint32_t KeysManager_1derive_1channel_1keys(void* ctx_TODO, uint32_t this_arg, int64_t channel_value_satoshis, int64_t params_1, int64_t params_2) {
6186         LDKKeysManager this_arg_conv;
6187         this_arg_conv.inner = (void*)(this_arg & (~1));
6188         this_arg_conv.is_owned = false;
6189         LDKInMemoryChannelKeys ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
6190         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6191         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6192         long ret_ref = (long)ret_var.inner;
6193         if (ret_var.is_owned) {
6194                 ret_ref |= 1;
6195         }
6196         return ret_ref;
6197 }
6198
6199 uint32_t KeysManager_1as_1KeysInterface(void* ctx_TODO, uint32_t this_arg) {
6200         LDKKeysManager this_arg_conv;
6201         this_arg_conv.inner = (void*)(this_arg & (~1));
6202         this_arg_conv.is_owned = false;
6203         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6204         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
6205         return (long)ret;
6206 }
6207
6208 void ChannelManager_1free(void* ctx_TODO, uint32_t this_ptr) {
6209         LDKChannelManager this_ptr_conv;
6210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6211         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6212         ChannelManager_free(this_ptr_conv);
6213 }
6214
6215 void ChannelDetails_1free(void* ctx_TODO, uint32_t this_ptr) {
6216         LDKChannelDetails this_ptr_conv;
6217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6218         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6219         ChannelDetails_free(this_ptr_conv);
6220 }
6221
6222 uint32_t ChannelDetails_1clone(void* ctx_TODO, uint32_t orig) {
6223         LDKChannelDetails orig_conv;
6224         orig_conv.inner = (void*)(orig & (~1));
6225         orig_conv.is_owned = false;
6226         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
6227         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6228         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6229         long ret_ref = (long)ret_var.inner;
6230         if (ret_var.is_owned) {
6231                 ret_ref |= 1;
6232         }
6233         return ret_ref;
6234 }
6235
6236 int8_tArray ChannelDetails_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
6237         LDKChannelDetails this_ptr_conv;
6238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6239         this_ptr_conv.is_owned = false;
6240         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6241         memcpy(ret_arr.ptr, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
6242         return ret_arr;
6243 }
6244
6245 void ChannelDetails_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6246         LDKChannelDetails this_ptr_conv;
6247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6248         this_ptr_conv.is_owned = false;
6249         LDKThirtyTwoBytes val_ref;
6250         CHECK(val.len == 32);
6251         memcpy(val_ref.data, val.ptr, 32);
6252         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
6253 }
6254
6255 int8_tArray ChannelDetails_1get_1remote_1network_1id(void* ctx_TODO, uint32_t this_ptr) {
6256         LDKChannelDetails this_ptr_conv;
6257         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6258         this_ptr_conv.is_owned = false;
6259         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
6260         memcpy(arg_arr.ptr, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
6261         return arg_arr;
6262 }
6263
6264 void ChannelDetails_1set_1remote_1network_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6265         LDKChannelDetails this_ptr_conv;
6266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6267         this_ptr_conv.is_owned = false;
6268         LDKPublicKey val_ref;
6269         CHECK(val.len == 33);
6270         memcpy(val_ref.compressed_form, val.ptr, 33);
6271         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
6272 }
6273
6274 uint32_t ChannelDetails_1get_1counterparty_1features(void* ctx_TODO, uint32_t this_ptr) {
6275         LDKChannelDetails this_ptr_conv;
6276         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6277         this_ptr_conv.is_owned = false;
6278         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
6279         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6280         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6281         long ret_ref = (long)ret_var.inner;
6282         if (ret_var.is_owned) {
6283                 ret_ref |= 1;
6284         }
6285         return ret_ref;
6286 }
6287
6288 void ChannelDetails_1set_1counterparty_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
6289         LDKChannelDetails this_ptr_conv;
6290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6291         this_ptr_conv.is_owned = false;
6292         LDKInitFeatures val_conv;
6293         val_conv.inner = (void*)(val & (~1));
6294         val_conv.is_owned = (val & 1) || (val == 0);
6295         // Warning: we may need a move here but can't clone!
6296         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
6297 }
6298
6299 int64_t ChannelDetails_1get_1channel_1value_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
6300         LDKChannelDetails this_ptr_conv;
6301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6302         this_ptr_conv.is_owned = false;
6303         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
6304         return ret_val;
6305 }
6306
6307 void ChannelDetails_1set_1channel_1value_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6308         LDKChannelDetails this_ptr_conv;
6309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6310         this_ptr_conv.is_owned = false;
6311         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
6312 }
6313
6314 int64_t ChannelDetails_1get_1user_1id(void* ctx_TODO, uint32_t this_ptr) {
6315         LDKChannelDetails this_ptr_conv;
6316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6317         this_ptr_conv.is_owned = false;
6318         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
6319         return ret_val;
6320 }
6321
6322 void ChannelDetails_1set_1user_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6323         LDKChannelDetails this_ptr_conv;
6324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6325         this_ptr_conv.is_owned = false;
6326         ChannelDetails_set_user_id(&this_ptr_conv, val);
6327 }
6328
6329 int64_t ChannelDetails_1get_1outbound_1capacity_1msat(void* ctx_TODO, uint32_t this_ptr) {
6330         LDKChannelDetails this_ptr_conv;
6331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6332         this_ptr_conv.is_owned = false;
6333         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
6334         return ret_val;
6335 }
6336
6337 void ChannelDetails_1set_1outbound_1capacity_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6338         LDKChannelDetails this_ptr_conv;
6339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6340         this_ptr_conv.is_owned = false;
6341         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
6342 }
6343
6344 int64_t ChannelDetails_1get_1inbound_1capacity_1msat(void* ctx_TODO, uint32_t this_ptr) {
6345         LDKChannelDetails this_ptr_conv;
6346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6347         this_ptr_conv.is_owned = false;
6348         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
6349         return ret_val;
6350 }
6351
6352 void ChannelDetails_1set_1inbound_1capacity_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6353         LDKChannelDetails this_ptr_conv;
6354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6355         this_ptr_conv.is_owned = false;
6356         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
6357 }
6358
6359 jboolean ChannelDetails_1get_1is_1live(void* ctx_TODO, uint32_t this_ptr) {
6360         LDKChannelDetails this_ptr_conv;
6361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6362         this_ptr_conv.is_owned = false;
6363         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
6364         return ret_val;
6365 }
6366
6367 void ChannelDetails_1set_1is_1live(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
6368         LDKChannelDetails this_ptr_conv;
6369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6370         this_ptr_conv.is_owned = false;
6371         ChannelDetails_set_is_live(&this_ptr_conv, val);
6372 }
6373
6374 void PaymentSendFailure_1free(void* ctx_TODO, uint32_t this_ptr) {
6375         LDKPaymentSendFailure this_ptr_conv;
6376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6377         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6378         PaymentSendFailure_free(this_ptr_conv);
6379 }
6380
6381 uint32_t ChannelManager_1new(void* ctx_TODO, 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) {
6382         LDKNetwork network_conv = LDKNetwork_from_js(network);
6383         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
6384         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
6385                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6386                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
6387         }
6388         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
6389         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
6390                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6391                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
6392         }
6393         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
6394         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6395                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6396                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
6397         }
6398         LDKLogger logger_conv = *(LDKLogger*)logger;
6399         if (logger_conv.free == LDKLogger_JCalls_free) {
6400                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6401                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6402         }
6403         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
6404         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
6405                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6406                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
6407         }
6408         LDKUserConfig config_conv;
6409         config_conv.inner = (void*)(config & (~1));
6410         config_conv.is_owned = (config & 1) || (config == 0);
6411         if (config_conv.inner != NULL)
6412                 config_conv = UserConfig_clone(&config_conv);
6413         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);
6414         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6415         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6416         long ret_ref = (long)ret_var.inner;
6417         if (ret_var.is_owned) {
6418                 ret_ref |= 1;
6419         }
6420         return ret_ref;
6421 }
6422
6423 uint32_t ChannelManager_1create_1channel(void* ctx_TODO, 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) {
6424         LDKChannelManager this_arg_conv;
6425         this_arg_conv.inner = (void*)(this_arg & (~1));
6426         this_arg_conv.is_owned = false;
6427         LDKPublicKey their_network_key_ref;
6428         CHECK(their_network_key.len == 33);
6429         memcpy(their_network_key_ref.compressed_form, their_network_key.ptr, 33);
6430         LDKUserConfig override_config_conv;
6431         override_config_conv.inner = (void*)(override_config & (~1));
6432         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
6433         if (override_config_conv.inner != NULL)
6434                 override_config_conv = UserConfig_clone(&override_config_conv);
6435         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6436         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
6437         return (long)ret_conv;
6438 }
6439
6440 uint32_tArray ChannelManager_1list_1channels(void* ctx_TODO, uint32_t this_arg) {
6441         LDKChannelManager this_arg_conv;
6442         this_arg_conv.inner = (void*)(this_arg & (~1));
6443         this_arg_conv.is_owned = false;
6444         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
6445         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
6446         uint32_t *ret_arr_ptr = ret_arr.ptr;
6447         for (size_t q = 0; q < ret_var.datalen; q++) {
6448                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
6449                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6450                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6451                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
6452                 if (arr_conv_16_var.is_owned) {
6453                         arr_conv_16_ref |= 1;
6454                 }
6455                 ret_arr_ptr[q] = arr_conv_16_ref;
6456         }
6457         FREE(ret_var.data);
6458         return ret_arr;
6459 }
6460
6461 uint32_tArray ChannelManager_1list_1usable_1channels(void* ctx_TODO, uint32_t this_arg) {
6462         LDKChannelManager this_arg_conv;
6463         this_arg_conv.inner = (void*)(this_arg & (~1));
6464         this_arg_conv.is_owned = false;
6465         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
6466         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
6467         uint32_t *ret_arr_ptr = ret_arr.ptr;
6468         for (size_t q = 0; q < ret_var.datalen; q++) {
6469                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
6470                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6471                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6472                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
6473                 if (arr_conv_16_var.is_owned) {
6474                         arr_conv_16_ref |= 1;
6475                 }
6476                 ret_arr_ptr[q] = arr_conv_16_ref;
6477         }
6478         FREE(ret_var.data);
6479         return ret_arr;
6480 }
6481
6482 uint32_t ChannelManager_1close_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray channel_id) {
6483         LDKChannelManager this_arg_conv;
6484         this_arg_conv.inner = (void*)(this_arg & (~1));
6485         this_arg_conv.is_owned = false;
6486         unsigned char channel_id_arr[32];
6487         CHECK(channel_id.len == 32);
6488         memcpy(channel_id_arr, channel_id.ptr, 32);
6489         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6490         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6491         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
6492         return (long)ret_conv;
6493 }
6494
6495 void ChannelManager_1force_1close_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray channel_id) {
6496         LDKChannelManager this_arg_conv;
6497         this_arg_conv.inner = (void*)(this_arg & (~1));
6498         this_arg_conv.is_owned = false;
6499         unsigned char channel_id_arr[32];
6500         CHECK(channel_id.len == 32);
6501         memcpy(channel_id_arr, channel_id.ptr, 32);
6502         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
6503         ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
6504 }
6505
6506 void ChannelManager_1force_1close_1all_1channels(void* ctx_TODO, uint32_t this_arg) {
6507         LDKChannelManager this_arg_conv;
6508         this_arg_conv.inner = (void*)(this_arg & (~1));
6509         this_arg_conv.is_owned = false;
6510         ChannelManager_force_close_all_channels(&this_arg_conv);
6511 }
6512
6513 uint32_t ChannelManager_1send_1payment(void* ctx_TODO, uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
6514         LDKChannelManager this_arg_conv;
6515         this_arg_conv.inner = (void*)(this_arg & (~1));
6516         this_arg_conv.is_owned = false;
6517         LDKRoute route_conv;
6518         route_conv.inner = (void*)(route & (~1));
6519         route_conv.is_owned = false;
6520         LDKThirtyTwoBytes payment_hash_ref;
6521         CHECK(payment_hash.len == 32);
6522         memcpy(payment_hash_ref.data, payment_hash.ptr, 32);
6523         LDKThirtyTwoBytes payment_secret_ref;
6524         CHECK(payment_secret.len == 32);
6525         memcpy(payment_secret_ref.data, payment_secret.ptr, 32);
6526         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
6527         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
6528         return (long)ret_conv;
6529 }
6530
6531 void ChannelManager_1funding_1transaction_1generated(void* ctx_TODO, uint32_t this_arg, int8_tArray temporary_channel_id, uint32_t funding_txo) {
6532         LDKChannelManager this_arg_conv;
6533         this_arg_conv.inner = (void*)(this_arg & (~1));
6534         this_arg_conv.is_owned = false;
6535         unsigned char temporary_channel_id_arr[32];
6536         CHECK(temporary_channel_id.len == 32);
6537         memcpy(temporary_channel_id_arr, temporary_channel_id.ptr, 32);
6538         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
6539         LDKOutPoint funding_txo_conv;
6540         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6541         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
6542         if (funding_txo_conv.inner != NULL)
6543                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
6544         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
6545 }
6546
6547 void ChannelManager_1broadcast_1node_1announcement(void* ctx_TODO, uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
6548         LDKChannelManager this_arg_conv;
6549         this_arg_conv.inner = (void*)(this_arg & (~1));
6550         this_arg_conv.is_owned = false;
6551         LDKThreeBytes rgb_ref;
6552         CHECK(rgb.len == 3);
6553         memcpy(rgb_ref.data, rgb.ptr, 3);
6554         LDKThirtyTwoBytes alias_ref;
6555         CHECK(alias.len == 32);
6556         memcpy(alias_ref.data, alias.ptr, 32);
6557         LDKCVec_NetAddressZ addresses_constr;
6558         addresses_constr.datalen = addresses.len;
6559         if (addresses_constr.datalen > 0)
6560                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
6561         else
6562                 addresses_constr.data = NULL;
6563         uint32_t* addresses_vals = (uint32_t*) addresses.ptr;
6564         for (size_t m = 0; m < addresses_constr.datalen; m++) {
6565                 uint32_t arr_conv_12 = addresses_vals[m];
6566                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
6567                 FREE((void*)arr_conv_12);
6568                 addresses_constr.data[m] = arr_conv_12_conv;
6569         }
6570         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
6571 }
6572
6573 void ChannelManager_1process_1pending_1htlc_1forwards(void* ctx_TODO, uint32_t this_arg) {
6574         LDKChannelManager this_arg_conv;
6575         this_arg_conv.inner = (void*)(this_arg & (~1));
6576         this_arg_conv.is_owned = false;
6577         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
6578 }
6579
6580 void ChannelManager_1timer_1chan_1freshness_1every_1min(void* ctx_TODO, uint32_t this_arg) {
6581         LDKChannelManager this_arg_conv;
6582         this_arg_conv.inner = (void*)(this_arg & (~1));
6583         this_arg_conv.is_owned = false;
6584         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
6585 }
6586
6587 jboolean ChannelManager_1fail_1htlc_1backwards(void* ctx_TODO, uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
6588         LDKChannelManager this_arg_conv;
6589         this_arg_conv.inner = (void*)(this_arg & (~1));
6590         this_arg_conv.is_owned = false;
6591         unsigned char payment_hash_arr[32];
6592         CHECK(payment_hash.len == 32);
6593         memcpy(payment_hash_arr, payment_hash.ptr, 32);
6594         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
6595         LDKThirtyTwoBytes payment_secret_ref;
6596         CHECK(payment_secret.len == 32);
6597         memcpy(payment_secret_ref.data, payment_secret.ptr, 32);
6598         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
6599         return ret_val;
6600 }
6601
6602 jboolean ChannelManager_1claim_1funds(void* ctx_TODO, uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
6603         LDKChannelManager this_arg_conv;
6604         this_arg_conv.inner = (void*)(this_arg & (~1));
6605         this_arg_conv.is_owned = false;
6606         LDKThirtyTwoBytes payment_preimage_ref;
6607         CHECK(payment_preimage.len == 32);
6608         memcpy(payment_preimage_ref.data, payment_preimage.ptr, 32);
6609         LDKThirtyTwoBytes payment_secret_ref;
6610         CHECK(payment_secret.len == 32);
6611         memcpy(payment_secret_ref.data, payment_secret.ptr, 32);
6612         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
6613         return ret_val;
6614 }
6615
6616 int8_tArray ChannelManager_1get_1our_1node_1id(void* ctx_TODO, uint32_t this_arg) {
6617         LDKChannelManager this_arg_conv;
6618         this_arg_conv.inner = (void*)(this_arg & (~1));
6619         this_arg_conv.is_owned = false;
6620         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
6621         memcpy(arg_arr.ptr, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
6622         return arg_arr;
6623 }
6624
6625 void ChannelManager_1channel_1monitor_1updated(void* ctx_TODO, uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
6626         LDKChannelManager this_arg_conv;
6627         this_arg_conv.inner = (void*)(this_arg & (~1));
6628         this_arg_conv.is_owned = false;
6629         LDKOutPoint funding_txo_conv;
6630         funding_txo_conv.inner = (void*)(funding_txo & (~1));
6631         funding_txo_conv.is_owned = false;
6632         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
6633 }
6634
6635 uint32_t ChannelManager_1as_1MessageSendEventsProvider(void* ctx_TODO, uint32_t this_arg) {
6636         LDKChannelManager this_arg_conv;
6637         this_arg_conv.inner = (void*)(this_arg & (~1));
6638         this_arg_conv.is_owned = false;
6639         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
6640         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
6641         return (long)ret;
6642 }
6643
6644 uint32_t ChannelManager_1as_1EventsProvider(void* ctx_TODO, uint32_t this_arg) {
6645         LDKChannelManager this_arg_conv;
6646         this_arg_conv.inner = (void*)(this_arg & (~1));
6647         this_arg_conv.is_owned = false;
6648         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6649         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
6650         return (long)ret;
6651 }
6652
6653 void ChannelManager_1block_1connected(void* ctx_TODO, uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
6654         LDKChannelManager this_arg_conv;
6655         this_arg_conv.inner = (void*)(this_arg & (~1));
6656         this_arg_conv.is_owned = false;
6657         unsigned char header_arr[80];
6658         CHECK(header.len == 80);
6659         memcpy(header_arr, header.ptr, 80);
6660         unsigned char (*header_ref)[80] = &header_arr;
6661         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6662         txdata_constr.datalen = txdata.len;
6663         if (txdata_constr.datalen > 0)
6664                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6665         else
6666                 txdata_constr.data = NULL;
6667         uint32_t* txdata_vals = (uint32_t*) txdata.ptr;
6668         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6669                 uint32_t arr_conv_24 = txdata_vals[y];
6670                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_24;
6671                 FREE((void*)arr_conv_24);
6672                 txdata_constr.data[y] = arr_conv_24_conv;
6673         }
6674         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
6675 }
6676
6677 void ChannelManager_1block_1disconnected(void* ctx_TODO, uint32_t this_arg, int8_tArray header) {
6678         LDKChannelManager this_arg_conv;
6679         this_arg_conv.inner = (void*)(this_arg & (~1));
6680         this_arg_conv.is_owned = false;
6681         unsigned char header_arr[80];
6682         CHECK(header.len == 80);
6683         memcpy(header_arr, header.ptr, 80);
6684         unsigned char (*header_ref)[80] = &header_arr;
6685         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
6686 }
6687
6688 uint32_t ChannelManager_1as_1ChannelMessageHandler(void* ctx_TODO, uint32_t this_arg) {
6689         LDKChannelManager this_arg_conv;
6690         this_arg_conv.inner = (void*)(this_arg & (~1));
6691         this_arg_conv.is_owned = false;
6692         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
6693         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
6694         return (long)ret;
6695 }
6696
6697 int8_tArray ChannelManager_1write(void* ctx_TODO, uint32_t obj) {
6698         LDKChannelManager obj_conv;
6699         obj_conv.inner = (void*)(obj & (~1));
6700         obj_conv.is_owned = false;
6701         LDKCVec_u8Z arg_var = ChannelManager_write(&obj_conv);
6702         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
6703         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
6704         CVec_u8Z_free(arg_var);
6705         return arg_arr;
6706 }
6707
6708 void ChannelManagerReadArgs_1free(void* ctx_TODO, uint32_t this_ptr) {
6709         LDKChannelManagerReadArgs this_ptr_conv;
6710         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6711         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6712         ChannelManagerReadArgs_free(this_ptr_conv);
6713 }
6714
6715 uint32_t ChannelManagerReadArgs_1get_1keys_1manager(void* ctx_TODO, uint32_t this_ptr) {
6716         LDKChannelManagerReadArgs this_ptr_conv;
6717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6718         this_ptr_conv.is_owned = false;
6719         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
6720         return ret_ret;
6721 }
6722
6723 void ChannelManagerReadArgs_1set_1keys_1manager(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
6724         LDKChannelManagerReadArgs this_ptr_conv;
6725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6726         this_ptr_conv.is_owned = false;
6727         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
6728         if (val_conv.free == LDKKeysInterface_JCalls_free) {
6729                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6730                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
6731         }
6732         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
6733 }
6734
6735 uint32_t ChannelManagerReadArgs_1get_1fee_1estimator(void* ctx_TODO, uint32_t this_ptr) {
6736         LDKChannelManagerReadArgs this_ptr_conv;
6737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6738         this_ptr_conv.is_owned = false;
6739         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
6740         return ret_ret;
6741 }
6742
6743 void ChannelManagerReadArgs_1set_1fee_1estimator(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
6744         LDKChannelManagerReadArgs this_ptr_conv;
6745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6746         this_ptr_conv.is_owned = false;
6747         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
6748         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
6749                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6750                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
6751         }
6752         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
6753 }
6754
6755 uint32_t ChannelManagerReadArgs_1get_1chain_1monitor(void* ctx_TODO, uint32_t this_ptr) {
6756         LDKChannelManagerReadArgs this_ptr_conv;
6757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6758         this_ptr_conv.is_owned = false;
6759         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
6760         return ret_ret;
6761 }
6762
6763 void ChannelManagerReadArgs_1set_1chain_1monitor(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
6764         LDKChannelManagerReadArgs this_ptr_conv;
6765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6766         this_ptr_conv.is_owned = false;
6767         LDKWatch val_conv = *(LDKWatch*)val;
6768         if (val_conv.free == LDKWatch_JCalls_free) {
6769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6770                 LDKWatch_JCalls_clone(val_conv.this_arg);
6771         }
6772         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
6773 }
6774
6775 uint32_t ChannelManagerReadArgs_1get_1tx_1broadcaster(void* ctx_TODO, uint32_t this_ptr) {
6776         LDKChannelManagerReadArgs this_ptr_conv;
6777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6778         this_ptr_conv.is_owned = false;
6779         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
6780         return ret_ret;
6781 }
6782
6783 void ChannelManagerReadArgs_1set_1tx_1broadcaster(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
6784         LDKChannelManagerReadArgs this_ptr_conv;
6785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6786         this_ptr_conv.is_owned = false;
6787         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
6788         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
6789                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6790                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
6791         }
6792         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
6793 }
6794
6795 uint32_t ChannelManagerReadArgs_1get_1logger(void* ctx_TODO, uint32_t this_ptr) {
6796         LDKChannelManagerReadArgs this_ptr_conv;
6797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6798         this_ptr_conv.is_owned = false;
6799         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
6800         return ret_ret;
6801 }
6802
6803 void ChannelManagerReadArgs_1set_1logger(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
6804         LDKChannelManagerReadArgs this_ptr_conv;
6805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6806         this_ptr_conv.is_owned = false;
6807         LDKLogger val_conv = *(LDKLogger*)val;
6808         if (val_conv.free == LDKLogger_JCalls_free) {
6809                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6810                 LDKLogger_JCalls_clone(val_conv.this_arg);
6811         }
6812         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
6813 }
6814
6815 uint32_t ChannelManagerReadArgs_1get_1default_1config(void* ctx_TODO, uint32_t this_ptr) {
6816         LDKChannelManagerReadArgs this_ptr_conv;
6817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6818         this_ptr_conv.is_owned = false;
6819         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
6820         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6821         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6822         long ret_ref = (long)ret_var.inner;
6823         if (ret_var.is_owned) {
6824                 ret_ref |= 1;
6825         }
6826         return ret_ref;
6827 }
6828
6829 void ChannelManagerReadArgs_1set_1default_1config(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
6830         LDKChannelManagerReadArgs this_ptr_conv;
6831         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6832         this_ptr_conv.is_owned = false;
6833         LDKUserConfig val_conv;
6834         val_conv.inner = (void*)(val & (~1));
6835         val_conv.is_owned = (val & 1) || (val == 0);
6836         if (val_conv.inner != NULL)
6837                 val_conv = UserConfig_clone(&val_conv);
6838         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
6839 }
6840
6841 uint32_t ChannelManagerReadArgs_1new(void* ctx_TODO, 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) {
6842         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
6843         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
6844                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6845                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
6846         }
6847         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6848         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6849                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6850                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6851         }
6852         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
6853         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
6854                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6855                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
6856         }
6857         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
6858         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6859                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6860                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
6861         }
6862         LDKLogger logger_conv = *(LDKLogger*)logger;
6863         if (logger_conv.free == LDKLogger_JCalls_free) {
6864                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6865                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6866         }
6867         LDKUserConfig default_config_conv;
6868         default_config_conv.inner = (void*)(default_config & (~1));
6869         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
6870         if (default_config_conv.inner != NULL)
6871                 default_config_conv = UserConfig_clone(&default_config_conv);
6872         LDKCVec_ChannelMonitorZ channel_monitors_constr;
6873         channel_monitors_constr.datalen = channel_monitors.len;
6874         if (channel_monitors_constr.datalen > 0)
6875                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
6876         else
6877                 channel_monitors_constr.data = NULL;
6878         uint32_t* channel_monitors_vals = (uint32_t*) channel_monitors.ptr;
6879         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
6880                 uint32_t arr_conv_16 = channel_monitors_vals[q];
6881                 LDKChannelMonitor arr_conv_16_conv;
6882                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
6883                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
6884                 // Warning: we may need a move here but can't clone!
6885                 channel_monitors_constr.data[q] = arr_conv_16_conv;
6886         }
6887         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);
6888         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6889         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6890         long ret_ref = (long)ret_var.inner;
6891         if (ret_var.is_owned) {
6892                 ret_ref |= 1;
6893         }
6894         return ret_ref;
6895 }
6896
6897 uint32_t C2Tuple_1BlockHashChannelManagerZ_1read(void* ctx_TODO, int8_tArray ser, uint32_t arg) {
6898         LDKu8slice ser_ref;
6899         ser_ref.datalen = ser.len;
6900         ser_ref.data = ser.ptr;
6901         LDKChannelManagerReadArgs arg_conv;
6902         arg_conv.inner = (void*)(arg & (~1));
6903         arg_conv.is_owned = (arg & 1) || (arg == 0);
6904         // Warning: we may need a move here but can't clone!
6905         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
6906         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
6907         return (long)ret_conv;
6908 }
6909
6910 void DecodeError_1free(void* ctx_TODO, uint32_t this_ptr) {
6911         LDKDecodeError this_ptr_conv;
6912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6913         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6914         DecodeError_free(this_ptr_conv);
6915 }
6916
6917 void Init_1free(void* ctx_TODO, uint32_t this_ptr) {
6918         LDKInit this_ptr_conv;
6919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6920         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6921         Init_free(this_ptr_conv);
6922 }
6923
6924 uint32_t Init_1clone(void* ctx_TODO, uint32_t orig) {
6925         LDKInit orig_conv;
6926         orig_conv.inner = (void*)(orig & (~1));
6927         orig_conv.is_owned = false;
6928         LDKInit ret_var = Init_clone(&orig_conv);
6929         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6930         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6931         long ret_ref = (long)ret_var.inner;
6932         if (ret_var.is_owned) {
6933                 ret_ref |= 1;
6934         }
6935         return ret_ref;
6936 }
6937
6938 void ErrorMessage_1free(void* ctx_TODO, uint32_t this_ptr) {
6939         LDKErrorMessage this_ptr_conv;
6940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6941         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6942         ErrorMessage_free(this_ptr_conv);
6943 }
6944
6945 uint32_t ErrorMessage_1clone(void* ctx_TODO, uint32_t orig) {
6946         LDKErrorMessage orig_conv;
6947         orig_conv.inner = (void*)(orig & (~1));
6948         orig_conv.is_owned = false;
6949         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
6950         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6951         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6952         long ret_ref = (long)ret_var.inner;
6953         if (ret_var.is_owned) {
6954                 ret_ref |= 1;
6955         }
6956         return ret_ref;
6957 }
6958
6959 int8_tArray ErrorMessage_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
6960         LDKErrorMessage this_ptr_conv;
6961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6962         this_ptr_conv.is_owned = false;
6963         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6964         memcpy(ret_arr.ptr, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
6965         return ret_arr;
6966 }
6967
6968 void ErrorMessage_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6969         LDKErrorMessage this_ptr_conv;
6970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6971         this_ptr_conv.is_owned = false;
6972         LDKThirtyTwoBytes val_ref;
6973         CHECK(val.len == 32);
6974         memcpy(val_ref.data, val.ptr, 32);
6975         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
6976 }
6977
6978 jstring ErrorMessage_1get_1data(void* ctx_TODO, uint32_t this_ptr) {
6979         LDKErrorMessage this_ptr_conv;
6980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6981         this_ptr_conv.is_owned = false;
6982         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
6983         char* _buf = MALLOC(_str.len + 1, "str conv buf");
6984         memcpy(_buf, _str.chars, _str.len);
6985         _buf[_str.len] = 0;
6986         jstring _conv = (*env)->NewStringUTF(env, _str.chars);
6987         FREE(_buf);
6988         return _conv;
6989 }
6990
6991 void ErrorMessage_1set_1data(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6992         LDKErrorMessage this_ptr_conv;
6993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6994         this_ptr_conv.is_owned = false;
6995         LDKCVec_u8Z val_ref;
6996         val_ref.datalen = val.len;
6997         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
6998         memcpy(val_ref.data, val.ptr, val_ref.datalen);
6999         ErrorMessage_set_data(&this_ptr_conv, val_ref);
7000 }
7001
7002 uint32_t ErrorMessage_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray data_arg) {
7003         LDKThirtyTwoBytes channel_id_arg_ref;
7004         CHECK(channel_id_arg.len == 32);
7005         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
7006         LDKCVec_u8Z data_arg_ref;
7007         data_arg_ref.datalen = data_arg.len;
7008         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
7009         memcpy(data_arg_ref.data, data_arg.ptr, data_arg_ref.datalen);
7010         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
7011         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7012         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7013         long ret_ref = (long)ret_var.inner;
7014         if (ret_var.is_owned) {
7015                 ret_ref |= 1;
7016         }
7017         return ret_ref;
7018 }
7019
7020 void Ping_1free(void* ctx_TODO, uint32_t this_ptr) {
7021         LDKPing this_ptr_conv;
7022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7023         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7024         Ping_free(this_ptr_conv);
7025 }
7026
7027 uint32_t Ping_1clone(void* ctx_TODO, uint32_t orig) {
7028         LDKPing orig_conv;
7029         orig_conv.inner = (void*)(orig & (~1));
7030         orig_conv.is_owned = false;
7031         LDKPing ret_var = Ping_clone(&orig_conv);
7032         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7033         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7034         long ret_ref = (long)ret_var.inner;
7035         if (ret_var.is_owned) {
7036                 ret_ref |= 1;
7037         }
7038         return ret_ref;
7039 }
7040
7041 jshort Ping_1get_1ponglen(void* ctx_TODO, uint32_t this_ptr) {
7042         LDKPing this_ptr_conv;
7043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7044         this_ptr_conv.is_owned = false;
7045         jshort ret_val = Ping_get_ponglen(&this_ptr_conv);
7046         return ret_val;
7047 }
7048
7049 void Ping_1set_1ponglen(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7050         LDKPing this_ptr_conv;
7051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7052         this_ptr_conv.is_owned = false;
7053         Ping_set_ponglen(&this_ptr_conv, val);
7054 }
7055
7056 jshort Ping_1get_1byteslen(void* ctx_TODO, uint32_t this_ptr) {
7057         LDKPing this_ptr_conv;
7058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7059         this_ptr_conv.is_owned = false;
7060         jshort ret_val = Ping_get_byteslen(&this_ptr_conv);
7061         return ret_val;
7062 }
7063
7064 void Ping_1set_1byteslen(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7065         LDKPing this_ptr_conv;
7066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7067         this_ptr_conv.is_owned = false;
7068         Ping_set_byteslen(&this_ptr_conv, val);
7069 }
7070
7071 uint32_t Ping_1new(void* ctx_TODO, jshort ponglen_arg, jshort byteslen_arg) {
7072         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
7073         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7074         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7075         long ret_ref = (long)ret_var.inner;
7076         if (ret_var.is_owned) {
7077                 ret_ref |= 1;
7078         }
7079         return ret_ref;
7080 }
7081
7082 void Pong_1free(void* ctx_TODO, uint32_t this_ptr) {
7083         LDKPong this_ptr_conv;
7084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7085         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7086         Pong_free(this_ptr_conv);
7087 }
7088
7089 uint32_t Pong_1clone(void* ctx_TODO, uint32_t orig) {
7090         LDKPong orig_conv;
7091         orig_conv.inner = (void*)(orig & (~1));
7092         orig_conv.is_owned = false;
7093         LDKPong ret_var = Pong_clone(&orig_conv);
7094         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7095         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7096         long ret_ref = (long)ret_var.inner;
7097         if (ret_var.is_owned) {
7098                 ret_ref |= 1;
7099         }
7100         return ret_ref;
7101 }
7102
7103 jshort Pong_1get_1byteslen(void* ctx_TODO, uint32_t this_ptr) {
7104         LDKPong this_ptr_conv;
7105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7106         this_ptr_conv.is_owned = false;
7107         jshort ret_val = Pong_get_byteslen(&this_ptr_conv);
7108         return ret_val;
7109 }
7110
7111 void Pong_1set_1byteslen(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7112         LDKPong this_ptr_conv;
7113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7114         this_ptr_conv.is_owned = false;
7115         Pong_set_byteslen(&this_ptr_conv, val);
7116 }
7117
7118 uint32_t Pong_1new(void* ctx_TODO, jshort byteslen_arg) {
7119         LDKPong ret_var = Pong_new(byteslen_arg);
7120         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7121         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7122         long ret_ref = (long)ret_var.inner;
7123         if (ret_var.is_owned) {
7124                 ret_ref |= 1;
7125         }
7126         return ret_ref;
7127 }
7128
7129 void OpenChannel_1free(void* ctx_TODO, uint32_t this_ptr) {
7130         LDKOpenChannel this_ptr_conv;
7131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7132         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7133         OpenChannel_free(this_ptr_conv);
7134 }
7135
7136 uint32_t OpenChannel_1clone(void* ctx_TODO, uint32_t orig) {
7137         LDKOpenChannel orig_conv;
7138         orig_conv.inner = (void*)(orig & (~1));
7139         orig_conv.is_owned = false;
7140         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
7141         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7142         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7143         long ret_ref = (long)ret_var.inner;
7144         if (ret_var.is_owned) {
7145                 ret_ref |= 1;
7146         }
7147         return ret_ref;
7148 }
7149
7150 int8_tArray OpenChannel_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
7151         LDKOpenChannel this_ptr_conv;
7152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7153         this_ptr_conv.is_owned = false;
7154         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7155         memcpy(ret_arr.ptr, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
7156         return ret_arr;
7157 }
7158
7159 void OpenChannel_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7160         LDKOpenChannel this_ptr_conv;
7161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7162         this_ptr_conv.is_owned = false;
7163         LDKThirtyTwoBytes val_ref;
7164         CHECK(val.len == 32);
7165         memcpy(val_ref.data, val.ptr, 32);
7166         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
7167 }
7168
7169 int8_tArray OpenChannel_1get_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
7170         LDKOpenChannel this_ptr_conv;
7171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7172         this_ptr_conv.is_owned = false;
7173         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7174         memcpy(ret_arr.ptr, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
7175         return ret_arr;
7176 }
7177
7178 void OpenChannel_1set_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7179         LDKOpenChannel this_ptr_conv;
7180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7181         this_ptr_conv.is_owned = false;
7182         LDKThirtyTwoBytes val_ref;
7183         CHECK(val.len == 32);
7184         memcpy(val_ref.data, val.ptr, 32);
7185         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7186 }
7187
7188 int64_t OpenChannel_1get_1funding_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
7189         LDKOpenChannel this_ptr_conv;
7190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7191         this_ptr_conv.is_owned = false;
7192         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
7193         return ret_val;
7194 }
7195
7196 void OpenChannel_1set_1funding_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7197         LDKOpenChannel this_ptr_conv;
7198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7199         this_ptr_conv.is_owned = false;
7200         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
7201 }
7202
7203 int64_t OpenChannel_1get_1push_1msat(void* ctx_TODO, uint32_t this_ptr) {
7204         LDKOpenChannel this_ptr_conv;
7205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7206         this_ptr_conv.is_owned = false;
7207         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
7208         return ret_val;
7209 }
7210
7211 void OpenChannel_1set_1push_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7212         LDKOpenChannel this_ptr_conv;
7213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7214         this_ptr_conv.is_owned = false;
7215         OpenChannel_set_push_msat(&this_ptr_conv, val);
7216 }
7217
7218 int64_t OpenChannel_1get_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
7219         LDKOpenChannel this_ptr_conv;
7220         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7221         this_ptr_conv.is_owned = false;
7222         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
7223         return ret_val;
7224 }
7225
7226 void OpenChannel_1set_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7227         LDKOpenChannel this_ptr_conv;
7228         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7229         this_ptr_conv.is_owned = false;
7230         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7231 }
7232
7233 int64_t OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr) {
7234         LDKOpenChannel this_ptr_conv;
7235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7236         this_ptr_conv.is_owned = false;
7237         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7238         return ret_val;
7239 }
7240
7241 void OpenChannel_1set_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7242         LDKOpenChannel this_ptr_conv;
7243         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7244         this_ptr_conv.is_owned = false;
7245         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7246 }
7247
7248 int64_t OpenChannel_1get_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
7249         LDKOpenChannel this_ptr_conv;
7250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7251         this_ptr_conv.is_owned = false;
7252         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7253         return ret_val;
7254 }
7255
7256 void OpenChannel_1set_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7257         LDKOpenChannel this_ptr_conv;
7258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7259         this_ptr_conv.is_owned = false;
7260         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7261 }
7262
7263 int64_t OpenChannel_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
7264         LDKOpenChannel this_ptr_conv;
7265         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7266         this_ptr_conv.is_owned = false;
7267         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
7268         return ret_val;
7269 }
7270
7271 void OpenChannel_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7272         LDKOpenChannel this_ptr_conv;
7273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7274         this_ptr_conv.is_owned = false;
7275         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7276 }
7277
7278 int32_t OpenChannel_1get_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_ptr) {
7279         LDKOpenChannel this_ptr_conv;
7280         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7281         this_ptr_conv.is_owned = false;
7282         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
7283         return ret_val;
7284 }
7285
7286 void OpenChannel_1set_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
7287         LDKOpenChannel this_ptr_conv;
7288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7289         this_ptr_conv.is_owned = false;
7290         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
7291 }
7292
7293 jshort OpenChannel_1get_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr) {
7294         LDKOpenChannel this_ptr_conv;
7295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7296         this_ptr_conv.is_owned = false;
7297         jshort ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
7298         return ret_val;
7299 }
7300
7301 void OpenChannel_1set_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7302         LDKOpenChannel this_ptr_conv;
7303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7304         this_ptr_conv.is_owned = false;
7305         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
7306 }
7307
7308 jshort OpenChannel_1get_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr) {
7309         LDKOpenChannel this_ptr_conv;
7310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7311         this_ptr_conv.is_owned = false;
7312         jshort ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
7313         return ret_val;
7314 }
7315
7316 void OpenChannel_1set_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7317         LDKOpenChannel this_ptr_conv;
7318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7319         this_ptr_conv.is_owned = false;
7320         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7321 }
7322
7323 int8_tArray OpenChannel_1get_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
7324         LDKOpenChannel this_ptr_conv;
7325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7326         this_ptr_conv.is_owned = false;
7327         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7328         memcpy(arg_arr.ptr, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
7329         return arg_arr;
7330 }
7331
7332 void OpenChannel_1set_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7333         LDKOpenChannel this_ptr_conv;
7334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7335         this_ptr_conv.is_owned = false;
7336         LDKPublicKey val_ref;
7337         CHECK(val.len == 33);
7338         memcpy(val_ref.compressed_form, val.ptr, 33);
7339         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7340 }
7341
7342 int8_tArray OpenChannel_1get_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
7343         LDKOpenChannel this_ptr_conv;
7344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7345         this_ptr_conv.is_owned = false;
7346         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7347         memcpy(arg_arr.ptr, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
7348         return arg_arr;
7349 }
7350
7351 void OpenChannel_1set_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7352         LDKOpenChannel this_ptr_conv;
7353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7354         this_ptr_conv.is_owned = false;
7355         LDKPublicKey val_ref;
7356         CHECK(val.len == 33);
7357         memcpy(val_ref.compressed_form, val.ptr, 33);
7358         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7359 }
7360
7361 int8_tArray OpenChannel_1get_1payment_1point(void* ctx_TODO, uint32_t this_ptr) {
7362         LDKOpenChannel this_ptr_conv;
7363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7364         this_ptr_conv.is_owned = false;
7365         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7366         memcpy(arg_arr.ptr, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
7367         return arg_arr;
7368 }
7369
7370 void OpenChannel_1set_1payment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7371         LDKOpenChannel this_ptr_conv;
7372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7373         this_ptr_conv.is_owned = false;
7374         LDKPublicKey val_ref;
7375         CHECK(val.len == 33);
7376         memcpy(val_ref.compressed_form, val.ptr, 33);
7377         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
7378 }
7379
7380 int8_tArray OpenChannel_1get_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
7381         LDKOpenChannel this_ptr_conv;
7382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7383         this_ptr_conv.is_owned = false;
7384         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7385         memcpy(arg_arr.ptr, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
7386         return arg_arr;
7387 }
7388
7389 void OpenChannel_1set_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7390         LDKOpenChannel this_ptr_conv;
7391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7392         this_ptr_conv.is_owned = false;
7393         LDKPublicKey val_ref;
7394         CHECK(val.len == 33);
7395         memcpy(val_ref.compressed_form, val.ptr, 33);
7396         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7397 }
7398
7399 int8_tArray OpenChannel_1get_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
7400         LDKOpenChannel this_ptr_conv;
7401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7402         this_ptr_conv.is_owned = false;
7403         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7404         memcpy(arg_arr.ptr, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
7405         return arg_arr;
7406 }
7407
7408 void OpenChannel_1set_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7409         LDKOpenChannel this_ptr_conv;
7410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7411         this_ptr_conv.is_owned = false;
7412         LDKPublicKey val_ref;
7413         CHECK(val.len == 33);
7414         memcpy(val_ref.compressed_form, val.ptr, 33);
7415         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7416 }
7417
7418 int8_tArray OpenChannel_1get_1first_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
7419         LDKOpenChannel this_ptr_conv;
7420         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7421         this_ptr_conv.is_owned = false;
7422         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7423         memcpy(arg_arr.ptr, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
7424         return arg_arr;
7425 }
7426
7427 void OpenChannel_1set_1first_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7428         LDKOpenChannel this_ptr_conv;
7429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7430         this_ptr_conv.is_owned = false;
7431         LDKPublicKey val_ref;
7432         CHECK(val.len == 33);
7433         memcpy(val_ref.compressed_form, val.ptr, 33);
7434         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7435 }
7436
7437 int8_t OpenChannel_1get_1channel_1flags(void* ctx_TODO, uint32_t this_ptr) {
7438         LDKOpenChannel this_ptr_conv;
7439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7440         this_ptr_conv.is_owned = false;
7441         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
7442         return ret_val;
7443 }
7444
7445 void OpenChannel_1set_1channel_1flags(void* ctx_TODO, uint32_t this_ptr, int8_t val) {
7446         LDKOpenChannel this_ptr_conv;
7447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7448         this_ptr_conv.is_owned = false;
7449         OpenChannel_set_channel_flags(&this_ptr_conv, val);
7450 }
7451
7452 void AcceptChannel_1free(void* ctx_TODO, uint32_t this_ptr) {
7453         LDKAcceptChannel this_ptr_conv;
7454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7455         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7456         AcceptChannel_free(this_ptr_conv);
7457 }
7458
7459 uint32_t AcceptChannel_1clone(void* ctx_TODO, uint32_t orig) {
7460         LDKAcceptChannel orig_conv;
7461         orig_conv.inner = (void*)(orig & (~1));
7462         orig_conv.is_owned = false;
7463         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
7464         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7465         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7466         long ret_ref = (long)ret_var.inner;
7467         if (ret_var.is_owned) {
7468                 ret_ref |= 1;
7469         }
7470         return ret_ref;
7471 }
7472
7473 int8_tArray AcceptChannel_1get_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
7474         LDKAcceptChannel this_ptr_conv;
7475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7476         this_ptr_conv.is_owned = false;
7477         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7478         memcpy(ret_arr.ptr, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
7479         return ret_arr;
7480 }
7481
7482 void AcceptChannel_1set_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7483         LDKAcceptChannel this_ptr_conv;
7484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7485         this_ptr_conv.is_owned = false;
7486         LDKThirtyTwoBytes val_ref;
7487         CHECK(val.len == 32);
7488         memcpy(val_ref.data, val.ptr, 32);
7489         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7490 }
7491
7492 int64_t AcceptChannel_1get_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
7493         LDKAcceptChannel this_ptr_conv;
7494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7495         this_ptr_conv.is_owned = false;
7496         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
7497         return ret_val;
7498 }
7499
7500 void AcceptChannel_1set_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7501         LDKAcceptChannel this_ptr_conv;
7502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7503         this_ptr_conv.is_owned = false;
7504         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7505 }
7506
7507 int64_t AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr) {
7508         LDKAcceptChannel this_ptr_conv;
7509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7510         this_ptr_conv.is_owned = false;
7511         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7512         return ret_val;
7513 }
7514
7515 void AcceptChannel_1set_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7516         LDKAcceptChannel this_ptr_conv;
7517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7518         this_ptr_conv.is_owned = false;
7519         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7520 }
7521
7522 int64_t AcceptChannel_1get_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
7523         LDKAcceptChannel this_ptr_conv;
7524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7525         this_ptr_conv.is_owned = false;
7526         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7527         return ret_val;
7528 }
7529
7530 void AcceptChannel_1set_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7531         LDKAcceptChannel this_ptr_conv;
7532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7533         this_ptr_conv.is_owned = false;
7534         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7535 }
7536
7537 int64_t AcceptChannel_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
7538         LDKAcceptChannel this_ptr_conv;
7539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7540         this_ptr_conv.is_owned = false;
7541         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
7542         return ret_val;
7543 }
7544
7545 void AcceptChannel_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7546         LDKAcceptChannel this_ptr_conv;
7547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7548         this_ptr_conv.is_owned = false;
7549         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7550 }
7551
7552 int32_t AcceptChannel_1get_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr) {
7553         LDKAcceptChannel this_ptr_conv;
7554         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7555         this_ptr_conv.is_owned = false;
7556         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
7557         return ret_val;
7558 }
7559
7560 void AcceptChannel_1set_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
7561         LDKAcceptChannel this_ptr_conv;
7562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7563         this_ptr_conv.is_owned = false;
7564         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
7565 }
7566
7567 jshort AcceptChannel_1get_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr) {
7568         LDKAcceptChannel this_ptr_conv;
7569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7570         this_ptr_conv.is_owned = false;
7571         jshort ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
7572         return ret_val;
7573 }
7574
7575 void AcceptChannel_1set_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7576         LDKAcceptChannel this_ptr_conv;
7577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7578         this_ptr_conv.is_owned = false;
7579         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
7580 }
7581
7582 jshort AcceptChannel_1get_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr) {
7583         LDKAcceptChannel this_ptr_conv;
7584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7585         this_ptr_conv.is_owned = false;
7586         jshort ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
7587         return ret_val;
7588 }
7589
7590 void AcceptChannel_1set_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7591         LDKAcceptChannel this_ptr_conv;
7592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7593         this_ptr_conv.is_owned = false;
7594         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7595 }
7596
7597 int8_tArray AcceptChannel_1get_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
7598         LDKAcceptChannel this_ptr_conv;
7599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7600         this_ptr_conv.is_owned = false;
7601         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7602         memcpy(arg_arr.ptr, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
7603         return arg_arr;
7604 }
7605
7606 void AcceptChannel_1set_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7607         LDKAcceptChannel this_ptr_conv;
7608         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7609         this_ptr_conv.is_owned = false;
7610         LDKPublicKey val_ref;
7611         CHECK(val.len == 33);
7612         memcpy(val_ref.compressed_form, val.ptr, 33);
7613         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7614 }
7615
7616 int8_tArray AcceptChannel_1get_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
7617         LDKAcceptChannel this_ptr_conv;
7618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7619         this_ptr_conv.is_owned = false;
7620         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7621         memcpy(arg_arr.ptr, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
7622         return arg_arr;
7623 }
7624
7625 void AcceptChannel_1set_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7626         LDKAcceptChannel this_ptr_conv;
7627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7628         this_ptr_conv.is_owned = false;
7629         LDKPublicKey val_ref;
7630         CHECK(val.len == 33);
7631         memcpy(val_ref.compressed_form, val.ptr, 33);
7632         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7633 }
7634
7635 int8_tArray AcceptChannel_1get_1payment_1point(void* ctx_TODO, uint32_t this_ptr) {
7636         LDKAcceptChannel this_ptr_conv;
7637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7638         this_ptr_conv.is_owned = false;
7639         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7640         memcpy(arg_arr.ptr, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
7641         return arg_arr;
7642 }
7643
7644 void AcceptChannel_1set_1payment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7645         LDKAcceptChannel this_ptr_conv;
7646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7647         this_ptr_conv.is_owned = false;
7648         LDKPublicKey val_ref;
7649         CHECK(val.len == 33);
7650         memcpy(val_ref.compressed_form, val.ptr, 33);
7651         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
7652 }
7653
7654 int8_tArray AcceptChannel_1get_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
7655         LDKAcceptChannel this_ptr_conv;
7656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7657         this_ptr_conv.is_owned = false;
7658         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7659         memcpy(arg_arr.ptr, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
7660         return arg_arr;
7661 }
7662
7663 void AcceptChannel_1set_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7664         LDKAcceptChannel this_ptr_conv;
7665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7666         this_ptr_conv.is_owned = false;
7667         LDKPublicKey val_ref;
7668         CHECK(val.len == 33);
7669         memcpy(val_ref.compressed_form, val.ptr, 33);
7670         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
7671 }
7672
7673 int8_tArray AcceptChannel_1get_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
7674         LDKAcceptChannel this_ptr_conv;
7675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7676         this_ptr_conv.is_owned = false;
7677         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7678         memcpy(arg_arr.ptr, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
7679         return arg_arr;
7680 }
7681
7682 void AcceptChannel_1set_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7683         LDKAcceptChannel this_ptr_conv;
7684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7685         this_ptr_conv.is_owned = false;
7686         LDKPublicKey val_ref;
7687         CHECK(val.len == 33);
7688         memcpy(val_ref.compressed_form, val.ptr, 33);
7689         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
7690 }
7691
7692 int8_tArray AcceptChannel_1get_1first_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
7693         LDKAcceptChannel this_ptr_conv;
7694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7695         this_ptr_conv.is_owned = false;
7696         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7697         memcpy(arg_arr.ptr, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
7698         return arg_arr;
7699 }
7700
7701 void AcceptChannel_1set_1first_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7702         LDKAcceptChannel this_ptr_conv;
7703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7704         this_ptr_conv.is_owned = false;
7705         LDKPublicKey val_ref;
7706         CHECK(val.len == 33);
7707         memcpy(val_ref.compressed_form, val.ptr, 33);
7708         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
7709 }
7710
7711 void FundingCreated_1free(void* ctx_TODO, uint32_t this_ptr) {
7712         LDKFundingCreated this_ptr_conv;
7713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7714         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7715         FundingCreated_free(this_ptr_conv);
7716 }
7717
7718 uint32_t FundingCreated_1clone(void* ctx_TODO, uint32_t orig) {
7719         LDKFundingCreated orig_conv;
7720         orig_conv.inner = (void*)(orig & (~1));
7721         orig_conv.is_owned = false;
7722         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
7723         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7724         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7725         long ret_ref = (long)ret_var.inner;
7726         if (ret_var.is_owned) {
7727                 ret_ref |= 1;
7728         }
7729         return ret_ref;
7730 }
7731
7732 int8_tArray FundingCreated_1get_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
7733         LDKFundingCreated this_ptr_conv;
7734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7735         this_ptr_conv.is_owned = false;
7736         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7737         memcpy(ret_arr.ptr, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
7738         return ret_arr;
7739 }
7740
7741 void FundingCreated_1set_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7742         LDKFundingCreated this_ptr_conv;
7743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7744         this_ptr_conv.is_owned = false;
7745         LDKThirtyTwoBytes val_ref;
7746         CHECK(val.len == 32);
7747         memcpy(val_ref.data, val.ptr, 32);
7748         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
7749 }
7750
7751 int8_tArray FundingCreated_1get_1funding_1txid(void* ctx_TODO, uint32_t this_ptr) {
7752         LDKFundingCreated this_ptr_conv;
7753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7754         this_ptr_conv.is_owned = false;
7755         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7756         memcpy(ret_arr.ptr, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
7757         return ret_arr;
7758 }
7759
7760 void FundingCreated_1set_1funding_1txid(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7761         LDKFundingCreated this_ptr_conv;
7762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7763         this_ptr_conv.is_owned = false;
7764         LDKThirtyTwoBytes val_ref;
7765         CHECK(val.len == 32);
7766         memcpy(val_ref.data, val.ptr, 32);
7767         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
7768 }
7769
7770 jshort FundingCreated_1get_1funding_1output_1index(void* ctx_TODO, uint32_t this_ptr) {
7771         LDKFundingCreated this_ptr_conv;
7772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7773         this_ptr_conv.is_owned = false;
7774         jshort ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
7775         return ret_val;
7776 }
7777
7778 void FundingCreated_1set_1funding_1output_1index(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7779         LDKFundingCreated this_ptr_conv;
7780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7781         this_ptr_conv.is_owned = false;
7782         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
7783 }
7784
7785 int8_tArray FundingCreated_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
7786         LDKFundingCreated this_ptr_conv;
7787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7788         this_ptr_conv.is_owned = false;
7789         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
7790         memcpy(arg_arr.ptr, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
7791         return arg_arr;
7792 }
7793
7794 void FundingCreated_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7795         LDKFundingCreated this_ptr_conv;
7796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7797         this_ptr_conv.is_owned = false;
7798         LDKSignature val_ref;
7799         CHECK(val.len == 64);
7800         memcpy(val_ref.compact_form, val.ptr, 64);
7801         FundingCreated_set_signature(&this_ptr_conv, val_ref);
7802 }
7803
7804 uint32_t FundingCreated_1new(void* ctx_TODO, int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, jshort funding_output_index_arg, int8_tArray signature_arg) {
7805         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
7806         CHECK(temporary_channel_id_arg.len == 32);
7807         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg.ptr, 32);
7808         LDKThirtyTwoBytes funding_txid_arg_ref;
7809         CHECK(funding_txid_arg.len == 32);
7810         memcpy(funding_txid_arg_ref.data, funding_txid_arg.ptr, 32);
7811         LDKSignature signature_arg_ref;
7812         CHECK(signature_arg.len == 64);
7813         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
7814         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
7815         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7816         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7817         long ret_ref = (long)ret_var.inner;
7818         if (ret_var.is_owned) {
7819                 ret_ref |= 1;
7820         }
7821         return ret_ref;
7822 }
7823
7824 void FundingSigned_1free(void* ctx_TODO, uint32_t this_ptr) {
7825         LDKFundingSigned this_ptr_conv;
7826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7827         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7828         FundingSigned_free(this_ptr_conv);
7829 }
7830
7831 uint32_t FundingSigned_1clone(void* ctx_TODO, uint32_t orig) {
7832         LDKFundingSigned orig_conv;
7833         orig_conv.inner = (void*)(orig & (~1));
7834         orig_conv.is_owned = false;
7835         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
7836         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7837         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7838         long ret_ref = (long)ret_var.inner;
7839         if (ret_var.is_owned) {
7840                 ret_ref |= 1;
7841         }
7842         return ret_ref;
7843 }
7844
7845 int8_tArray FundingSigned_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
7846         LDKFundingSigned this_ptr_conv;
7847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7848         this_ptr_conv.is_owned = false;
7849         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7850         memcpy(ret_arr.ptr, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
7851         return ret_arr;
7852 }
7853
7854 void FundingSigned_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7855         LDKFundingSigned this_ptr_conv;
7856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7857         this_ptr_conv.is_owned = false;
7858         LDKThirtyTwoBytes val_ref;
7859         CHECK(val.len == 32);
7860         memcpy(val_ref.data, val.ptr, 32);
7861         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
7862 }
7863
7864 int8_tArray FundingSigned_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
7865         LDKFundingSigned this_ptr_conv;
7866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7867         this_ptr_conv.is_owned = false;
7868         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
7869         memcpy(arg_arr.ptr, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
7870         return arg_arr;
7871 }
7872
7873 void FundingSigned_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7874         LDKFundingSigned this_ptr_conv;
7875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7876         this_ptr_conv.is_owned = false;
7877         LDKSignature val_ref;
7878         CHECK(val.len == 64);
7879         memcpy(val_ref.compact_form, val.ptr, 64);
7880         FundingSigned_set_signature(&this_ptr_conv, val_ref);
7881 }
7882
7883 uint32_t FundingSigned_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray signature_arg) {
7884         LDKThirtyTwoBytes channel_id_arg_ref;
7885         CHECK(channel_id_arg.len == 32);
7886         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
7887         LDKSignature signature_arg_ref;
7888         CHECK(signature_arg.len == 64);
7889         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
7890         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
7891         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7892         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7893         long ret_ref = (long)ret_var.inner;
7894         if (ret_var.is_owned) {
7895                 ret_ref |= 1;
7896         }
7897         return ret_ref;
7898 }
7899
7900 void FundingLocked_1free(void* ctx_TODO, uint32_t this_ptr) {
7901         LDKFundingLocked this_ptr_conv;
7902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7903         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7904         FundingLocked_free(this_ptr_conv);
7905 }
7906
7907 uint32_t FundingLocked_1clone(void* ctx_TODO, uint32_t orig) {
7908         LDKFundingLocked orig_conv;
7909         orig_conv.inner = (void*)(orig & (~1));
7910         orig_conv.is_owned = false;
7911         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
7912         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7913         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7914         long ret_ref = (long)ret_var.inner;
7915         if (ret_var.is_owned) {
7916                 ret_ref |= 1;
7917         }
7918         return ret_ref;
7919 }
7920
7921 int8_tArray FundingLocked_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
7922         LDKFundingLocked this_ptr_conv;
7923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7924         this_ptr_conv.is_owned = false;
7925         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7926         memcpy(ret_arr.ptr, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
7927         return ret_arr;
7928 }
7929
7930 void FundingLocked_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7931         LDKFundingLocked this_ptr_conv;
7932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7933         this_ptr_conv.is_owned = false;
7934         LDKThirtyTwoBytes val_ref;
7935         CHECK(val.len == 32);
7936         memcpy(val_ref.data, val.ptr, 32);
7937         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
7938 }
7939
7940 int8_tArray FundingLocked_1get_1next_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
7941         LDKFundingLocked this_ptr_conv;
7942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7943         this_ptr_conv.is_owned = false;
7944         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7945         memcpy(arg_arr.ptr, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
7946         return arg_arr;
7947 }
7948
7949 void FundingLocked_1set_1next_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7950         LDKFundingLocked this_ptr_conv;
7951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7952         this_ptr_conv.is_owned = false;
7953         LDKPublicKey val_ref;
7954         CHECK(val.len == 33);
7955         memcpy(val_ref.compressed_form, val.ptr, 33);
7956         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
7957 }
7958
7959 uint32_t FundingLocked_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
7960         LDKThirtyTwoBytes channel_id_arg_ref;
7961         CHECK(channel_id_arg.len == 32);
7962         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
7963         LDKPublicKey next_per_commitment_point_arg_ref;
7964         CHECK(next_per_commitment_point_arg.len == 33);
7965         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg.ptr, 33);
7966         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
7967         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7968         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7969         long ret_ref = (long)ret_var.inner;
7970         if (ret_var.is_owned) {
7971                 ret_ref |= 1;
7972         }
7973         return ret_ref;
7974 }
7975
7976 void Shutdown_1free(void* ctx_TODO, uint32_t this_ptr) {
7977         LDKShutdown this_ptr_conv;
7978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7979         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7980         Shutdown_free(this_ptr_conv);
7981 }
7982
7983 uint32_t Shutdown_1clone(void* ctx_TODO, uint32_t orig) {
7984         LDKShutdown orig_conv;
7985         orig_conv.inner = (void*)(orig & (~1));
7986         orig_conv.is_owned = false;
7987         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
7988         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7989         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7990         long ret_ref = (long)ret_var.inner;
7991         if (ret_var.is_owned) {
7992                 ret_ref |= 1;
7993         }
7994         return ret_ref;
7995 }
7996
7997 int8_tArray Shutdown_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
7998         LDKShutdown this_ptr_conv;
7999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8000         this_ptr_conv.is_owned = false;
8001         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8002         memcpy(ret_arr.ptr, *Shutdown_get_channel_id(&this_ptr_conv), 32);
8003         return ret_arr;
8004 }
8005
8006 void Shutdown_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8007         LDKShutdown this_ptr_conv;
8008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8009         this_ptr_conv.is_owned = false;
8010         LDKThirtyTwoBytes val_ref;
8011         CHECK(val.len == 32);
8012         memcpy(val_ref.data, val.ptr, 32);
8013         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
8014 }
8015
8016 int8_tArray Shutdown_1get_1scriptpubkey(void* ctx_TODO, uint32_t this_ptr) {
8017         LDKShutdown this_ptr_conv;
8018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8019         this_ptr_conv.is_owned = false;
8020         LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
8021         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
8022         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
8023         return arg_arr;
8024 }
8025
8026 void Shutdown_1set_1scriptpubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8027         LDKShutdown this_ptr_conv;
8028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8029         this_ptr_conv.is_owned = false;
8030         LDKCVec_u8Z val_ref;
8031         val_ref.datalen = val.len;
8032         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
8033         memcpy(val_ref.data, val.ptr, val_ref.datalen);
8034         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
8035 }
8036
8037 uint32_t Shutdown_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
8038         LDKThirtyTwoBytes channel_id_arg_ref;
8039         CHECK(channel_id_arg.len == 32);
8040         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8041         LDKCVec_u8Z scriptpubkey_arg_ref;
8042         scriptpubkey_arg_ref.datalen = scriptpubkey_arg.len;
8043         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
8044         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg.ptr, scriptpubkey_arg_ref.datalen);
8045         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
8046         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8047         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8048         long ret_ref = (long)ret_var.inner;
8049         if (ret_var.is_owned) {
8050                 ret_ref |= 1;
8051         }
8052         return ret_ref;
8053 }
8054
8055 void ClosingSigned_1free(void* ctx_TODO, uint32_t this_ptr) {
8056         LDKClosingSigned this_ptr_conv;
8057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8058         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8059         ClosingSigned_free(this_ptr_conv);
8060 }
8061
8062 uint32_t ClosingSigned_1clone(void* ctx_TODO, uint32_t orig) {
8063         LDKClosingSigned orig_conv;
8064         orig_conv.inner = (void*)(orig & (~1));
8065         orig_conv.is_owned = false;
8066         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
8067         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8068         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8069         long ret_ref = (long)ret_var.inner;
8070         if (ret_var.is_owned) {
8071                 ret_ref |= 1;
8072         }
8073         return ret_ref;
8074 }
8075
8076 int8_tArray ClosingSigned_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8077         LDKClosingSigned this_ptr_conv;
8078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8079         this_ptr_conv.is_owned = false;
8080         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8081         memcpy(ret_arr.ptr, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
8082         return ret_arr;
8083 }
8084
8085 void ClosingSigned_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8086         LDKClosingSigned this_ptr_conv;
8087         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8088         this_ptr_conv.is_owned = false;
8089         LDKThirtyTwoBytes val_ref;
8090         CHECK(val.len == 32);
8091         memcpy(val_ref.data, val.ptr, 32);
8092         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
8093 }
8094
8095 int64_t ClosingSigned_1get_1fee_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
8096         LDKClosingSigned this_ptr_conv;
8097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8098         this_ptr_conv.is_owned = false;
8099         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
8100         return ret_val;
8101 }
8102
8103 void ClosingSigned_1set_1fee_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8104         LDKClosingSigned this_ptr_conv;
8105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8106         this_ptr_conv.is_owned = false;
8107         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
8108 }
8109
8110 int8_tArray ClosingSigned_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
8111         LDKClosingSigned this_ptr_conv;
8112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8113         this_ptr_conv.is_owned = false;
8114         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
8115         memcpy(arg_arr.ptr, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
8116         return arg_arr;
8117 }
8118
8119 void ClosingSigned_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8120         LDKClosingSigned this_ptr_conv;
8121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8122         this_ptr_conv.is_owned = false;
8123         LDKSignature val_ref;
8124         CHECK(val.len == 64);
8125         memcpy(val_ref.compact_form, val.ptr, 64);
8126         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
8127 }
8128
8129 uint32_t ClosingSigned_1new(void* ctx_TODO, int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
8130         LDKThirtyTwoBytes channel_id_arg_ref;
8131         CHECK(channel_id_arg.len == 32);
8132         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8133         LDKSignature signature_arg_ref;
8134         CHECK(signature_arg.len == 64);
8135         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
8136         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
8137         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8138         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8139         long ret_ref = (long)ret_var.inner;
8140         if (ret_var.is_owned) {
8141                 ret_ref |= 1;
8142         }
8143         return ret_ref;
8144 }
8145
8146 void UpdateAddHTLC_1free(void* ctx_TODO, uint32_t this_ptr) {
8147         LDKUpdateAddHTLC this_ptr_conv;
8148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8149         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8150         UpdateAddHTLC_free(this_ptr_conv);
8151 }
8152
8153 uint32_t UpdateAddHTLC_1clone(void* ctx_TODO, uint32_t orig) {
8154         LDKUpdateAddHTLC orig_conv;
8155         orig_conv.inner = (void*)(orig & (~1));
8156         orig_conv.is_owned = false;
8157         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
8158         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8159         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8160         long ret_ref = (long)ret_var.inner;
8161         if (ret_var.is_owned) {
8162                 ret_ref |= 1;
8163         }
8164         return ret_ref;
8165 }
8166
8167 int8_tArray UpdateAddHTLC_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8168         LDKUpdateAddHTLC this_ptr_conv;
8169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8170         this_ptr_conv.is_owned = false;
8171         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8172         memcpy(ret_arr.ptr, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
8173         return ret_arr;
8174 }
8175
8176 void UpdateAddHTLC_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8177         LDKUpdateAddHTLC this_ptr_conv;
8178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8179         this_ptr_conv.is_owned = false;
8180         LDKThirtyTwoBytes val_ref;
8181         CHECK(val.len == 32);
8182         memcpy(val_ref.data, val.ptr, 32);
8183         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
8184 }
8185
8186 int64_t UpdateAddHTLC_1get_1htlc_1id(void* ctx_TODO, uint32_t this_ptr) {
8187         LDKUpdateAddHTLC this_ptr_conv;
8188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8189         this_ptr_conv.is_owned = false;
8190         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
8191         return ret_val;
8192 }
8193
8194 void UpdateAddHTLC_1set_1htlc_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8195         LDKUpdateAddHTLC this_ptr_conv;
8196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8197         this_ptr_conv.is_owned = false;
8198         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
8199 }
8200
8201 int64_t UpdateAddHTLC_1get_1amount_1msat(void* ctx_TODO, uint32_t this_ptr) {
8202         LDKUpdateAddHTLC this_ptr_conv;
8203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8204         this_ptr_conv.is_owned = false;
8205         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
8206         return ret_val;
8207 }
8208
8209 void UpdateAddHTLC_1set_1amount_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8210         LDKUpdateAddHTLC this_ptr_conv;
8211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8212         this_ptr_conv.is_owned = false;
8213         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
8214 }
8215
8216 int8_tArray UpdateAddHTLC_1get_1payment_1hash(void* ctx_TODO, uint32_t this_ptr) {
8217         LDKUpdateAddHTLC this_ptr_conv;
8218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8219         this_ptr_conv.is_owned = false;
8220         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8221         memcpy(ret_arr.ptr, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
8222         return ret_arr;
8223 }
8224
8225 void UpdateAddHTLC_1set_1payment_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8226         LDKUpdateAddHTLC this_ptr_conv;
8227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8228         this_ptr_conv.is_owned = false;
8229         LDKThirtyTwoBytes val_ref;
8230         CHECK(val.len == 32);
8231         memcpy(val_ref.data, val.ptr, 32);
8232         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
8233 }
8234
8235 int32_t UpdateAddHTLC_1get_1cltv_1expiry(void* ctx_TODO, uint32_t this_ptr) {
8236         LDKUpdateAddHTLC this_ptr_conv;
8237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8238         this_ptr_conv.is_owned = false;
8239         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
8240         return ret_val;
8241 }
8242
8243 void UpdateAddHTLC_1set_1cltv_1expiry(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
8244         LDKUpdateAddHTLC this_ptr_conv;
8245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8246         this_ptr_conv.is_owned = false;
8247         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
8248 }
8249
8250 void UpdateFulfillHTLC_1free(void* ctx_TODO, uint32_t this_ptr) {
8251         LDKUpdateFulfillHTLC this_ptr_conv;
8252         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8253         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8254         UpdateFulfillHTLC_free(this_ptr_conv);
8255 }
8256
8257 uint32_t UpdateFulfillHTLC_1clone(void* ctx_TODO, uint32_t orig) {
8258         LDKUpdateFulfillHTLC orig_conv;
8259         orig_conv.inner = (void*)(orig & (~1));
8260         orig_conv.is_owned = false;
8261         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
8262         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8263         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8264         long ret_ref = (long)ret_var.inner;
8265         if (ret_var.is_owned) {
8266                 ret_ref |= 1;
8267         }
8268         return ret_ref;
8269 }
8270
8271 int8_tArray UpdateFulfillHTLC_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8272         LDKUpdateFulfillHTLC this_ptr_conv;
8273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8274         this_ptr_conv.is_owned = false;
8275         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8276         memcpy(ret_arr.ptr, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
8277         return ret_arr;
8278 }
8279
8280 void UpdateFulfillHTLC_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8281         LDKUpdateFulfillHTLC this_ptr_conv;
8282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8283         this_ptr_conv.is_owned = false;
8284         LDKThirtyTwoBytes val_ref;
8285         CHECK(val.len == 32);
8286         memcpy(val_ref.data, val.ptr, 32);
8287         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
8288 }
8289
8290 int64_t UpdateFulfillHTLC_1get_1htlc_1id(void* ctx_TODO, uint32_t this_ptr) {
8291         LDKUpdateFulfillHTLC this_ptr_conv;
8292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8293         this_ptr_conv.is_owned = false;
8294         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
8295         return ret_val;
8296 }
8297
8298 void UpdateFulfillHTLC_1set_1htlc_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8299         LDKUpdateFulfillHTLC this_ptr_conv;
8300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8301         this_ptr_conv.is_owned = false;
8302         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
8303 }
8304
8305 int8_tArray UpdateFulfillHTLC_1get_1payment_1preimage(void* ctx_TODO, uint32_t this_ptr) {
8306         LDKUpdateFulfillHTLC this_ptr_conv;
8307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8308         this_ptr_conv.is_owned = false;
8309         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8310         memcpy(ret_arr.ptr, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
8311         return ret_arr;
8312 }
8313
8314 void UpdateFulfillHTLC_1set_1payment_1preimage(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8315         LDKUpdateFulfillHTLC this_ptr_conv;
8316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8317         this_ptr_conv.is_owned = false;
8318         LDKThirtyTwoBytes val_ref;
8319         CHECK(val.len == 32);
8320         memcpy(val_ref.data, val.ptr, 32);
8321         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
8322 }
8323
8324 uint32_t UpdateFulfillHTLC_1new(void* ctx_TODO, int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
8325         LDKThirtyTwoBytes channel_id_arg_ref;
8326         CHECK(channel_id_arg.len == 32);
8327         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8328         LDKThirtyTwoBytes payment_preimage_arg_ref;
8329         CHECK(payment_preimage_arg.len == 32);
8330         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg.ptr, 32);
8331         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
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 void UpdateFailHTLC_1free(void* ctx_TODO, uint32_t this_ptr) {
8342         LDKUpdateFailHTLC this_ptr_conv;
8343         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8344         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8345         UpdateFailHTLC_free(this_ptr_conv);
8346 }
8347
8348 uint32_t UpdateFailHTLC_1clone(void* ctx_TODO, uint32_t orig) {
8349         LDKUpdateFailHTLC orig_conv;
8350         orig_conv.inner = (void*)(orig & (~1));
8351         orig_conv.is_owned = false;
8352         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
8353         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8354         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8355         long ret_ref = (long)ret_var.inner;
8356         if (ret_var.is_owned) {
8357                 ret_ref |= 1;
8358         }
8359         return ret_ref;
8360 }
8361
8362 int8_tArray UpdateFailHTLC_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8363         LDKUpdateFailHTLC this_ptr_conv;
8364         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8365         this_ptr_conv.is_owned = false;
8366         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8367         memcpy(ret_arr.ptr, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
8368         return ret_arr;
8369 }
8370
8371 void UpdateFailHTLC_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8372         LDKUpdateFailHTLC this_ptr_conv;
8373         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8374         this_ptr_conv.is_owned = false;
8375         LDKThirtyTwoBytes val_ref;
8376         CHECK(val.len == 32);
8377         memcpy(val_ref.data, val.ptr, 32);
8378         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
8379 }
8380
8381 int64_t UpdateFailHTLC_1get_1htlc_1id(void* ctx_TODO, uint32_t this_ptr) {
8382         LDKUpdateFailHTLC this_ptr_conv;
8383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8384         this_ptr_conv.is_owned = false;
8385         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
8386         return ret_val;
8387 }
8388
8389 void UpdateFailHTLC_1set_1htlc_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8390         LDKUpdateFailHTLC this_ptr_conv;
8391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8392         this_ptr_conv.is_owned = false;
8393         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
8394 }
8395
8396 void UpdateFailMalformedHTLC_1free(void* ctx_TODO, uint32_t this_ptr) {
8397         LDKUpdateFailMalformedHTLC 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         UpdateFailMalformedHTLC_free(this_ptr_conv);
8401 }
8402
8403 uint32_t UpdateFailMalformedHTLC_1clone(void* ctx_TODO, uint32_t orig) {
8404         LDKUpdateFailMalformedHTLC orig_conv;
8405         orig_conv.inner = (void*)(orig & (~1));
8406         orig_conv.is_owned = false;
8407         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_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 UpdateFailMalformedHTLC_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8418         LDKUpdateFailMalformedHTLC this_ptr_conv;
8419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8420         this_ptr_conv.is_owned = false;
8421         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8422         memcpy(ret_arr.ptr, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
8423         return ret_arr;
8424 }
8425
8426 void UpdateFailMalformedHTLC_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8427         LDKUpdateFailMalformedHTLC 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(val.len == 32);
8432         memcpy(val_ref.data, val.ptr, 32);
8433         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
8434 }
8435
8436 int64_t UpdateFailMalformedHTLC_1get_1htlc_1id(void* ctx_TODO, uint32_t this_ptr) {
8437         LDKUpdateFailMalformedHTLC this_ptr_conv;
8438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8439         this_ptr_conv.is_owned = false;
8440         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
8441         return ret_val;
8442 }
8443
8444 void UpdateFailMalformedHTLC_1set_1htlc_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8445         LDKUpdateFailMalformedHTLC this_ptr_conv;
8446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8447         this_ptr_conv.is_owned = false;
8448         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
8449 }
8450
8451 jshort UpdateFailMalformedHTLC_1get_1failure_1code(void* ctx_TODO, uint32_t this_ptr) {
8452         LDKUpdateFailMalformedHTLC this_ptr_conv;
8453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8454         this_ptr_conv.is_owned = false;
8455         jshort ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
8456         return ret_val;
8457 }
8458
8459 void UpdateFailMalformedHTLC_1set_1failure_1code(void* ctx_TODO, uint32_t this_ptr, jshort val) {
8460         LDKUpdateFailMalformedHTLC this_ptr_conv;
8461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8462         this_ptr_conv.is_owned = false;
8463         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
8464 }
8465
8466 void CommitmentSigned_1free(void* ctx_TODO, uint32_t this_ptr) {
8467         LDKCommitmentSigned this_ptr_conv;
8468         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8469         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8470         CommitmentSigned_free(this_ptr_conv);
8471 }
8472
8473 uint32_t CommitmentSigned_1clone(void* ctx_TODO, uint32_t orig) {
8474         LDKCommitmentSigned orig_conv;
8475         orig_conv.inner = (void*)(orig & (~1));
8476         orig_conv.is_owned = false;
8477         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
8478         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8479         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8480         long ret_ref = (long)ret_var.inner;
8481         if (ret_var.is_owned) {
8482                 ret_ref |= 1;
8483         }
8484         return ret_ref;
8485 }
8486
8487 int8_tArray CommitmentSigned_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8488         LDKCommitmentSigned this_ptr_conv;
8489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8490         this_ptr_conv.is_owned = false;
8491         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8492         memcpy(ret_arr.ptr, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
8493         return ret_arr;
8494 }
8495
8496 void CommitmentSigned_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8497         LDKCommitmentSigned this_ptr_conv;
8498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8499         this_ptr_conv.is_owned = false;
8500         LDKThirtyTwoBytes val_ref;
8501         CHECK(val.len == 32);
8502         memcpy(val_ref.data, val.ptr, 32);
8503         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
8504 }
8505
8506 int8_tArray CommitmentSigned_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
8507         LDKCommitmentSigned this_ptr_conv;
8508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8509         this_ptr_conv.is_owned = false;
8510         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
8511         memcpy(arg_arr.ptr, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
8512         return arg_arr;
8513 }
8514
8515 void CommitmentSigned_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8516         LDKCommitmentSigned this_ptr_conv;
8517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8518         this_ptr_conv.is_owned = false;
8519         LDKSignature val_ref;
8520         CHECK(val.len == 64);
8521         memcpy(val_ref.compact_form, val.ptr, 64);
8522         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
8523 }
8524
8525 void CommitmentSigned_1set_1htlc_1signatures(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
8526         LDKCommitmentSigned this_ptr_conv;
8527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8528         this_ptr_conv.is_owned = false;
8529         LDKCVec_SignatureZ val_constr;
8530         val_constr.datalen = val.len;
8531         if (val_constr.datalen > 0)
8532                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8533         else
8534                 val_constr.data = NULL;
8535         int8_tArray* val_vals = (int8_tArray*) val.ptr;
8536         for (size_t i = 0; i < val_constr.datalen; i++) {
8537                 int8_tArray arr_conv_8 = val_vals[i];
8538                 LDKSignature arr_conv_8_ref;
8539                 CHECK(arr_conv_8.len == 64);
8540                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
8541                 val_constr.data[i] = arr_conv_8_ref;
8542         }
8543         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
8544 }
8545
8546 uint32_t CommitmentSigned_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray signature_arg, uint32_tArray htlc_signatures_arg) {
8547         LDKThirtyTwoBytes channel_id_arg_ref;
8548         CHECK(channel_id_arg.len == 32);
8549         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8550         LDKSignature signature_arg_ref;
8551         CHECK(signature_arg.len == 64);
8552         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
8553         LDKCVec_SignatureZ htlc_signatures_arg_constr;
8554         htlc_signatures_arg_constr.datalen = htlc_signatures_arg.len;
8555         if (htlc_signatures_arg_constr.datalen > 0)
8556                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
8557         else
8558                 htlc_signatures_arg_constr.data = NULL;
8559         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*) htlc_signatures_arg.ptr;
8560         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
8561                 int8_tArray arr_conv_8 = htlc_signatures_arg_vals[i];
8562                 LDKSignature arr_conv_8_ref;
8563                 CHECK(arr_conv_8.len == 64);
8564                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
8565                 htlc_signatures_arg_constr.data[i] = arr_conv_8_ref;
8566         }
8567         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
8568         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8569         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8570         long ret_ref = (long)ret_var.inner;
8571         if (ret_var.is_owned) {
8572                 ret_ref |= 1;
8573         }
8574         return ret_ref;
8575 }
8576
8577 void RevokeAndACK_1free(void* ctx_TODO, uint32_t this_ptr) {
8578         LDKRevokeAndACK this_ptr_conv;
8579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8580         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8581         RevokeAndACK_free(this_ptr_conv);
8582 }
8583
8584 uint32_t RevokeAndACK_1clone(void* ctx_TODO, uint32_t orig) {
8585         LDKRevokeAndACK orig_conv;
8586         orig_conv.inner = (void*)(orig & (~1));
8587         orig_conv.is_owned = false;
8588         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
8589         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8590         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8591         long ret_ref = (long)ret_var.inner;
8592         if (ret_var.is_owned) {
8593                 ret_ref |= 1;
8594         }
8595         return ret_ref;
8596 }
8597
8598 int8_tArray RevokeAndACK_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8599         LDKRevokeAndACK this_ptr_conv;
8600         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8601         this_ptr_conv.is_owned = false;
8602         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8603         memcpy(ret_arr.ptr, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
8604         return ret_arr;
8605 }
8606
8607 void RevokeAndACK_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8608         LDKRevokeAndACK this_ptr_conv;
8609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8610         this_ptr_conv.is_owned = false;
8611         LDKThirtyTwoBytes val_ref;
8612         CHECK(val.len == 32);
8613         memcpy(val_ref.data, val.ptr, 32);
8614         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
8615 }
8616
8617 int8_tArray RevokeAndACK_1get_1per_1commitment_1secret(void* ctx_TODO, uint32_t this_ptr) {
8618         LDKRevokeAndACK this_ptr_conv;
8619         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8620         this_ptr_conv.is_owned = false;
8621         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8622         memcpy(ret_arr.ptr, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
8623         return ret_arr;
8624 }
8625
8626 void RevokeAndACK_1set_1per_1commitment_1secret(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8627         LDKRevokeAndACK this_ptr_conv;
8628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8629         this_ptr_conv.is_owned = false;
8630         LDKThirtyTwoBytes val_ref;
8631         CHECK(val.len == 32);
8632         memcpy(val_ref.data, val.ptr, 32);
8633         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
8634 }
8635
8636 int8_tArray RevokeAndACK_1get_1next_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
8637         LDKRevokeAndACK this_ptr_conv;
8638         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8639         this_ptr_conv.is_owned = false;
8640         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8641         memcpy(arg_arr.ptr, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
8642         return arg_arr;
8643 }
8644
8645 void RevokeAndACK_1set_1next_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8646         LDKRevokeAndACK this_ptr_conv;
8647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8648         this_ptr_conv.is_owned = false;
8649         LDKPublicKey val_ref;
8650         CHECK(val.len == 33);
8651         memcpy(val_ref.compressed_form, val.ptr, 33);
8652         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
8653 }
8654
8655 uint32_t RevokeAndACK_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
8656         LDKThirtyTwoBytes channel_id_arg_ref;
8657         CHECK(channel_id_arg.len == 32);
8658         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8659         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
8660         CHECK(per_commitment_secret_arg.len == 32);
8661         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg.ptr, 32);
8662         LDKPublicKey next_per_commitment_point_arg_ref;
8663         CHECK(next_per_commitment_point_arg.len == 33);
8664         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg.ptr, 33);
8665         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
8666         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8667         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8668         long ret_ref = (long)ret_var.inner;
8669         if (ret_var.is_owned) {
8670                 ret_ref |= 1;
8671         }
8672         return ret_ref;
8673 }
8674
8675 void UpdateFee_1free(void* ctx_TODO, uint32_t this_ptr) {
8676         LDKUpdateFee this_ptr_conv;
8677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8678         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8679         UpdateFee_free(this_ptr_conv);
8680 }
8681
8682 uint32_t UpdateFee_1clone(void* ctx_TODO, uint32_t orig) {
8683         LDKUpdateFee orig_conv;
8684         orig_conv.inner = (void*)(orig & (~1));
8685         orig_conv.is_owned = false;
8686         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
8687         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8688         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8689         long ret_ref = (long)ret_var.inner;
8690         if (ret_var.is_owned) {
8691                 ret_ref |= 1;
8692         }
8693         return ret_ref;
8694 }
8695
8696 int8_tArray UpdateFee_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8697         LDKUpdateFee this_ptr_conv;
8698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8699         this_ptr_conv.is_owned = false;
8700         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8701         memcpy(ret_arr.ptr, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
8702         return ret_arr;
8703 }
8704
8705 void UpdateFee_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8706         LDKUpdateFee this_ptr_conv;
8707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8708         this_ptr_conv.is_owned = false;
8709         LDKThirtyTwoBytes val_ref;
8710         CHECK(val.len == 32);
8711         memcpy(val_ref.data, val.ptr, 32);
8712         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
8713 }
8714
8715 int32_t UpdateFee_1get_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_ptr) {
8716         LDKUpdateFee this_ptr_conv;
8717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8718         this_ptr_conv.is_owned = false;
8719         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
8720         return ret_val;
8721 }
8722
8723 void UpdateFee_1set_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
8724         LDKUpdateFee this_ptr_conv;
8725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8726         this_ptr_conv.is_owned = false;
8727         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
8728 }
8729
8730 uint32_t UpdateFee_1new(void* ctx_TODO, int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
8731         LDKThirtyTwoBytes channel_id_arg_ref;
8732         CHECK(channel_id_arg.len == 32);
8733         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8734         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
8735         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8736         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8737         long ret_ref = (long)ret_var.inner;
8738         if (ret_var.is_owned) {
8739                 ret_ref |= 1;
8740         }
8741         return ret_ref;
8742 }
8743
8744 void DataLossProtect_1free(void* ctx_TODO, uint32_t this_ptr) {
8745         LDKDataLossProtect this_ptr_conv;
8746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8747         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8748         DataLossProtect_free(this_ptr_conv);
8749 }
8750
8751 uint32_t DataLossProtect_1clone(void* ctx_TODO, uint32_t orig) {
8752         LDKDataLossProtect orig_conv;
8753         orig_conv.inner = (void*)(orig & (~1));
8754         orig_conv.is_owned = false;
8755         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
8756         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8757         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8758         long ret_ref = (long)ret_var.inner;
8759         if (ret_var.is_owned) {
8760                 ret_ref |= 1;
8761         }
8762         return ret_ref;
8763 }
8764
8765 int8_tArray DataLossProtect_1get_1your_1last_1per_1commitment_1secret(void* ctx_TODO, uint32_t this_ptr) {
8766         LDKDataLossProtect this_ptr_conv;
8767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8768         this_ptr_conv.is_owned = false;
8769         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8770         memcpy(ret_arr.ptr, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
8771         return ret_arr;
8772 }
8773
8774 void DataLossProtect_1set_1your_1last_1per_1commitment_1secret(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8775         LDKDataLossProtect this_ptr_conv;
8776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8777         this_ptr_conv.is_owned = false;
8778         LDKThirtyTwoBytes val_ref;
8779         CHECK(val.len == 32);
8780         memcpy(val_ref.data, val.ptr, 32);
8781         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
8782 }
8783
8784 int8_tArray DataLossProtect_1get_1my_1current_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
8785         LDKDataLossProtect this_ptr_conv;
8786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8787         this_ptr_conv.is_owned = false;
8788         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8789         memcpy(arg_arr.ptr, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
8790         return arg_arr;
8791 }
8792
8793 void DataLossProtect_1set_1my_1current_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8794         LDKDataLossProtect this_ptr_conv;
8795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8796         this_ptr_conv.is_owned = false;
8797         LDKPublicKey val_ref;
8798         CHECK(val.len == 33);
8799         memcpy(val_ref.compressed_form, val.ptr, 33);
8800         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
8801 }
8802
8803 uint32_t DataLossProtect_1new(void* ctx_TODO, int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
8804         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
8805         CHECK(your_last_per_commitment_secret_arg.len == 32);
8806         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg.ptr, 32);
8807         LDKPublicKey my_current_per_commitment_point_arg_ref;
8808         CHECK(my_current_per_commitment_point_arg.len == 33);
8809         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, my_current_per_commitment_point_arg.ptr, 33);
8810         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
8811         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8812         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8813         long ret_ref = (long)ret_var.inner;
8814         if (ret_var.is_owned) {
8815                 ret_ref |= 1;
8816         }
8817         return ret_ref;
8818 }
8819
8820 void ChannelReestablish_1free(void* ctx_TODO, uint32_t this_ptr) {
8821         LDKChannelReestablish this_ptr_conv;
8822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8823         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8824         ChannelReestablish_free(this_ptr_conv);
8825 }
8826
8827 uint32_t ChannelReestablish_1clone(void* ctx_TODO, uint32_t orig) {
8828         LDKChannelReestablish orig_conv;
8829         orig_conv.inner = (void*)(orig & (~1));
8830         orig_conv.is_owned = false;
8831         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
8832         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8833         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8834         long ret_ref = (long)ret_var.inner;
8835         if (ret_var.is_owned) {
8836                 ret_ref |= 1;
8837         }
8838         return ret_ref;
8839 }
8840
8841 int8_tArray ChannelReestablish_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8842         LDKChannelReestablish this_ptr_conv;
8843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8844         this_ptr_conv.is_owned = false;
8845         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8846         memcpy(ret_arr.ptr, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
8847         return ret_arr;
8848 }
8849
8850 void ChannelReestablish_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8851         LDKChannelReestablish this_ptr_conv;
8852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8853         this_ptr_conv.is_owned = false;
8854         LDKThirtyTwoBytes val_ref;
8855         CHECK(val.len == 32);
8856         memcpy(val_ref.data, val.ptr, 32);
8857         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
8858 }
8859
8860 int64_t ChannelReestablish_1get_1next_1local_1commitment_1number(void* ctx_TODO, uint32_t this_ptr) {
8861         LDKChannelReestablish this_ptr_conv;
8862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8863         this_ptr_conv.is_owned = false;
8864         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
8865         return ret_val;
8866 }
8867
8868 void ChannelReestablish_1set_1next_1local_1commitment_1number(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8869         LDKChannelReestablish this_ptr_conv;
8870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8871         this_ptr_conv.is_owned = false;
8872         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
8873 }
8874
8875 int64_t ChannelReestablish_1get_1next_1remote_1commitment_1number(void* ctx_TODO, uint32_t this_ptr) {
8876         LDKChannelReestablish this_ptr_conv;
8877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8878         this_ptr_conv.is_owned = false;
8879         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
8880         return ret_val;
8881 }
8882
8883 void ChannelReestablish_1set_1next_1remote_1commitment_1number(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8884         LDKChannelReestablish this_ptr_conv;
8885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8886         this_ptr_conv.is_owned = false;
8887         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
8888 }
8889
8890 void AnnouncementSignatures_1free(void* ctx_TODO, uint32_t this_ptr) {
8891         LDKAnnouncementSignatures this_ptr_conv;
8892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8893         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8894         AnnouncementSignatures_free(this_ptr_conv);
8895 }
8896
8897 uint32_t AnnouncementSignatures_1clone(void* ctx_TODO, uint32_t orig) {
8898         LDKAnnouncementSignatures orig_conv;
8899         orig_conv.inner = (void*)(orig & (~1));
8900         orig_conv.is_owned = false;
8901         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
8902         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8903         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8904         long ret_ref = (long)ret_var.inner;
8905         if (ret_var.is_owned) {
8906                 ret_ref |= 1;
8907         }
8908         return ret_ref;
8909 }
8910
8911 int8_tArray AnnouncementSignatures_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8912         LDKAnnouncementSignatures this_ptr_conv;
8913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8914         this_ptr_conv.is_owned = false;
8915         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8916         memcpy(ret_arr.ptr, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
8917         return ret_arr;
8918 }
8919
8920 void AnnouncementSignatures_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8921         LDKAnnouncementSignatures this_ptr_conv;
8922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8923         this_ptr_conv.is_owned = false;
8924         LDKThirtyTwoBytes val_ref;
8925         CHECK(val.len == 32);
8926         memcpy(val_ref.data, val.ptr, 32);
8927         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
8928 }
8929
8930 int64_t AnnouncementSignatures_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8931         LDKAnnouncementSignatures this_ptr_conv;
8932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8933         this_ptr_conv.is_owned = false;
8934         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
8935         return ret_val;
8936 }
8937
8938 void AnnouncementSignatures_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8939         LDKAnnouncementSignatures this_ptr_conv;
8940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8941         this_ptr_conv.is_owned = false;
8942         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
8943 }
8944
8945 int8_tArray AnnouncementSignatures_1get_1node_1signature(void* ctx_TODO, uint32_t this_ptr) {
8946         LDKAnnouncementSignatures this_ptr_conv;
8947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8948         this_ptr_conv.is_owned = false;
8949         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
8950         memcpy(arg_arr.ptr, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
8951         return arg_arr;
8952 }
8953
8954 void AnnouncementSignatures_1set_1node_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8955         LDKAnnouncementSignatures this_ptr_conv;
8956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8957         this_ptr_conv.is_owned = false;
8958         LDKSignature val_ref;
8959         CHECK(val.len == 64);
8960         memcpy(val_ref.compact_form, val.ptr, 64);
8961         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
8962 }
8963
8964 int8_tArray AnnouncementSignatures_1get_1bitcoin_1signature(void* ctx_TODO, uint32_t this_ptr) {
8965         LDKAnnouncementSignatures this_ptr_conv;
8966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8967         this_ptr_conv.is_owned = false;
8968         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
8969         memcpy(arg_arr.ptr, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
8970         return arg_arr;
8971 }
8972
8973 void AnnouncementSignatures_1set_1bitcoin_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8974         LDKAnnouncementSignatures this_ptr_conv;
8975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8976         this_ptr_conv.is_owned = false;
8977         LDKSignature val_ref;
8978         CHECK(val.len == 64);
8979         memcpy(val_ref.compact_form, val.ptr, 64);
8980         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
8981 }
8982
8983 uint32_t AnnouncementSignatures_1new(void* ctx_TODO, int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
8984         LDKThirtyTwoBytes channel_id_arg_ref;
8985         CHECK(channel_id_arg.len == 32);
8986         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8987         LDKSignature node_signature_arg_ref;
8988         CHECK(node_signature_arg.len == 64);
8989         memcpy(node_signature_arg_ref.compact_form, node_signature_arg.ptr, 64);
8990         LDKSignature bitcoin_signature_arg_ref;
8991         CHECK(bitcoin_signature_arg.len == 64);
8992         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg.ptr, 64);
8993         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
8994         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8995         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8996         long ret_ref = (long)ret_var.inner;
8997         if (ret_var.is_owned) {
8998                 ret_ref |= 1;
8999         }
9000         return ret_ref;
9001 }
9002
9003 void NetAddress_1free(void* ctx_TODO, uint32_t this_ptr) {
9004         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
9005         FREE((void*)this_ptr);
9006         NetAddress_free(this_ptr_conv);
9007 }
9008
9009 uint32_t NetAddress_1clone(void* ctx_TODO, uint32_t orig) {
9010         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
9011         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9012         *ret_copy = NetAddress_clone(orig_conv);
9013         long ret_ref = (long)ret_copy;
9014         return ret_ref;
9015 }
9016
9017 int8_tArray NetAddress_1write(void* ctx_TODO, uint32_t obj) {
9018         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
9019         LDKCVec_u8Z arg_var = NetAddress_write(obj_conv);
9020         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
9021         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
9022         CVec_u8Z_free(arg_var);
9023         return arg_arr;
9024 }
9025
9026 uint32_t Result_1read(void* ctx_TODO, int8_tArray ser) {
9027         LDKu8slice ser_ref;
9028         ser_ref.datalen = ser.len;
9029         ser_ref.data = ser.ptr;
9030         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9031         *ret_conv = Result_read(ser_ref);
9032         return (long)ret_conv;
9033 }
9034
9035 void UnsignedNodeAnnouncement_1free(void* ctx_TODO, uint32_t this_ptr) {
9036         LDKUnsignedNodeAnnouncement this_ptr_conv;
9037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9038         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9039         UnsignedNodeAnnouncement_free(this_ptr_conv);
9040 }
9041
9042 uint32_t UnsignedNodeAnnouncement_1clone(void* ctx_TODO, uint32_t orig) {
9043         LDKUnsignedNodeAnnouncement orig_conv;
9044         orig_conv.inner = (void*)(orig & (~1));
9045         orig_conv.is_owned = false;
9046         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
9047         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9048         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9049         long ret_ref = (long)ret_var.inner;
9050         if (ret_var.is_owned) {
9051                 ret_ref |= 1;
9052         }
9053         return ret_ref;
9054 }
9055
9056 uint32_t UnsignedNodeAnnouncement_1get_1features(void* ctx_TODO, uint32_t this_ptr) {
9057         LDKUnsignedNodeAnnouncement this_ptr_conv;
9058         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9059         this_ptr_conv.is_owned = false;
9060         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
9061         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9062         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9063         long ret_ref = (long)ret_var.inner;
9064         if (ret_var.is_owned) {
9065                 ret_ref |= 1;
9066         }
9067         return ret_ref;
9068 }
9069
9070 void UnsignedNodeAnnouncement_1set_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
9071         LDKUnsignedNodeAnnouncement this_ptr_conv;
9072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9073         this_ptr_conv.is_owned = false;
9074         LDKNodeFeatures val_conv;
9075         val_conv.inner = (void*)(val & (~1));
9076         val_conv.is_owned = (val & 1) || (val == 0);
9077         // Warning: we may need a move here but can't clone!
9078         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
9079 }
9080
9081 int32_t UnsignedNodeAnnouncement_1get_1timestamp(void* ctx_TODO, uint32_t this_ptr) {
9082         LDKUnsignedNodeAnnouncement this_ptr_conv;
9083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9084         this_ptr_conv.is_owned = false;
9085         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
9086         return ret_val;
9087 }
9088
9089 void UnsignedNodeAnnouncement_1set_1timestamp(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9090         LDKUnsignedNodeAnnouncement this_ptr_conv;
9091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9092         this_ptr_conv.is_owned = false;
9093         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
9094 }
9095
9096 int8_tArray UnsignedNodeAnnouncement_1get_1node_1id(void* ctx_TODO, uint32_t this_ptr) {
9097         LDKUnsignedNodeAnnouncement this_ptr_conv;
9098         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9099         this_ptr_conv.is_owned = false;
9100         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9101         memcpy(arg_arr.ptr, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
9102         return arg_arr;
9103 }
9104
9105 void UnsignedNodeAnnouncement_1set_1node_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9106         LDKUnsignedNodeAnnouncement this_ptr_conv;
9107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9108         this_ptr_conv.is_owned = false;
9109         LDKPublicKey val_ref;
9110         CHECK(val.len == 33);
9111         memcpy(val_ref.compressed_form, val.ptr, 33);
9112         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
9113 }
9114
9115 int8_tArray UnsignedNodeAnnouncement_1get_1rgb(void* ctx_TODO, uint32_t this_ptr) {
9116         LDKUnsignedNodeAnnouncement this_ptr_conv;
9117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9118         this_ptr_conv.is_owned = false;
9119         int8_tArray ret_arr = { .len = 3, .ptr = MALLOC(3, "Native int8_tArray Bytes") };
9120         memcpy(ret_arr.ptr, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
9121         return ret_arr;
9122 }
9123
9124 void UnsignedNodeAnnouncement_1set_1rgb(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9125         LDKUnsignedNodeAnnouncement this_ptr_conv;
9126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9127         this_ptr_conv.is_owned = false;
9128         LDKThreeBytes val_ref;
9129         CHECK(val.len == 3);
9130         memcpy(val_ref.data, val.ptr, 3);
9131         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
9132 }
9133
9134 int8_tArray UnsignedNodeAnnouncement_1get_1alias(void* ctx_TODO, uint32_t this_ptr) {
9135         LDKUnsignedNodeAnnouncement this_ptr_conv;
9136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9137         this_ptr_conv.is_owned = false;
9138         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9139         memcpy(ret_arr.ptr, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
9140         return ret_arr;
9141 }
9142
9143 void UnsignedNodeAnnouncement_1set_1alias(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9144         LDKUnsignedNodeAnnouncement this_ptr_conv;
9145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9146         this_ptr_conv.is_owned = false;
9147         LDKThirtyTwoBytes val_ref;
9148         CHECK(val.len == 32);
9149         memcpy(val_ref.data, val.ptr, 32);
9150         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
9151 }
9152
9153 void UnsignedNodeAnnouncement_1set_1addresses(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
9154         LDKUnsignedNodeAnnouncement this_ptr_conv;
9155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9156         this_ptr_conv.is_owned = false;
9157         LDKCVec_NetAddressZ val_constr;
9158         val_constr.datalen = val.len;
9159         if (val_constr.datalen > 0)
9160                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
9161         else
9162                 val_constr.data = NULL;
9163         uint32_t* val_vals = (uint32_t*) val.ptr;
9164         for (size_t m = 0; m < val_constr.datalen; m++) {
9165                 uint32_t arr_conv_12 = val_vals[m];
9166                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
9167                 FREE((void*)arr_conv_12);
9168                 val_constr.data[m] = arr_conv_12_conv;
9169         }
9170         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
9171 }
9172
9173 void NodeAnnouncement_1free(void* ctx_TODO, uint32_t this_ptr) {
9174         LDKNodeAnnouncement this_ptr_conv;
9175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9176         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9177         NodeAnnouncement_free(this_ptr_conv);
9178 }
9179
9180 uint32_t NodeAnnouncement_1clone(void* ctx_TODO, uint32_t orig) {
9181         LDKNodeAnnouncement orig_conv;
9182         orig_conv.inner = (void*)(orig & (~1));
9183         orig_conv.is_owned = false;
9184         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
9185         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9186         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9187         long ret_ref = (long)ret_var.inner;
9188         if (ret_var.is_owned) {
9189                 ret_ref |= 1;
9190         }
9191         return ret_ref;
9192 }
9193
9194 int8_tArray NodeAnnouncement_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
9195         LDKNodeAnnouncement this_ptr_conv;
9196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9197         this_ptr_conv.is_owned = false;
9198         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9199         memcpy(arg_arr.ptr, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
9200         return arg_arr;
9201 }
9202
9203 void NodeAnnouncement_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9204         LDKNodeAnnouncement this_ptr_conv;
9205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9206         this_ptr_conv.is_owned = false;
9207         LDKSignature val_ref;
9208         CHECK(val.len == 64);
9209         memcpy(val_ref.compact_form, val.ptr, 64);
9210         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
9211 }
9212
9213 uint32_t NodeAnnouncement_1get_1contents(void* ctx_TODO, uint32_t this_ptr) {
9214         LDKNodeAnnouncement this_ptr_conv;
9215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9216         this_ptr_conv.is_owned = false;
9217         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
9218         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9219         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9220         long ret_ref = (long)ret_var.inner;
9221         if (ret_var.is_owned) {
9222                 ret_ref |= 1;
9223         }
9224         return ret_ref;
9225 }
9226
9227 void NodeAnnouncement_1set_1contents(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
9228         LDKNodeAnnouncement this_ptr_conv;
9229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9230         this_ptr_conv.is_owned = false;
9231         LDKUnsignedNodeAnnouncement val_conv;
9232         val_conv.inner = (void*)(val & (~1));
9233         val_conv.is_owned = (val & 1) || (val == 0);
9234         if (val_conv.inner != NULL)
9235                 val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
9236         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
9237 }
9238
9239 uint32_t NodeAnnouncement_1new(void* ctx_TODO, int8_tArray signature_arg, uint32_t contents_arg) {
9240         LDKSignature signature_arg_ref;
9241         CHECK(signature_arg.len == 64);
9242         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
9243         LDKUnsignedNodeAnnouncement contents_arg_conv;
9244         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9245         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9246         if (contents_arg_conv.inner != NULL)
9247                 contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
9248         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
9249         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9250         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9251         long ret_ref = (long)ret_var.inner;
9252         if (ret_var.is_owned) {
9253                 ret_ref |= 1;
9254         }
9255         return ret_ref;
9256 }
9257
9258 void UnsignedChannelAnnouncement_1free(void* ctx_TODO, uint32_t this_ptr) {
9259         LDKUnsignedChannelAnnouncement this_ptr_conv;
9260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9261         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9262         UnsignedChannelAnnouncement_free(this_ptr_conv);
9263 }
9264
9265 uint32_t UnsignedChannelAnnouncement_1clone(void* ctx_TODO, uint32_t orig) {
9266         LDKUnsignedChannelAnnouncement orig_conv;
9267         orig_conv.inner = (void*)(orig & (~1));
9268         orig_conv.is_owned = false;
9269         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
9270         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9271         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9272         long ret_ref = (long)ret_var.inner;
9273         if (ret_var.is_owned) {
9274                 ret_ref |= 1;
9275         }
9276         return ret_ref;
9277 }
9278
9279 uint32_t UnsignedChannelAnnouncement_1get_1features(void* ctx_TODO, uint32_t this_ptr) {
9280         LDKUnsignedChannelAnnouncement this_ptr_conv;
9281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9282         this_ptr_conv.is_owned = false;
9283         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
9284         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9285         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9286         long ret_ref = (long)ret_var.inner;
9287         if (ret_var.is_owned) {
9288                 ret_ref |= 1;
9289         }
9290         return ret_ref;
9291 }
9292
9293 void UnsignedChannelAnnouncement_1set_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
9294         LDKUnsignedChannelAnnouncement this_ptr_conv;
9295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9296         this_ptr_conv.is_owned = false;
9297         LDKChannelFeatures val_conv;
9298         val_conv.inner = (void*)(val & (~1));
9299         val_conv.is_owned = (val & 1) || (val == 0);
9300         // Warning: we may need a move here but can't clone!
9301         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
9302 }
9303
9304 int8_tArray UnsignedChannelAnnouncement_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
9305         LDKUnsignedChannelAnnouncement this_ptr_conv;
9306         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9307         this_ptr_conv.is_owned = false;
9308         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9309         memcpy(ret_arr.ptr, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
9310         return ret_arr;
9311 }
9312
9313 void UnsignedChannelAnnouncement_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9314         LDKUnsignedChannelAnnouncement this_ptr_conv;
9315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9316         this_ptr_conv.is_owned = false;
9317         LDKThirtyTwoBytes val_ref;
9318         CHECK(val.len == 32);
9319         memcpy(val_ref.data, val.ptr, 32);
9320         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
9321 }
9322
9323 int64_t UnsignedChannelAnnouncement_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9324         LDKUnsignedChannelAnnouncement this_ptr_conv;
9325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9326         this_ptr_conv.is_owned = false;
9327         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
9328         return ret_val;
9329 }
9330
9331 void UnsignedChannelAnnouncement_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9332         LDKUnsignedChannelAnnouncement this_ptr_conv;
9333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9334         this_ptr_conv.is_owned = false;
9335         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
9336 }
9337
9338 int8_tArray UnsignedChannelAnnouncement_1get_1node_1id_11(void* ctx_TODO, uint32_t this_ptr) {
9339         LDKUnsignedChannelAnnouncement this_ptr_conv;
9340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9341         this_ptr_conv.is_owned = false;
9342         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9343         memcpy(arg_arr.ptr, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
9344         return arg_arr;
9345 }
9346
9347 void UnsignedChannelAnnouncement_1set_1node_1id_11(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9348         LDKUnsignedChannelAnnouncement this_ptr_conv;
9349         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9350         this_ptr_conv.is_owned = false;
9351         LDKPublicKey val_ref;
9352         CHECK(val.len == 33);
9353         memcpy(val_ref.compressed_form, val.ptr, 33);
9354         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
9355 }
9356
9357 int8_tArray UnsignedChannelAnnouncement_1get_1node_1id_12(void* ctx_TODO, uint32_t this_ptr) {
9358         LDKUnsignedChannelAnnouncement this_ptr_conv;
9359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9360         this_ptr_conv.is_owned = false;
9361         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9362         memcpy(arg_arr.ptr, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
9363         return arg_arr;
9364 }
9365
9366 void UnsignedChannelAnnouncement_1set_1node_1id_12(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9367         LDKUnsignedChannelAnnouncement this_ptr_conv;
9368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9369         this_ptr_conv.is_owned = false;
9370         LDKPublicKey val_ref;
9371         CHECK(val.len == 33);
9372         memcpy(val_ref.compressed_form, val.ptr, 33);
9373         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
9374 }
9375
9376 int8_tArray UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(void* ctx_TODO, uint32_t this_ptr) {
9377         LDKUnsignedChannelAnnouncement this_ptr_conv;
9378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9379         this_ptr_conv.is_owned = false;
9380         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9381         memcpy(arg_arr.ptr, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
9382         return arg_arr;
9383 }
9384
9385 void UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9386         LDKUnsignedChannelAnnouncement this_ptr_conv;
9387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9388         this_ptr_conv.is_owned = false;
9389         LDKPublicKey val_ref;
9390         CHECK(val.len == 33);
9391         memcpy(val_ref.compressed_form, val.ptr, 33);
9392         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
9393 }
9394
9395 int8_tArray UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(void* ctx_TODO, uint32_t this_ptr) {
9396         LDKUnsignedChannelAnnouncement this_ptr_conv;
9397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9398         this_ptr_conv.is_owned = false;
9399         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9400         memcpy(arg_arr.ptr, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
9401         return arg_arr;
9402 }
9403
9404 void UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9405         LDKUnsignedChannelAnnouncement this_ptr_conv;
9406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9407         this_ptr_conv.is_owned = false;
9408         LDKPublicKey val_ref;
9409         CHECK(val.len == 33);
9410         memcpy(val_ref.compressed_form, val.ptr, 33);
9411         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
9412 }
9413
9414 void ChannelAnnouncement_1free(void* ctx_TODO, uint32_t this_ptr) {
9415         LDKChannelAnnouncement this_ptr_conv;
9416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9417         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9418         ChannelAnnouncement_free(this_ptr_conv);
9419 }
9420
9421 uint32_t ChannelAnnouncement_1clone(void* ctx_TODO, uint32_t orig) {
9422         LDKChannelAnnouncement orig_conv;
9423         orig_conv.inner = (void*)(orig & (~1));
9424         orig_conv.is_owned = false;
9425         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
9426         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9427         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9428         long ret_ref = (long)ret_var.inner;
9429         if (ret_var.is_owned) {
9430                 ret_ref |= 1;
9431         }
9432         return ret_ref;
9433 }
9434
9435 int8_tArray ChannelAnnouncement_1get_1node_1signature_11(void* ctx_TODO, uint32_t this_ptr) {
9436         LDKChannelAnnouncement this_ptr_conv;
9437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9438         this_ptr_conv.is_owned = false;
9439         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9440         memcpy(arg_arr.ptr, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
9441         return arg_arr;
9442 }
9443
9444 void ChannelAnnouncement_1set_1node_1signature_11(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9445         LDKChannelAnnouncement this_ptr_conv;
9446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9447         this_ptr_conv.is_owned = false;
9448         LDKSignature val_ref;
9449         CHECK(val.len == 64);
9450         memcpy(val_ref.compact_form, val.ptr, 64);
9451         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
9452 }
9453
9454 int8_tArray ChannelAnnouncement_1get_1node_1signature_12(void* ctx_TODO, uint32_t this_ptr) {
9455         LDKChannelAnnouncement this_ptr_conv;
9456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9457         this_ptr_conv.is_owned = false;
9458         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9459         memcpy(arg_arr.ptr, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
9460         return arg_arr;
9461 }
9462
9463 void ChannelAnnouncement_1set_1node_1signature_12(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9464         LDKChannelAnnouncement this_ptr_conv;
9465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9466         this_ptr_conv.is_owned = false;
9467         LDKSignature val_ref;
9468         CHECK(val.len == 64);
9469         memcpy(val_ref.compact_form, val.ptr, 64);
9470         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
9471 }
9472
9473 int8_tArray ChannelAnnouncement_1get_1bitcoin_1signature_11(void* ctx_TODO, uint32_t this_ptr) {
9474         LDKChannelAnnouncement this_ptr_conv;
9475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9476         this_ptr_conv.is_owned = false;
9477         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9478         memcpy(arg_arr.ptr, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
9479         return arg_arr;
9480 }
9481
9482 void ChannelAnnouncement_1set_1bitcoin_1signature_11(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9483         LDKChannelAnnouncement this_ptr_conv;
9484         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9485         this_ptr_conv.is_owned = false;
9486         LDKSignature val_ref;
9487         CHECK(val.len == 64);
9488         memcpy(val_ref.compact_form, val.ptr, 64);
9489         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
9490 }
9491
9492 int8_tArray ChannelAnnouncement_1get_1bitcoin_1signature_12(void* ctx_TODO, uint32_t this_ptr) {
9493         LDKChannelAnnouncement this_ptr_conv;
9494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9495         this_ptr_conv.is_owned = false;
9496         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9497         memcpy(arg_arr.ptr, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
9498         return arg_arr;
9499 }
9500
9501 void ChannelAnnouncement_1set_1bitcoin_1signature_12(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9502         LDKChannelAnnouncement this_ptr_conv;
9503         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9504         this_ptr_conv.is_owned = false;
9505         LDKSignature val_ref;
9506         CHECK(val.len == 64);
9507         memcpy(val_ref.compact_form, val.ptr, 64);
9508         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
9509 }
9510
9511 uint32_t ChannelAnnouncement_1get_1contents(void* ctx_TODO, uint32_t this_ptr) {
9512         LDKChannelAnnouncement this_ptr_conv;
9513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9514         this_ptr_conv.is_owned = false;
9515         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
9516         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9517         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9518         long ret_ref = (long)ret_var.inner;
9519         if (ret_var.is_owned) {
9520                 ret_ref |= 1;
9521         }
9522         return ret_ref;
9523 }
9524
9525 void ChannelAnnouncement_1set_1contents(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
9526         LDKChannelAnnouncement this_ptr_conv;
9527         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9528         this_ptr_conv.is_owned = false;
9529         LDKUnsignedChannelAnnouncement val_conv;
9530         val_conv.inner = (void*)(val & (~1));
9531         val_conv.is_owned = (val & 1) || (val == 0);
9532         if (val_conv.inner != NULL)
9533                 val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
9534         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
9535 }
9536
9537 uint32_t ChannelAnnouncement_1new(void* ctx_TODO, 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) {
9538         LDKSignature node_signature_1_arg_ref;
9539         CHECK(node_signature_1_arg.len == 64);
9540         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg.ptr, 64);
9541         LDKSignature node_signature_2_arg_ref;
9542         CHECK(node_signature_2_arg.len == 64);
9543         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg.ptr, 64);
9544         LDKSignature bitcoin_signature_1_arg_ref;
9545         CHECK(bitcoin_signature_1_arg.len == 64);
9546         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg.ptr, 64);
9547         LDKSignature bitcoin_signature_2_arg_ref;
9548         CHECK(bitcoin_signature_2_arg.len == 64);
9549         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg.ptr, 64);
9550         LDKUnsignedChannelAnnouncement contents_arg_conv;
9551         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9552         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9553         if (contents_arg_conv.inner != NULL)
9554                 contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
9555         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);
9556         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9557         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9558         long ret_ref = (long)ret_var.inner;
9559         if (ret_var.is_owned) {
9560                 ret_ref |= 1;
9561         }
9562         return ret_ref;
9563 }
9564
9565 void UnsignedChannelUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
9566         LDKUnsignedChannelUpdate this_ptr_conv;
9567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9568         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9569         UnsignedChannelUpdate_free(this_ptr_conv);
9570 }
9571
9572 uint32_t UnsignedChannelUpdate_1clone(void* ctx_TODO, uint32_t orig) {
9573         LDKUnsignedChannelUpdate orig_conv;
9574         orig_conv.inner = (void*)(orig & (~1));
9575         orig_conv.is_owned = false;
9576         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
9577         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9578         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9579         long ret_ref = (long)ret_var.inner;
9580         if (ret_var.is_owned) {
9581                 ret_ref |= 1;
9582         }
9583         return ret_ref;
9584 }
9585
9586 int8_tArray UnsignedChannelUpdate_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
9587         LDKUnsignedChannelUpdate this_ptr_conv;
9588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9589         this_ptr_conv.is_owned = false;
9590         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9591         memcpy(ret_arr.ptr, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
9592         return ret_arr;
9593 }
9594
9595 void UnsignedChannelUpdate_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9596         LDKUnsignedChannelUpdate this_ptr_conv;
9597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9598         this_ptr_conv.is_owned = false;
9599         LDKThirtyTwoBytes val_ref;
9600         CHECK(val.len == 32);
9601         memcpy(val_ref.data, val.ptr, 32);
9602         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
9603 }
9604
9605 int64_t UnsignedChannelUpdate_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9606         LDKUnsignedChannelUpdate this_ptr_conv;
9607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9608         this_ptr_conv.is_owned = false;
9609         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
9610         return ret_val;
9611 }
9612
9613 void UnsignedChannelUpdate_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9614         LDKUnsignedChannelUpdate this_ptr_conv;
9615         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9616         this_ptr_conv.is_owned = false;
9617         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
9618 }
9619
9620 int32_t UnsignedChannelUpdate_1get_1timestamp(void* ctx_TODO, uint32_t this_ptr) {
9621         LDKUnsignedChannelUpdate this_ptr_conv;
9622         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9623         this_ptr_conv.is_owned = false;
9624         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
9625         return ret_val;
9626 }
9627
9628 void UnsignedChannelUpdate_1set_1timestamp(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9629         LDKUnsignedChannelUpdate this_ptr_conv;
9630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9631         this_ptr_conv.is_owned = false;
9632         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
9633 }
9634
9635 int8_t UnsignedChannelUpdate_1get_1flags(void* ctx_TODO, uint32_t this_ptr) {
9636         LDKUnsignedChannelUpdate this_ptr_conv;
9637         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9638         this_ptr_conv.is_owned = false;
9639         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
9640         return ret_val;
9641 }
9642
9643 void UnsignedChannelUpdate_1set_1flags(void* ctx_TODO, uint32_t this_ptr, int8_t val) {
9644         LDKUnsignedChannelUpdate this_ptr_conv;
9645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9646         this_ptr_conv.is_owned = false;
9647         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
9648 }
9649
9650 jshort UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr) {
9651         LDKUnsignedChannelUpdate this_ptr_conv;
9652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9653         this_ptr_conv.is_owned = false;
9654         jshort ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
9655         return ret_val;
9656 }
9657
9658 void UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr, jshort val) {
9659         LDKUnsignedChannelUpdate this_ptr_conv;
9660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9661         this_ptr_conv.is_owned = false;
9662         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
9663 }
9664
9665 int64_t UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
9666         LDKUnsignedChannelUpdate this_ptr_conv;
9667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9668         this_ptr_conv.is_owned = false;
9669         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
9670         return ret_val;
9671 }
9672
9673 void UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9674         LDKUnsignedChannelUpdate this_ptr_conv;
9675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9676         this_ptr_conv.is_owned = false;
9677         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
9678 }
9679
9680 int32_t UnsignedChannelUpdate_1get_1fee_1base_1msat(void* ctx_TODO, uint32_t this_ptr) {
9681         LDKUnsignedChannelUpdate this_ptr_conv;
9682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9683         this_ptr_conv.is_owned = false;
9684         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
9685         return ret_val;
9686 }
9687
9688 void UnsignedChannelUpdate_1set_1fee_1base_1msat(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9689         LDKUnsignedChannelUpdate this_ptr_conv;
9690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9691         this_ptr_conv.is_owned = false;
9692         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
9693 }
9694
9695 int32_t UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr) {
9696         LDKUnsignedChannelUpdate this_ptr_conv;
9697         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9698         this_ptr_conv.is_owned = false;
9699         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
9700         return ret_val;
9701 }
9702
9703 void UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9704         LDKUnsignedChannelUpdate this_ptr_conv;
9705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9706         this_ptr_conv.is_owned = false;
9707         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
9708 }
9709
9710 void ChannelUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
9711         LDKChannelUpdate this_ptr_conv;
9712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9713         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9714         ChannelUpdate_free(this_ptr_conv);
9715 }
9716
9717 uint32_t ChannelUpdate_1clone(void* ctx_TODO, uint32_t orig) {
9718         LDKChannelUpdate orig_conv;
9719         orig_conv.inner = (void*)(orig & (~1));
9720         orig_conv.is_owned = false;
9721         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
9722         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9723         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9724         long ret_ref = (long)ret_var.inner;
9725         if (ret_var.is_owned) {
9726                 ret_ref |= 1;
9727         }
9728         return ret_ref;
9729 }
9730
9731 int8_tArray ChannelUpdate_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
9732         LDKChannelUpdate this_ptr_conv;
9733         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9734         this_ptr_conv.is_owned = false;
9735         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9736         memcpy(arg_arr.ptr, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
9737         return arg_arr;
9738 }
9739
9740 void ChannelUpdate_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9741         LDKChannelUpdate this_ptr_conv;
9742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9743         this_ptr_conv.is_owned = false;
9744         LDKSignature val_ref;
9745         CHECK(val.len == 64);
9746         memcpy(val_ref.compact_form, val.ptr, 64);
9747         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
9748 }
9749
9750 uint32_t ChannelUpdate_1get_1contents(void* ctx_TODO, uint32_t this_ptr) {
9751         LDKChannelUpdate this_ptr_conv;
9752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9753         this_ptr_conv.is_owned = false;
9754         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
9755         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9756         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9757         long ret_ref = (long)ret_var.inner;
9758         if (ret_var.is_owned) {
9759                 ret_ref |= 1;
9760         }
9761         return ret_ref;
9762 }
9763
9764 void ChannelUpdate_1set_1contents(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
9765         LDKChannelUpdate this_ptr_conv;
9766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9767         this_ptr_conv.is_owned = false;
9768         LDKUnsignedChannelUpdate val_conv;
9769         val_conv.inner = (void*)(val & (~1));
9770         val_conv.is_owned = (val & 1) || (val == 0);
9771         if (val_conv.inner != NULL)
9772                 val_conv = UnsignedChannelUpdate_clone(&val_conv);
9773         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
9774 }
9775
9776 uint32_t ChannelUpdate_1new(void* ctx_TODO, int8_tArray signature_arg, uint32_t contents_arg) {
9777         LDKSignature signature_arg_ref;
9778         CHECK(signature_arg.len == 64);
9779         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
9780         LDKUnsignedChannelUpdate contents_arg_conv;
9781         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9782         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9783         if (contents_arg_conv.inner != NULL)
9784                 contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
9785         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
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 QueryChannelRange_1free(void* ctx_TODO, uint32_t this_ptr) {
9796         LDKQueryChannelRange 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         QueryChannelRange_free(this_ptr_conv);
9800 }
9801
9802 uint32_t QueryChannelRange_1clone(void* ctx_TODO, uint32_t orig) {
9803         LDKQueryChannelRange orig_conv;
9804         orig_conv.inner = (void*)(orig & (~1));
9805         orig_conv.is_owned = false;
9806         LDKQueryChannelRange ret_var = QueryChannelRange_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 QueryChannelRange_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
9817         LDKQueryChannelRange this_ptr_conv;
9818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9819         this_ptr_conv.is_owned = false;
9820         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9821         memcpy(ret_arr.ptr, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
9822         return ret_arr;
9823 }
9824
9825 void QueryChannelRange_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9826         LDKQueryChannelRange 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(val.len == 32);
9831         memcpy(val_ref.data, val.ptr, 32);
9832         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
9833 }
9834
9835 int32_t QueryChannelRange_1get_1first_1blocknum(void* ctx_TODO, uint32_t this_ptr) {
9836         LDKQueryChannelRange this_ptr_conv;
9837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9838         this_ptr_conv.is_owned = false;
9839         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
9840         return ret_val;
9841 }
9842
9843 void QueryChannelRange_1set_1first_1blocknum(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9844         LDKQueryChannelRange this_ptr_conv;
9845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9846         this_ptr_conv.is_owned = false;
9847         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
9848 }
9849
9850 int32_t QueryChannelRange_1get_1number_1of_1blocks(void* ctx_TODO, uint32_t this_ptr) {
9851         LDKQueryChannelRange this_ptr_conv;
9852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9853         this_ptr_conv.is_owned = false;
9854         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
9855         return ret_val;
9856 }
9857
9858 void QueryChannelRange_1set_1number_1of_1blocks(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9859         LDKQueryChannelRange this_ptr_conv;
9860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9861         this_ptr_conv.is_owned = false;
9862         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
9863 }
9864
9865 uint32_t QueryChannelRange_1new(void* ctx_TODO, int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
9866         LDKThirtyTwoBytes chain_hash_arg_ref;
9867         CHECK(chain_hash_arg.len == 32);
9868         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
9869         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
9870         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9871         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9872         long ret_ref = (long)ret_var.inner;
9873         if (ret_var.is_owned) {
9874                 ret_ref |= 1;
9875         }
9876         return ret_ref;
9877 }
9878
9879 void ReplyChannelRange_1free(void* ctx_TODO, uint32_t this_ptr) {
9880         LDKReplyChannelRange this_ptr_conv;
9881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9882         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9883         ReplyChannelRange_free(this_ptr_conv);
9884 }
9885
9886 uint32_t ReplyChannelRange_1clone(void* ctx_TODO, uint32_t orig) {
9887         LDKReplyChannelRange orig_conv;
9888         orig_conv.inner = (void*)(orig & (~1));
9889         orig_conv.is_owned = false;
9890         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
9891         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9892         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9893         long ret_ref = (long)ret_var.inner;
9894         if (ret_var.is_owned) {
9895                 ret_ref |= 1;
9896         }
9897         return ret_ref;
9898 }
9899
9900 int8_tArray ReplyChannelRange_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
9901         LDKReplyChannelRange this_ptr_conv;
9902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9903         this_ptr_conv.is_owned = false;
9904         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9905         memcpy(ret_arr.ptr, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
9906         return ret_arr;
9907 }
9908
9909 void ReplyChannelRange_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9910         LDKReplyChannelRange this_ptr_conv;
9911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9912         this_ptr_conv.is_owned = false;
9913         LDKThirtyTwoBytes val_ref;
9914         CHECK(val.len == 32);
9915         memcpy(val_ref.data, val.ptr, 32);
9916         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
9917 }
9918
9919 int32_t ReplyChannelRange_1get_1first_1blocknum(void* ctx_TODO, uint32_t this_ptr) {
9920         LDKReplyChannelRange this_ptr_conv;
9921         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9922         this_ptr_conv.is_owned = false;
9923         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
9924         return ret_val;
9925 }
9926
9927 void ReplyChannelRange_1set_1first_1blocknum(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9928         LDKReplyChannelRange this_ptr_conv;
9929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9930         this_ptr_conv.is_owned = false;
9931         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
9932 }
9933
9934 int32_t ReplyChannelRange_1get_1number_1of_1blocks(void* ctx_TODO, uint32_t this_ptr) {
9935         LDKReplyChannelRange this_ptr_conv;
9936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9937         this_ptr_conv.is_owned = false;
9938         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
9939         return ret_val;
9940 }
9941
9942 void ReplyChannelRange_1set_1number_1of_1blocks(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9943         LDKReplyChannelRange this_ptr_conv;
9944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9945         this_ptr_conv.is_owned = false;
9946         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
9947 }
9948
9949 jboolean ReplyChannelRange_1get_1full_1information(void* ctx_TODO, uint32_t this_ptr) {
9950         LDKReplyChannelRange this_ptr_conv;
9951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9952         this_ptr_conv.is_owned = false;
9953         jboolean ret_val = ReplyChannelRange_get_full_information(&this_ptr_conv);
9954         return ret_val;
9955 }
9956
9957 void ReplyChannelRange_1set_1full_1information(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
9958         LDKReplyChannelRange this_ptr_conv;
9959         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9960         this_ptr_conv.is_owned = false;
9961         ReplyChannelRange_set_full_information(&this_ptr_conv, val);
9962 }
9963
9964 void ReplyChannelRange_1set_1short_1channel_1ids(void* ctx_TODO, uint32_t this_ptr, int64_tArray val) {
9965         LDKReplyChannelRange this_ptr_conv;
9966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9967         this_ptr_conv.is_owned = false;
9968         LDKCVec_u64Z val_constr;
9969         val_constr.datalen = val.len;
9970         if (val_constr.datalen > 0)
9971                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
9972         else
9973                 val_constr.data = NULL;
9974         int64_t* val_vals = (int64_t*) val.ptr;
9975         for (size_t g = 0; g < val_constr.datalen; g++) {
9976                 int64_t arr_conv_6 = val_vals[g];
9977                 val_constr.data[g] = arr_conv_6;
9978         }
9979         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
9980 }
9981
9982 uint32_t ReplyChannelRange_1new(void* ctx_TODO, 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) {
9983         LDKThirtyTwoBytes chain_hash_arg_ref;
9984         CHECK(chain_hash_arg.len == 32);
9985         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
9986         LDKCVec_u64Z short_channel_ids_arg_constr;
9987         short_channel_ids_arg_constr.datalen = short_channel_ids_arg.len;
9988         if (short_channel_ids_arg_constr.datalen > 0)
9989                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
9990         else
9991                 short_channel_ids_arg_constr.data = NULL;
9992         int64_t* short_channel_ids_arg_vals = (int64_t*) short_channel_ids_arg.ptr;
9993         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
9994                 int64_t arr_conv_6 = short_channel_ids_arg_vals[g];
9995                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
9996         }
9997         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr);
9998         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9999         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10000         long ret_ref = (long)ret_var.inner;
10001         if (ret_var.is_owned) {
10002                 ret_ref |= 1;
10003         }
10004         return ret_ref;
10005 }
10006
10007 void QueryShortChannelIds_1free(void* ctx_TODO, uint32_t this_ptr) {
10008         LDKQueryShortChannelIds this_ptr_conv;
10009         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10010         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10011         QueryShortChannelIds_free(this_ptr_conv);
10012 }
10013
10014 uint32_t QueryShortChannelIds_1clone(void* ctx_TODO, uint32_t orig) {
10015         LDKQueryShortChannelIds orig_conv;
10016         orig_conv.inner = (void*)(orig & (~1));
10017         orig_conv.is_owned = false;
10018         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
10019         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10020         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10021         long ret_ref = (long)ret_var.inner;
10022         if (ret_var.is_owned) {
10023                 ret_ref |= 1;
10024         }
10025         return ret_ref;
10026 }
10027
10028 int8_tArray QueryShortChannelIds_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10029         LDKQueryShortChannelIds this_ptr_conv;
10030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10031         this_ptr_conv.is_owned = false;
10032         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10033         memcpy(ret_arr.ptr, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
10034         return ret_arr;
10035 }
10036
10037 void QueryShortChannelIds_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10038         LDKQueryShortChannelIds this_ptr_conv;
10039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10040         this_ptr_conv.is_owned = false;
10041         LDKThirtyTwoBytes val_ref;
10042         CHECK(val.len == 32);
10043         memcpy(val_ref.data, val.ptr, 32);
10044         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
10045 }
10046
10047 void QueryShortChannelIds_1set_1short_1channel_1ids(void* ctx_TODO, uint32_t this_ptr, int64_tArray val) {
10048         LDKQueryShortChannelIds this_ptr_conv;
10049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10050         this_ptr_conv.is_owned = false;
10051         LDKCVec_u64Z val_constr;
10052         val_constr.datalen = val.len;
10053         if (val_constr.datalen > 0)
10054                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10055         else
10056                 val_constr.data = NULL;
10057         int64_t* val_vals = (int64_t*) val.ptr;
10058         for (size_t g = 0; g < val_constr.datalen; g++) {
10059                 int64_t arr_conv_6 = val_vals[g];
10060                 val_constr.data[g] = arr_conv_6;
10061         }
10062         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
10063 }
10064
10065 uint32_t QueryShortChannelIds_1new(void* ctx_TODO, int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
10066         LDKThirtyTwoBytes chain_hash_arg_ref;
10067         CHECK(chain_hash_arg.len == 32);
10068         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
10069         LDKCVec_u64Z short_channel_ids_arg_constr;
10070         short_channel_ids_arg_constr.datalen = short_channel_ids_arg.len;
10071         if (short_channel_ids_arg_constr.datalen > 0)
10072                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10073         else
10074                 short_channel_ids_arg_constr.data = NULL;
10075         int64_t* short_channel_ids_arg_vals = (int64_t*) short_channel_ids_arg.ptr;
10076         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
10077                 int64_t arr_conv_6 = short_channel_ids_arg_vals[g];
10078                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
10079         }
10080         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
10081         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10082         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10083         long ret_ref = (long)ret_var.inner;
10084         if (ret_var.is_owned) {
10085                 ret_ref |= 1;
10086         }
10087         return ret_ref;
10088 }
10089
10090 void ReplyShortChannelIdsEnd_1free(void* ctx_TODO, uint32_t this_ptr) {
10091         LDKReplyShortChannelIdsEnd this_ptr_conv;
10092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10093         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10094         ReplyShortChannelIdsEnd_free(this_ptr_conv);
10095 }
10096
10097 uint32_t ReplyShortChannelIdsEnd_1clone(void* ctx_TODO, uint32_t orig) {
10098         LDKReplyShortChannelIdsEnd orig_conv;
10099         orig_conv.inner = (void*)(orig & (~1));
10100         orig_conv.is_owned = false;
10101         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
10102         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10103         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10104         long ret_ref = (long)ret_var.inner;
10105         if (ret_var.is_owned) {
10106                 ret_ref |= 1;
10107         }
10108         return ret_ref;
10109 }
10110
10111 int8_tArray ReplyShortChannelIdsEnd_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10112         LDKReplyShortChannelIdsEnd this_ptr_conv;
10113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10114         this_ptr_conv.is_owned = false;
10115         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10116         memcpy(ret_arr.ptr, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
10117         return ret_arr;
10118 }
10119
10120 void ReplyShortChannelIdsEnd_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10121         LDKReplyShortChannelIdsEnd this_ptr_conv;
10122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10123         this_ptr_conv.is_owned = false;
10124         LDKThirtyTwoBytes val_ref;
10125         CHECK(val.len == 32);
10126         memcpy(val_ref.data, val.ptr, 32);
10127         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
10128 }
10129
10130 jboolean ReplyShortChannelIdsEnd_1get_1full_1information(void* ctx_TODO, uint32_t this_ptr) {
10131         LDKReplyShortChannelIdsEnd this_ptr_conv;
10132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10133         this_ptr_conv.is_owned = false;
10134         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
10135         return ret_val;
10136 }
10137
10138 void ReplyShortChannelIdsEnd_1set_1full_1information(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
10139         LDKReplyShortChannelIdsEnd this_ptr_conv;
10140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10141         this_ptr_conv.is_owned = false;
10142         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
10143 }
10144
10145 uint32_t ReplyShortChannelIdsEnd_1new(void* ctx_TODO, int8_tArray chain_hash_arg, jboolean full_information_arg) {
10146         LDKThirtyTwoBytes chain_hash_arg_ref;
10147         CHECK(chain_hash_arg.len == 32);
10148         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
10149         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
10150         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10151         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10152         long ret_ref = (long)ret_var.inner;
10153         if (ret_var.is_owned) {
10154                 ret_ref |= 1;
10155         }
10156         return ret_ref;
10157 }
10158
10159 void GossipTimestampFilter_1free(void* ctx_TODO, uint32_t this_ptr) {
10160         LDKGossipTimestampFilter this_ptr_conv;
10161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10162         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10163         GossipTimestampFilter_free(this_ptr_conv);
10164 }
10165
10166 uint32_t GossipTimestampFilter_1clone(void* ctx_TODO, uint32_t orig) {
10167         LDKGossipTimestampFilter orig_conv;
10168         orig_conv.inner = (void*)(orig & (~1));
10169         orig_conv.is_owned = false;
10170         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
10171         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10172         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10173         long ret_ref = (long)ret_var.inner;
10174         if (ret_var.is_owned) {
10175                 ret_ref |= 1;
10176         }
10177         return ret_ref;
10178 }
10179
10180 int8_tArray GossipTimestampFilter_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10181         LDKGossipTimestampFilter this_ptr_conv;
10182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10183         this_ptr_conv.is_owned = false;
10184         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10185         memcpy(ret_arr.ptr, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
10186         return ret_arr;
10187 }
10188
10189 void GossipTimestampFilter_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10190         LDKGossipTimestampFilter this_ptr_conv;
10191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10192         this_ptr_conv.is_owned = false;
10193         LDKThirtyTwoBytes val_ref;
10194         CHECK(val.len == 32);
10195         memcpy(val_ref.data, val.ptr, 32);
10196         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
10197 }
10198
10199 int32_t GossipTimestampFilter_1get_1first_1timestamp(void* ctx_TODO, uint32_t this_ptr) {
10200         LDKGossipTimestampFilter this_ptr_conv;
10201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10202         this_ptr_conv.is_owned = false;
10203         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
10204         return ret_val;
10205 }
10206
10207 void GossipTimestampFilter_1set_1first_1timestamp(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10208         LDKGossipTimestampFilter this_ptr_conv;
10209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10210         this_ptr_conv.is_owned = false;
10211         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
10212 }
10213
10214 int32_t GossipTimestampFilter_1get_1timestamp_1range(void* ctx_TODO, uint32_t this_ptr) {
10215         LDKGossipTimestampFilter this_ptr_conv;
10216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10217         this_ptr_conv.is_owned = false;
10218         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
10219         return ret_val;
10220 }
10221
10222 void GossipTimestampFilter_1set_1timestamp_1range(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10223         LDKGossipTimestampFilter this_ptr_conv;
10224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10225         this_ptr_conv.is_owned = false;
10226         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
10227 }
10228
10229 uint32_t GossipTimestampFilter_1new(void* ctx_TODO, int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
10230         LDKThirtyTwoBytes chain_hash_arg_ref;
10231         CHECK(chain_hash_arg.len == 32);
10232         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
10233         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
10234         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10235         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10236         long ret_ref = (long)ret_var.inner;
10237         if (ret_var.is_owned) {
10238                 ret_ref |= 1;
10239         }
10240         return ret_ref;
10241 }
10242
10243 void ErrorAction_1free(void* ctx_TODO, uint32_t this_ptr) {
10244         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
10245         FREE((void*)this_ptr);
10246         ErrorAction_free(this_ptr_conv);
10247 }
10248
10249 uint32_t ErrorAction_1clone(void* ctx_TODO, uint32_t orig) {
10250         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
10251         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10252         *ret_copy = ErrorAction_clone(orig_conv);
10253         long ret_ref = (long)ret_copy;
10254         return ret_ref;
10255 }
10256
10257 void LightningError_1free(void* ctx_TODO, uint32_t this_ptr) {
10258         LDKLightningError this_ptr_conv;
10259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10260         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10261         LightningError_free(this_ptr_conv);
10262 }
10263
10264 jstring LightningError_1get_1err(void* ctx_TODO, uint32_t this_ptr) {
10265         LDKLightningError this_ptr_conv;
10266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10267         this_ptr_conv.is_owned = false;
10268         LDKStr _str = LightningError_get_err(&this_ptr_conv);
10269         char* _buf = MALLOC(_str.len + 1, "str conv buf");
10270         memcpy(_buf, _str.chars, _str.len);
10271         _buf[_str.len] = 0;
10272         jstring _conv = (*env)->NewStringUTF(env, _str.chars);
10273         FREE(_buf);
10274         return _conv;
10275 }
10276
10277 void LightningError_1set_1err(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10278         LDKLightningError this_ptr_conv;
10279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10280         this_ptr_conv.is_owned = false;
10281         LDKCVec_u8Z val_ref;
10282         val_ref.datalen = val.len;
10283         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
10284         memcpy(val_ref.data, val.ptr, val_ref.datalen);
10285         LightningError_set_err(&this_ptr_conv, val_ref);
10286 }
10287
10288 uint32_t LightningError_1get_1action(void* ctx_TODO, uint32_t this_ptr) {
10289         LDKLightningError this_ptr_conv;
10290         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10291         this_ptr_conv.is_owned = false;
10292         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10293         *ret_copy = LightningError_get_action(&this_ptr_conv);
10294         long ret_ref = (long)ret_copy;
10295         return ret_ref;
10296 }
10297
10298 void LightningError_1set_1action(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
10299         LDKLightningError this_ptr_conv;
10300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10301         this_ptr_conv.is_owned = false;
10302         LDKErrorAction val_conv = *(LDKErrorAction*)val;
10303         FREE((void*)val);
10304         LightningError_set_action(&this_ptr_conv, val_conv);
10305 }
10306
10307 uint32_t LightningError_1new(void* ctx_TODO, int8_tArray err_arg, uint32_t action_arg) {
10308         LDKCVec_u8Z err_arg_ref;
10309         err_arg_ref.datalen = err_arg.len;
10310         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
10311         memcpy(err_arg_ref.data, err_arg.ptr, err_arg_ref.datalen);
10312         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
10313         FREE((void*)action_arg);
10314         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
10315         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10316         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10317         long ret_ref = (long)ret_var.inner;
10318         if (ret_var.is_owned) {
10319                 ret_ref |= 1;
10320         }
10321         return ret_ref;
10322 }
10323
10324 void CommitmentUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
10325         LDKCommitmentUpdate this_ptr_conv;
10326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10327         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10328         CommitmentUpdate_free(this_ptr_conv);
10329 }
10330
10331 uint32_t CommitmentUpdate_1clone(void* ctx_TODO, uint32_t orig) {
10332         LDKCommitmentUpdate orig_conv;
10333         orig_conv.inner = (void*)(orig & (~1));
10334         orig_conv.is_owned = false;
10335         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
10336         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10337         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10338         long ret_ref = (long)ret_var.inner;
10339         if (ret_var.is_owned) {
10340                 ret_ref |= 1;
10341         }
10342         return ret_ref;
10343 }
10344
10345 void CommitmentUpdate_1set_1update_1add_1htlcs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
10346         LDKCommitmentUpdate this_ptr_conv;
10347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10348         this_ptr_conv.is_owned = false;
10349         LDKCVec_UpdateAddHTLCZ val_constr;
10350         val_constr.datalen = val.len;
10351         if (val_constr.datalen > 0)
10352                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10353         else
10354                 val_constr.data = NULL;
10355         uint32_t* val_vals = (uint32_t*) val.ptr;
10356         for (size_t p = 0; p < val_constr.datalen; p++) {
10357                 uint32_t arr_conv_15 = val_vals[p];
10358                 LDKUpdateAddHTLC arr_conv_15_conv;
10359                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10360                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10361                 if (arr_conv_15_conv.inner != NULL)
10362                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10363                 val_constr.data[p] = arr_conv_15_conv;
10364         }
10365         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
10366 }
10367
10368 void CommitmentUpdate_1set_1update_1fulfill_1htlcs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
10369         LDKCommitmentUpdate this_ptr_conv;
10370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10371         this_ptr_conv.is_owned = false;
10372         LDKCVec_UpdateFulfillHTLCZ val_constr;
10373         val_constr.datalen = val.len;
10374         if (val_constr.datalen > 0)
10375                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10376         else
10377                 val_constr.data = NULL;
10378         uint32_t* val_vals = (uint32_t*) val.ptr;
10379         for (size_t t = 0; t < val_constr.datalen; t++) {
10380                 uint32_t arr_conv_19 = val_vals[t];
10381                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10382                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
10383                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
10384                 if (arr_conv_19_conv.inner != NULL)
10385                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
10386                 val_constr.data[t] = arr_conv_19_conv;
10387         }
10388         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
10389 }
10390
10391 void CommitmentUpdate_1set_1update_1fail_1htlcs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
10392         LDKCommitmentUpdate this_ptr_conv;
10393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10394         this_ptr_conv.is_owned = false;
10395         LDKCVec_UpdateFailHTLCZ val_constr;
10396         val_constr.datalen = val.len;
10397         if (val_constr.datalen > 0)
10398                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10399         else
10400                 val_constr.data = NULL;
10401         uint32_t* val_vals = (uint32_t*) val.ptr;
10402         for (size_t q = 0; q < val_constr.datalen; q++) {
10403                 uint32_t arr_conv_16 = val_vals[q];
10404                 LDKUpdateFailHTLC arr_conv_16_conv;
10405                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
10406                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
10407                 if (arr_conv_16_conv.inner != NULL)
10408                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
10409                 val_constr.data[q] = arr_conv_16_conv;
10410         }
10411         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
10412 }
10413
10414 void CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
10415         LDKCommitmentUpdate this_ptr_conv;
10416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10417         this_ptr_conv.is_owned = false;
10418         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
10419         val_constr.datalen = val.len;
10420         if (val_constr.datalen > 0)
10421                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10422         else
10423                 val_constr.data = NULL;
10424         uint32_t* val_vals = (uint32_t*) val.ptr;
10425         for (size_t z = 0; z < val_constr.datalen; z++) {
10426                 uint32_t arr_conv_25 = val_vals[z];
10427                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
10428                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
10429                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
10430                 if (arr_conv_25_conv.inner != NULL)
10431                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
10432                 val_constr.data[z] = arr_conv_25_conv;
10433         }
10434         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
10435 }
10436
10437 uint32_t CommitmentUpdate_1get_1update_1fee(void* ctx_TODO, uint32_t this_ptr) {
10438         LDKCommitmentUpdate this_ptr_conv;
10439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10440         this_ptr_conv.is_owned = false;
10441         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
10442         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10443         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10444         long ret_ref = (long)ret_var.inner;
10445         if (ret_var.is_owned) {
10446                 ret_ref |= 1;
10447         }
10448         return ret_ref;
10449 }
10450
10451 void CommitmentUpdate_1set_1update_1fee(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
10452         LDKCommitmentUpdate this_ptr_conv;
10453         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10454         this_ptr_conv.is_owned = false;
10455         LDKUpdateFee val_conv;
10456         val_conv.inner = (void*)(val & (~1));
10457         val_conv.is_owned = (val & 1) || (val == 0);
10458         if (val_conv.inner != NULL)
10459                 val_conv = UpdateFee_clone(&val_conv);
10460         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
10461 }
10462
10463 uint32_t CommitmentUpdate_1get_1commitment_1signed(void* ctx_TODO, uint32_t this_ptr) {
10464         LDKCommitmentUpdate this_ptr_conv;
10465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10466         this_ptr_conv.is_owned = false;
10467         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
10468         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10469         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10470         long ret_ref = (long)ret_var.inner;
10471         if (ret_var.is_owned) {
10472                 ret_ref |= 1;
10473         }
10474         return ret_ref;
10475 }
10476
10477 void CommitmentUpdate_1set_1commitment_1signed(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
10478         LDKCommitmentUpdate this_ptr_conv;
10479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10480         this_ptr_conv.is_owned = false;
10481         LDKCommitmentSigned val_conv;
10482         val_conv.inner = (void*)(val & (~1));
10483         val_conv.is_owned = (val & 1) || (val == 0);
10484         if (val_conv.inner != NULL)
10485                 val_conv = CommitmentSigned_clone(&val_conv);
10486         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
10487 }
10488
10489 uint32_t CommitmentUpdate_1new(void* ctx_TODO, 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) {
10490         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
10491         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg.len;
10492         if (update_add_htlcs_arg_constr.datalen > 0)
10493                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10494         else
10495                 update_add_htlcs_arg_constr.data = NULL;
10496         uint32_t* update_add_htlcs_arg_vals = (uint32_t*) update_add_htlcs_arg.ptr;
10497         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
10498                 uint32_t arr_conv_15 = update_add_htlcs_arg_vals[p];
10499                 LDKUpdateAddHTLC arr_conv_15_conv;
10500                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10501                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10502                 if (arr_conv_15_conv.inner != NULL)
10503                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10504                 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
10505         }
10506         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
10507         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg.len;
10508         if (update_fulfill_htlcs_arg_constr.datalen > 0)
10509                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10510         else
10511                 update_fulfill_htlcs_arg_constr.data = NULL;
10512         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*) update_fulfill_htlcs_arg.ptr;
10513         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
10514                 uint32_t arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
10515                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10516                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
10517                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
10518                 if (arr_conv_19_conv.inner != NULL)
10519                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
10520                 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
10521         }
10522         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
10523         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg.len;
10524         if (update_fail_htlcs_arg_constr.datalen > 0)
10525                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
10526         else
10527                 update_fail_htlcs_arg_constr.data = NULL;
10528         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*) update_fail_htlcs_arg.ptr;
10529         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
10530                 uint32_t arr_conv_16 = update_fail_htlcs_arg_vals[q];
10531                 LDKUpdateFailHTLC arr_conv_16_conv;
10532                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
10533                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
10534                 if (arr_conv_16_conv.inner != NULL)
10535                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
10536                 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
10537         }
10538         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
10539         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg.len;
10540         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
10541                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
10542         else
10543                 update_fail_malformed_htlcs_arg_constr.data = NULL;
10544         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*) update_fail_malformed_htlcs_arg.ptr;
10545         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
10546                 uint32_t arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
10547                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
10548                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
10549                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
10550                 if (arr_conv_25_conv.inner != NULL)
10551                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
10552                 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
10553         }
10554         LDKUpdateFee update_fee_arg_conv;
10555         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
10556         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
10557         if (update_fee_arg_conv.inner != NULL)
10558                 update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
10559         LDKCommitmentSigned commitment_signed_arg_conv;
10560         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
10561         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
10562         if (commitment_signed_arg_conv.inner != NULL)
10563                 commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
10564         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);
10565         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10566         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10567         long ret_ref = (long)ret_var.inner;
10568         if (ret_var.is_owned) {
10569                 ret_ref |= 1;
10570         }
10571         return ret_ref;
10572 }
10573
10574 void HTLCFailChannelUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
10575         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
10576         FREE((void*)this_ptr);
10577         HTLCFailChannelUpdate_free(this_ptr_conv);
10578 }
10579
10580 uint32_t HTLCFailChannelUpdate_1clone(void* ctx_TODO, uint32_t orig) {
10581         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
10582         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
10583         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
10584         long ret_ref = (long)ret_copy;
10585         return ret_ref;
10586 }
10587
10588 void ChannelMessageHandler_1free(void* ctx_TODO, uint32_t this_ptr) {
10589         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
10590         FREE((void*)this_ptr);
10591         ChannelMessageHandler_free(this_ptr_conv);
10592 }
10593
10594 void RoutingMessageHandler_1free(void* ctx_TODO, uint32_t this_ptr) {
10595         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
10596         FREE((void*)this_ptr);
10597         RoutingMessageHandler_free(this_ptr_conv);
10598 }
10599
10600 int8_tArray AcceptChannel_1write(void* ctx_TODO, uint32_t obj) {
10601         LDKAcceptChannel obj_conv;
10602         obj_conv.inner = (void*)(obj & (~1));
10603         obj_conv.is_owned = false;
10604         LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
10605         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10606         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10607         CVec_u8Z_free(arg_var);
10608         return arg_arr;
10609 }
10610
10611 uint32_t AcceptChannel_1read(void* ctx_TODO, int8_tArray ser) {
10612         LDKu8slice ser_ref;
10613         ser_ref.datalen = ser.len;
10614         ser_ref.data = ser.ptr;
10615         LDKAcceptChannel ret_var = AcceptChannel_read(ser_ref);
10616         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10617         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10618         long ret_ref = (long)ret_var.inner;
10619         if (ret_var.is_owned) {
10620                 ret_ref |= 1;
10621         }
10622         return ret_ref;
10623 }
10624
10625 int8_tArray AnnouncementSignatures_1write(void* ctx_TODO, uint32_t obj) {
10626         LDKAnnouncementSignatures obj_conv;
10627         obj_conv.inner = (void*)(obj & (~1));
10628         obj_conv.is_owned = false;
10629         LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
10630         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10631         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10632         CVec_u8Z_free(arg_var);
10633         return arg_arr;
10634 }
10635
10636 uint32_t AnnouncementSignatures_1read(void* ctx_TODO, int8_tArray ser) {
10637         LDKu8slice ser_ref;
10638         ser_ref.datalen = ser.len;
10639         ser_ref.data = ser.ptr;
10640         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_read(ser_ref);
10641         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10642         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10643         long ret_ref = (long)ret_var.inner;
10644         if (ret_var.is_owned) {
10645                 ret_ref |= 1;
10646         }
10647         return ret_ref;
10648 }
10649
10650 int8_tArray ChannelReestablish_1write(void* ctx_TODO, uint32_t obj) {
10651         LDKChannelReestablish obj_conv;
10652         obj_conv.inner = (void*)(obj & (~1));
10653         obj_conv.is_owned = false;
10654         LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
10655         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10656         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10657         CVec_u8Z_free(arg_var);
10658         return arg_arr;
10659 }
10660
10661 uint32_t ChannelReestablish_1read(void* ctx_TODO, int8_tArray ser) {
10662         LDKu8slice ser_ref;
10663         ser_ref.datalen = ser.len;
10664         ser_ref.data = ser.ptr;
10665         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
10666         *ret_conv = ChannelReestablish_read(ser_ref);
10667         return (long)ret_conv;
10668 }
10669
10670 int8_tArray ClosingSigned_1write(void* ctx_TODO, uint32_t obj) {
10671         LDKClosingSigned obj_conv;
10672         obj_conv.inner = (void*)(obj & (~1));
10673         obj_conv.is_owned = false;
10674         LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
10675         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10676         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10677         CVec_u8Z_free(arg_var);
10678         return arg_arr;
10679 }
10680
10681 uint32_t ClosingSigned_1read(void* ctx_TODO, int8_tArray ser) {
10682         LDKu8slice ser_ref;
10683         ser_ref.datalen = ser.len;
10684         ser_ref.data = ser.ptr;
10685         LDKClosingSigned ret_var = ClosingSigned_read(ser_ref);
10686         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10687         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10688         long ret_ref = (long)ret_var.inner;
10689         if (ret_var.is_owned) {
10690                 ret_ref |= 1;
10691         }
10692         return ret_ref;
10693 }
10694
10695 int8_tArray CommitmentSigned_1write(void* ctx_TODO, uint32_t obj) {
10696         LDKCommitmentSigned obj_conv;
10697         obj_conv.inner = (void*)(obj & (~1));
10698         obj_conv.is_owned = false;
10699         LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
10700         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10701         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10702         CVec_u8Z_free(arg_var);
10703         return arg_arr;
10704 }
10705
10706 uint32_t CommitmentSigned_1read(void* ctx_TODO, int8_tArray ser) {
10707         LDKu8slice ser_ref;
10708         ser_ref.datalen = ser.len;
10709         ser_ref.data = ser.ptr;
10710         LDKCommitmentSigned ret_var = CommitmentSigned_read(ser_ref);
10711         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10712         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10713         long ret_ref = (long)ret_var.inner;
10714         if (ret_var.is_owned) {
10715                 ret_ref |= 1;
10716         }
10717         return ret_ref;
10718 }
10719
10720 int8_tArray FundingCreated_1write(void* ctx_TODO, uint32_t obj) {
10721         LDKFundingCreated obj_conv;
10722         obj_conv.inner = (void*)(obj & (~1));
10723         obj_conv.is_owned = false;
10724         LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
10725         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10726         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10727         CVec_u8Z_free(arg_var);
10728         return arg_arr;
10729 }
10730
10731 uint32_t FundingCreated_1read(void* ctx_TODO, int8_tArray ser) {
10732         LDKu8slice ser_ref;
10733         ser_ref.datalen = ser.len;
10734         ser_ref.data = ser.ptr;
10735         LDKFundingCreated ret_var = FundingCreated_read(ser_ref);
10736         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10737         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10738         long ret_ref = (long)ret_var.inner;
10739         if (ret_var.is_owned) {
10740                 ret_ref |= 1;
10741         }
10742         return ret_ref;
10743 }
10744
10745 int8_tArray FundingSigned_1write(void* ctx_TODO, uint32_t obj) {
10746         LDKFundingSigned obj_conv;
10747         obj_conv.inner = (void*)(obj & (~1));
10748         obj_conv.is_owned = false;
10749         LDKCVec_u8Z arg_var = FundingSigned_write(&obj_conv);
10750         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10751         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10752         CVec_u8Z_free(arg_var);
10753         return arg_arr;
10754 }
10755
10756 uint32_t FundingSigned_1read(void* ctx_TODO, int8_tArray ser) {
10757         LDKu8slice ser_ref;
10758         ser_ref.datalen = ser.len;
10759         ser_ref.data = ser.ptr;
10760         LDKFundingSigned ret_var = FundingSigned_read(ser_ref);
10761         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10762         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10763         long ret_ref = (long)ret_var.inner;
10764         if (ret_var.is_owned) {
10765                 ret_ref |= 1;
10766         }
10767         return ret_ref;
10768 }
10769
10770 int8_tArray FundingLocked_1write(void* ctx_TODO, uint32_t obj) {
10771         LDKFundingLocked obj_conv;
10772         obj_conv.inner = (void*)(obj & (~1));
10773         obj_conv.is_owned = false;
10774         LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
10775         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10776         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10777         CVec_u8Z_free(arg_var);
10778         return arg_arr;
10779 }
10780
10781 uint32_t FundingLocked_1read(void* ctx_TODO, int8_tArray ser) {
10782         LDKu8slice ser_ref;
10783         ser_ref.datalen = ser.len;
10784         ser_ref.data = ser.ptr;
10785         LDKFundingLocked ret_var = FundingLocked_read(ser_ref);
10786         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10787         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10788         long ret_ref = (long)ret_var.inner;
10789         if (ret_var.is_owned) {
10790                 ret_ref |= 1;
10791         }
10792         return ret_ref;
10793 }
10794
10795 int8_tArray Init_1write(void* ctx_TODO, uint32_t obj) {
10796         LDKInit obj_conv;
10797         obj_conv.inner = (void*)(obj & (~1));
10798         obj_conv.is_owned = false;
10799         LDKCVec_u8Z arg_var = Init_write(&obj_conv);
10800         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10801         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10802         CVec_u8Z_free(arg_var);
10803         return arg_arr;
10804 }
10805
10806 uint32_t Init_1read(void* ctx_TODO, int8_tArray ser) {
10807         LDKu8slice ser_ref;
10808         ser_ref.datalen = ser.len;
10809         ser_ref.data = ser.ptr;
10810         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
10811         *ret_conv = Init_read(ser_ref);
10812         return (long)ret_conv;
10813 }
10814
10815 int8_tArray OpenChannel_1write(void* ctx_TODO, uint32_t obj) {
10816         LDKOpenChannel obj_conv;
10817         obj_conv.inner = (void*)(obj & (~1));
10818         obj_conv.is_owned = false;
10819         LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
10820         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10821         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10822         CVec_u8Z_free(arg_var);
10823         return arg_arr;
10824 }
10825
10826 uint32_t OpenChannel_1read(void* ctx_TODO, int8_tArray ser) {
10827         LDKu8slice ser_ref;
10828         ser_ref.datalen = ser.len;
10829         ser_ref.data = ser.ptr;
10830         LDKOpenChannel ret_var = OpenChannel_read(ser_ref);
10831         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10832         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10833         long ret_ref = (long)ret_var.inner;
10834         if (ret_var.is_owned) {
10835                 ret_ref |= 1;
10836         }
10837         return ret_ref;
10838 }
10839
10840 int8_tArray RevokeAndACK_1write(void* ctx_TODO, uint32_t obj) {
10841         LDKRevokeAndACK obj_conv;
10842         obj_conv.inner = (void*)(obj & (~1));
10843         obj_conv.is_owned = false;
10844         LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
10845         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10846         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10847         CVec_u8Z_free(arg_var);
10848         return arg_arr;
10849 }
10850
10851 uint32_t RevokeAndACK_1read(void* ctx_TODO, int8_tArray ser) {
10852         LDKu8slice ser_ref;
10853         ser_ref.datalen = ser.len;
10854         ser_ref.data = ser.ptr;
10855         LDKRevokeAndACK ret_var = RevokeAndACK_read(ser_ref);
10856         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10857         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10858         long ret_ref = (long)ret_var.inner;
10859         if (ret_var.is_owned) {
10860                 ret_ref |= 1;
10861         }
10862         return ret_ref;
10863 }
10864
10865 int8_tArray Shutdown_1write(void* ctx_TODO, uint32_t obj) {
10866         LDKShutdown obj_conv;
10867         obj_conv.inner = (void*)(obj & (~1));
10868         obj_conv.is_owned = false;
10869         LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
10870         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10871         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10872         CVec_u8Z_free(arg_var);
10873         return arg_arr;
10874 }
10875
10876 uint32_t Shutdown_1read(void* ctx_TODO, int8_tArray ser) {
10877         LDKu8slice ser_ref;
10878         ser_ref.datalen = ser.len;
10879         ser_ref.data = ser.ptr;
10880         LDKShutdown ret_var = Shutdown_read(ser_ref);
10881         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10882         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10883         long ret_ref = (long)ret_var.inner;
10884         if (ret_var.is_owned) {
10885                 ret_ref |= 1;
10886         }
10887         return ret_ref;
10888 }
10889
10890 int8_tArray UpdateFailHTLC_1write(void* ctx_TODO, uint32_t obj) {
10891         LDKUpdateFailHTLC obj_conv;
10892         obj_conv.inner = (void*)(obj & (~1));
10893         obj_conv.is_owned = false;
10894         LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
10895         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10896         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10897         CVec_u8Z_free(arg_var);
10898         return arg_arr;
10899 }
10900
10901 uint32_t UpdateFailHTLC_1read(void* ctx_TODO, int8_tArray ser) {
10902         LDKu8slice ser_ref;
10903         ser_ref.datalen = ser.len;
10904         ser_ref.data = ser.ptr;
10905         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_read(ser_ref);
10906         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10907         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10908         long ret_ref = (long)ret_var.inner;
10909         if (ret_var.is_owned) {
10910                 ret_ref |= 1;
10911         }
10912         return ret_ref;
10913 }
10914
10915 int8_tArray UpdateFailMalformedHTLC_1write(void* ctx_TODO, uint32_t obj) {
10916         LDKUpdateFailMalformedHTLC obj_conv;
10917         obj_conv.inner = (void*)(obj & (~1));
10918         obj_conv.is_owned = false;
10919         LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
10920         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10921         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10922         CVec_u8Z_free(arg_var);
10923         return arg_arr;
10924 }
10925
10926 uint32_t UpdateFailMalformedHTLC_1read(void* ctx_TODO, int8_tArray ser) {
10927         LDKu8slice ser_ref;
10928         ser_ref.datalen = ser.len;
10929         ser_ref.data = ser.ptr;
10930         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_read(ser_ref);
10931         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10932         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10933         long ret_ref = (long)ret_var.inner;
10934         if (ret_var.is_owned) {
10935                 ret_ref |= 1;
10936         }
10937         return ret_ref;
10938 }
10939
10940 int8_tArray UpdateFee_1write(void* ctx_TODO, uint32_t obj) {
10941         LDKUpdateFee obj_conv;
10942         obj_conv.inner = (void*)(obj & (~1));
10943         obj_conv.is_owned = false;
10944         LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
10945         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10946         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10947         CVec_u8Z_free(arg_var);
10948         return arg_arr;
10949 }
10950
10951 uint32_t UpdateFee_1read(void* ctx_TODO, int8_tArray ser) {
10952         LDKu8slice ser_ref;
10953         ser_ref.datalen = ser.len;
10954         ser_ref.data = ser.ptr;
10955         LDKUpdateFee ret_var = UpdateFee_read(ser_ref);
10956         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10957         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10958         long ret_ref = (long)ret_var.inner;
10959         if (ret_var.is_owned) {
10960                 ret_ref |= 1;
10961         }
10962         return ret_ref;
10963 }
10964
10965 int8_tArray UpdateFulfillHTLC_1write(void* ctx_TODO, uint32_t obj) {
10966         LDKUpdateFulfillHTLC obj_conv;
10967         obj_conv.inner = (void*)(obj & (~1));
10968         obj_conv.is_owned = false;
10969         LDKCVec_u8Z arg_var = UpdateFulfillHTLC_write(&obj_conv);
10970         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10971         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10972         CVec_u8Z_free(arg_var);
10973         return arg_arr;
10974 }
10975
10976 uint32_t UpdateFulfillHTLC_1read(void* ctx_TODO, int8_tArray ser) {
10977         LDKu8slice ser_ref;
10978         ser_ref.datalen = ser.len;
10979         ser_ref.data = ser.ptr;
10980         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_read(ser_ref);
10981         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10982         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10983         long ret_ref = (long)ret_var.inner;
10984         if (ret_var.is_owned) {
10985                 ret_ref |= 1;
10986         }
10987         return ret_ref;
10988 }
10989
10990 int8_tArray UpdateAddHTLC_1write(void* ctx_TODO, uint32_t obj) {
10991         LDKUpdateAddHTLC obj_conv;
10992         obj_conv.inner = (void*)(obj & (~1));
10993         obj_conv.is_owned = false;
10994         LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
10995         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
10996         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
10997         CVec_u8Z_free(arg_var);
10998         return arg_arr;
10999 }
11000
11001 uint32_t UpdateAddHTLC_1read(void* ctx_TODO, int8_tArray ser) {
11002         LDKu8slice ser_ref;
11003         ser_ref.datalen = ser.len;
11004         ser_ref.data = ser.ptr;
11005         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_read(ser_ref);
11006         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11007         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11008         long ret_ref = (long)ret_var.inner;
11009         if (ret_var.is_owned) {
11010                 ret_ref |= 1;
11011         }
11012         return ret_ref;
11013 }
11014
11015 int8_tArray Ping_1write(void* ctx_TODO, uint32_t obj) {
11016         LDKPing obj_conv;
11017         obj_conv.inner = (void*)(obj & (~1));
11018         obj_conv.is_owned = false;
11019         LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
11020         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11021         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11022         CVec_u8Z_free(arg_var);
11023         return arg_arr;
11024 }
11025
11026 uint32_t Ping_1read(void* ctx_TODO, int8_tArray ser) {
11027         LDKu8slice ser_ref;
11028         ser_ref.datalen = ser.len;
11029         ser_ref.data = ser.ptr;
11030         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11031         *ret_conv = Ping_read(ser_ref);
11032         return (long)ret_conv;
11033 }
11034
11035 int8_tArray Pong_1write(void* ctx_TODO, uint32_t obj) {
11036         LDKPong obj_conv;
11037         obj_conv.inner = (void*)(obj & (~1));
11038         obj_conv.is_owned = false;
11039         LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
11040         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11041         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11042         CVec_u8Z_free(arg_var);
11043         return arg_arr;
11044 }
11045
11046 uint32_t Pong_1read(void* ctx_TODO, int8_tArray ser) {
11047         LDKu8slice ser_ref;
11048         ser_ref.datalen = ser.len;
11049         ser_ref.data = ser.ptr;
11050         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11051         *ret_conv = Pong_read(ser_ref);
11052         return (long)ret_conv;
11053 }
11054
11055 int8_tArray UnsignedChannelAnnouncement_1write(void* ctx_TODO, uint32_t obj) {
11056         LDKUnsignedChannelAnnouncement obj_conv;
11057         obj_conv.inner = (void*)(obj & (~1));
11058         obj_conv.is_owned = false;
11059         LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_write(&obj_conv);
11060         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11061         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11062         CVec_u8Z_free(arg_var);
11063         return arg_arr;
11064 }
11065
11066 uint32_t UnsignedChannelAnnouncement_1read(void* ctx_TODO, int8_tArray ser) {
11067         LDKu8slice ser_ref;
11068         ser_ref.datalen = ser.len;
11069         ser_ref.data = ser.ptr;
11070         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11071         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
11072         return (long)ret_conv;
11073 }
11074
11075 int8_tArray ChannelAnnouncement_1write(void* ctx_TODO, uint32_t obj) {
11076         LDKChannelAnnouncement obj_conv;
11077         obj_conv.inner = (void*)(obj & (~1));
11078         obj_conv.is_owned = false;
11079         LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
11080         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11081         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11082         CVec_u8Z_free(arg_var);
11083         return arg_arr;
11084 }
11085
11086 uint32_t ChannelAnnouncement_1read(void* ctx_TODO, int8_tArray ser) {
11087         LDKu8slice ser_ref;
11088         ser_ref.datalen = ser.len;
11089         ser_ref.data = ser.ptr;
11090         LDKChannelAnnouncement ret_var = ChannelAnnouncement_read(ser_ref);
11091         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11092         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11093         long ret_ref = (long)ret_var.inner;
11094         if (ret_var.is_owned) {
11095                 ret_ref |= 1;
11096         }
11097         return ret_ref;
11098 }
11099
11100 int8_tArray UnsignedChannelUpdate_1write(void* ctx_TODO, uint32_t obj) {
11101         LDKUnsignedChannelUpdate obj_conv;
11102         obj_conv.inner = (void*)(obj & (~1));
11103         obj_conv.is_owned = false;
11104         LDKCVec_u8Z arg_var = UnsignedChannelUpdate_write(&obj_conv);
11105         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11106         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11107         CVec_u8Z_free(arg_var);
11108         return arg_arr;
11109 }
11110
11111 uint32_t UnsignedChannelUpdate_1read(void* ctx_TODO, int8_tArray ser) {
11112         LDKu8slice ser_ref;
11113         ser_ref.datalen = ser.len;
11114         ser_ref.data = ser.ptr;
11115         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11116         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
11117         return (long)ret_conv;
11118 }
11119
11120 int8_tArray ChannelUpdate_1write(void* ctx_TODO, uint32_t obj) {
11121         LDKChannelUpdate obj_conv;
11122         obj_conv.inner = (void*)(obj & (~1));
11123         obj_conv.is_owned = false;
11124         LDKCVec_u8Z arg_var = ChannelUpdate_write(&obj_conv);
11125         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11126         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11127         CVec_u8Z_free(arg_var);
11128         return arg_arr;
11129 }
11130
11131 uint32_t ChannelUpdate_1read(void* ctx_TODO, int8_tArray ser) {
11132         LDKu8slice ser_ref;
11133         ser_ref.datalen = ser.len;
11134         ser_ref.data = ser.ptr;
11135         LDKChannelUpdate ret_var = ChannelUpdate_read(ser_ref);
11136         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11137         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11138         long ret_ref = (long)ret_var.inner;
11139         if (ret_var.is_owned) {
11140                 ret_ref |= 1;
11141         }
11142         return ret_ref;
11143 }
11144
11145 int8_tArray ErrorMessage_1write(void* ctx_TODO, uint32_t obj) {
11146         LDKErrorMessage obj_conv;
11147         obj_conv.inner = (void*)(obj & (~1));
11148         obj_conv.is_owned = false;
11149         LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
11150         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11151         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11152         CVec_u8Z_free(arg_var);
11153         return arg_arr;
11154 }
11155
11156 uint32_t ErrorMessage_1read(void* ctx_TODO, int8_tArray ser) {
11157         LDKu8slice ser_ref;
11158         ser_ref.datalen = ser.len;
11159         ser_ref.data = ser.ptr;
11160         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
11161         *ret_conv = ErrorMessage_read(ser_ref);
11162         return (long)ret_conv;
11163 }
11164
11165 int8_tArray UnsignedNodeAnnouncement_1write(void* ctx_TODO, uint32_t obj) {
11166         LDKUnsignedNodeAnnouncement obj_conv;
11167         obj_conv.inner = (void*)(obj & (~1));
11168         obj_conv.is_owned = false;
11169         LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_write(&obj_conv);
11170         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11171         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11172         CVec_u8Z_free(arg_var);
11173         return arg_arr;
11174 }
11175
11176 uint32_t UnsignedNodeAnnouncement_1read(void* ctx_TODO, int8_tArray ser) {
11177         LDKu8slice ser_ref;
11178         ser_ref.datalen = ser.len;
11179         ser_ref.data = ser.ptr;
11180         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
11181         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
11182         return (long)ret_conv;
11183 }
11184
11185 int8_tArray NodeAnnouncement_1write(void* ctx_TODO, uint32_t obj) {
11186         LDKNodeAnnouncement obj_conv;
11187         obj_conv.inner = (void*)(obj & (~1));
11188         obj_conv.is_owned = false;
11189         LDKCVec_u8Z arg_var = NodeAnnouncement_write(&obj_conv);
11190         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11191         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11192         CVec_u8Z_free(arg_var);
11193         return arg_arr;
11194 }
11195
11196 uint32_t NodeAnnouncement_1read(void* ctx_TODO, int8_tArray ser) {
11197         LDKu8slice ser_ref;
11198         ser_ref.datalen = ser.len;
11199         ser_ref.data = ser.ptr;
11200         LDKNodeAnnouncement ret_var = NodeAnnouncement_read(ser_ref);
11201         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11202         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11203         long ret_ref = (long)ret_var.inner;
11204         if (ret_var.is_owned) {
11205                 ret_ref |= 1;
11206         }
11207         return ret_ref;
11208 }
11209
11210 uint32_t QueryShortChannelIds_1read(void* ctx_TODO, int8_tArray ser) {
11211         LDKu8slice ser_ref;
11212         ser_ref.datalen = ser.len;
11213         ser_ref.data = ser.ptr;
11214         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
11215         *ret_conv = QueryShortChannelIds_read(ser_ref);
11216         return (long)ret_conv;
11217 }
11218
11219 int8_tArray QueryShortChannelIds_1write(void* ctx_TODO, uint32_t obj) {
11220         LDKQueryShortChannelIds obj_conv;
11221         obj_conv.inner = (void*)(obj & (~1));
11222         obj_conv.is_owned = false;
11223         LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
11224         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11225         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11226         CVec_u8Z_free(arg_var);
11227         return arg_arr;
11228 }
11229
11230 uint32_t ReplyShortChannelIdsEnd_1read(void* ctx_TODO, int8_tArray ser) {
11231         LDKu8slice ser_ref;
11232         ser_ref.datalen = ser.len;
11233         ser_ref.data = ser.ptr;
11234         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
11235         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
11236         return (long)ret_conv;
11237 }
11238
11239 int8_tArray ReplyShortChannelIdsEnd_1write(void* ctx_TODO, uint32_t obj) {
11240         LDKReplyShortChannelIdsEnd obj_conv;
11241         obj_conv.inner = (void*)(obj & (~1));
11242         obj_conv.is_owned = false;
11243         LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
11244         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11245         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11246         CVec_u8Z_free(arg_var);
11247         return arg_arr;
11248 }
11249
11250 uint32_t QueryChannelRange_1read(void* ctx_TODO, int8_tArray ser) {
11251         LDKu8slice ser_ref;
11252         ser_ref.datalen = ser.len;
11253         ser_ref.data = ser.ptr;
11254         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
11255         *ret_conv = QueryChannelRange_read(ser_ref);
11256         return (long)ret_conv;
11257 }
11258
11259 int8_tArray QueryChannelRange_1write(void* ctx_TODO, uint32_t obj) {
11260         LDKQueryChannelRange obj_conv;
11261         obj_conv.inner = (void*)(obj & (~1));
11262         obj_conv.is_owned = false;
11263         LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
11264         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11265         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11266         CVec_u8Z_free(arg_var);
11267         return arg_arr;
11268 }
11269
11270 uint32_t ReplyChannelRange_1read(void* ctx_TODO, int8_tArray ser) {
11271         LDKu8slice ser_ref;
11272         ser_ref.datalen = ser.len;
11273         ser_ref.data = ser.ptr;
11274         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
11275         *ret_conv = ReplyChannelRange_read(ser_ref);
11276         return (long)ret_conv;
11277 }
11278
11279 int8_tArray ReplyChannelRange_1write(void* ctx_TODO, uint32_t obj) {
11280         LDKReplyChannelRange obj_conv;
11281         obj_conv.inner = (void*)(obj & (~1));
11282         obj_conv.is_owned = false;
11283         LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
11284         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11285         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11286         CVec_u8Z_free(arg_var);
11287         return arg_arr;
11288 }
11289
11290 uint32_t GossipTimestampFilter_1read(void* ctx_TODO, int8_tArray ser) {
11291         LDKu8slice ser_ref;
11292         ser_ref.datalen = ser.len;
11293         ser_ref.data = ser.ptr;
11294         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
11295         *ret_conv = GossipTimestampFilter_read(ser_ref);
11296         return (long)ret_conv;
11297 }
11298
11299 int8_tArray GossipTimestampFilter_1write(void* ctx_TODO, uint32_t obj) {
11300         LDKGossipTimestampFilter obj_conv;
11301         obj_conv.inner = (void*)(obj & (~1));
11302         obj_conv.is_owned = false;
11303         LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
11304         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11305         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11306         CVec_u8Z_free(arg_var);
11307         return arg_arr;
11308 }
11309
11310 void MessageHandler_1free(void* ctx_TODO, uint32_t this_ptr) {
11311         LDKMessageHandler this_ptr_conv;
11312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11313         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11314         MessageHandler_free(this_ptr_conv);
11315 }
11316
11317 uint32_t MessageHandler_1get_1chan_1handler(void* ctx_TODO, uint32_t this_ptr) {
11318         LDKMessageHandler this_ptr_conv;
11319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11320         this_ptr_conv.is_owned = false;
11321         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
11322         return ret_ret;
11323 }
11324
11325 void MessageHandler_1set_1chan_1handler(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
11326         LDKMessageHandler this_ptr_conv;
11327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11328         this_ptr_conv.is_owned = false;
11329         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
11330         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
11331                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11332                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
11333         }
11334         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
11335 }
11336
11337 uint32_t MessageHandler_1get_1route_1handler(void* ctx_TODO, uint32_t this_ptr) {
11338         LDKMessageHandler this_ptr_conv;
11339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11340         this_ptr_conv.is_owned = false;
11341         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
11342         return ret_ret;
11343 }
11344
11345 void MessageHandler_1set_1route_1handler(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
11346         LDKMessageHandler this_ptr_conv;
11347         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11348         this_ptr_conv.is_owned = false;
11349         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
11350         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11351                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11352                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
11353         }
11354         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
11355 }
11356
11357 uint32_t MessageHandler_1new(void* ctx_TODO, uint32_t chan_handler_arg, uint32_t route_handler_arg) {
11358         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
11359         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
11360                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11361                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
11362         }
11363         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
11364         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11365                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11366                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
11367         }
11368         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
11369         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11370         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11371         long ret_ref = (long)ret_var.inner;
11372         if (ret_var.is_owned) {
11373                 ret_ref |= 1;
11374         }
11375         return ret_ref;
11376 }
11377
11378 uint32_t SocketDescriptor_1clone(void* ctx_TODO, uint32_t orig) {
11379         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig;
11380         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
11381         *ret = SocketDescriptor_clone(orig_conv);
11382         return (long)ret;
11383 }
11384
11385 void SocketDescriptor_1free(void* ctx_TODO, uint32_t this_ptr) {
11386         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
11387         FREE((void*)this_ptr);
11388         SocketDescriptor_free(this_ptr_conv);
11389 }
11390
11391 void PeerHandleError_1free(void* ctx_TODO, uint32_t this_ptr) {
11392         LDKPeerHandleError this_ptr_conv;
11393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11394         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11395         PeerHandleError_free(this_ptr_conv);
11396 }
11397
11398 jboolean PeerHandleError_1get_1no_1connection_1possible(void* ctx_TODO, uint32_t this_ptr) {
11399         LDKPeerHandleError this_ptr_conv;
11400         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11401         this_ptr_conv.is_owned = false;
11402         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
11403         return ret_val;
11404 }
11405
11406 void PeerHandleError_1set_1no_1connection_1possible(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
11407         LDKPeerHandleError this_ptr_conv;
11408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11409         this_ptr_conv.is_owned = false;
11410         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
11411 }
11412
11413 uint32_t PeerHandleError_1new(void* ctx_TODO, jboolean no_connection_possible_arg) {
11414         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
11415         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11416         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11417         long ret_ref = (long)ret_var.inner;
11418         if (ret_var.is_owned) {
11419                 ret_ref |= 1;
11420         }
11421         return ret_ref;
11422 }
11423
11424 void PeerManager_1free(void* ctx_TODO, uint32_t this_ptr) {
11425         LDKPeerManager this_ptr_conv;
11426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11427         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11428         PeerManager_free(this_ptr_conv);
11429 }
11430
11431 uint32_t PeerManager_1new(void* ctx_TODO, uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger) {
11432         LDKMessageHandler message_handler_conv;
11433         message_handler_conv.inner = (void*)(message_handler & (~1));
11434         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
11435         // Warning: we may need a move here but can't clone!
11436         LDKSecretKey our_node_secret_ref;
11437         CHECK(our_node_secret.len == 32);
11438         memcpy(our_node_secret_ref.bytes, our_node_secret.ptr, 32);
11439         unsigned char ephemeral_random_data_arr[32];
11440         CHECK(ephemeral_random_data.len == 32);
11441         memcpy(ephemeral_random_data_arr, ephemeral_random_data.ptr, 32);
11442         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
11443         LDKLogger logger_conv = *(LDKLogger*)logger;
11444         if (logger_conv.free == LDKLogger_JCalls_free) {
11445                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11446                 LDKLogger_JCalls_clone(logger_conv.this_arg);
11447         }
11448         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
11449         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11450         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11451         long ret_ref = (long)ret_var.inner;
11452         if (ret_var.is_owned) {
11453                 ret_ref |= 1;
11454         }
11455         return ret_ref;
11456 }
11457
11458 uint32_tArray PeerManager_1get_1peer_1node_1ids(void* ctx_TODO, uint32_t this_arg) {
11459         LDKPeerManager this_arg_conv;
11460         this_arg_conv.inner = (void*)(this_arg & (~1));
11461         this_arg_conv.is_owned = false;
11462         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
11463         uint32_tArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
11464         for (size_t i = 0; i < ret_var.datalen; i++) {
11465                 int8_tArray arr_conv_8_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11466                 memcpy(arr_conv_8_arr.ptr, ret_var.data[i].compressed_form, 33);
11467                 (*env)->SetObjectArrayElement(env, ret_arr, i, arr_conv_8_arr);
11468         }
11469         FREE(ret_var.data);
11470         return ret_arr;
11471 }
11472
11473 uint32_t PeerManager_1new_1outbound_1connection(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
11474         LDKPeerManager this_arg_conv;
11475         this_arg_conv.inner = (void*)(this_arg & (~1));
11476         this_arg_conv.is_owned = false;
11477         LDKPublicKey their_node_id_ref;
11478         CHECK(their_node_id.len == 33);
11479         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
11480         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
11481         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
11482                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11483                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
11484         }
11485         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
11486         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
11487         return (long)ret_conv;
11488 }
11489
11490 uint32_t PeerManager_1new_1inbound_1connection(void* ctx_TODO, uint32_t this_arg, uint32_t descriptor) {
11491         LDKPeerManager this_arg_conv;
11492         this_arg_conv.inner = (void*)(this_arg & (~1));
11493         this_arg_conv.is_owned = false;
11494         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
11495         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
11496                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11497                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
11498         }
11499         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11500         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
11501         return (long)ret_conv;
11502 }
11503
11504 uint32_t PeerManager_1write_1buffer_1space_1avail(void* ctx_TODO, uint32_t this_arg, uint32_t descriptor) {
11505         LDKPeerManager this_arg_conv;
11506         this_arg_conv.inner = (void*)(this_arg & (~1));
11507         this_arg_conv.is_owned = false;
11508         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
11509         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
11510         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
11511         return (long)ret_conv;
11512 }
11513
11514 uint32_t PeerManager_1read_1event(void* ctx_TODO, uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
11515         LDKPeerManager this_arg_conv;
11516         this_arg_conv.inner = (void*)(this_arg & (~1));
11517         this_arg_conv.is_owned = false;
11518         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
11519         LDKu8slice data_ref;
11520         data_ref.datalen = data.len;
11521         data_ref.data = data.ptr;
11522         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
11523         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
11524         return (long)ret_conv;
11525 }
11526
11527 void PeerManager_1process_1events(void* ctx_TODO, uint32_t this_arg) {
11528         LDKPeerManager this_arg_conv;
11529         this_arg_conv.inner = (void*)(this_arg & (~1));
11530         this_arg_conv.is_owned = false;
11531         PeerManager_process_events(&this_arg_conv);
11532 }
11533
11534 void PeerManager_1socket_1disconnected(void* ctx_TODO, uint32_t this_arg, uint32_t descriptor) {
11535         LDKPeerManager this_arg_conv;
11536         this_arg_conv.inner = (void*)(this_arg & (~1));
11537         this_arg_conv.is_owned = false;
11538         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
11539         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
11540 }
11541
11542 void PeerManager_1timer_1tick_1occured(void* ctx_TODO, uint32_t this_arg) {
11543         LDKPeerManager this_arg_conv;
11544         this_arg_conv.inner = (void*)(this_arg & (~1));
11545         this_arg_conv.is_owned = false;
11546         PeerManager_timer_tick_occured(&this_arg_conv);
11547 }
11548
11549 int8_tArray build_1commitment_1secret(void* ctx_TODO, int8_tArray commitment_seed, int64_t idx) {
11550         unsigned char commitment_seed_arr[32];
11551         CHECK(commitment_seed.len == 32);
11552         memcpy(commitment_seed_arr, commitment_seed.ptr, 32);
11553         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
11554         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
11555         memcpy(arg_arr.ptr, build_commitment_secret(commitment_seed_ref, idx).data, 32);
11556         return arg_arr;
11557 }
11558
11559 uint32_t derive_1private_1key(void* ctx_TODO, int8_tArray per_commitment_point, int8_tArray base_secret) {
11560         LDKPublicKey per_commitment_point_ref;
11561         CHECK(per_commitment_point.len == 33);
11562         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
11563         unsigned char base_secret_arr[32];
11564         CHECK(base_secret.len == 32);
11565         memcpy(base_secret_arr, base_secret.ptr, 32);
11566         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
11567         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
11568         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
11569         return (long)ret_conv;
11570 }
11571
11572 uint32_t derive_1public_1key(void* ctx_TODO, int8_tArray per_commitment_point, int8_tArray base_point) {
11573         LDKPublicKey per_commitment_point_ref;
11574         CHECK(per_commitment_point.len == 33);
11575         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
11576         LDKPublicKey base_point_ref;
11577         CHECK(base_point.len == 33);
11578         memcpy(base_point_ref.compressed_form, base_point.ptr, 33);
11579         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
11580         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
11581         return (long)ret_conv;
11582 }
11583
11584 uint32_t derive_1private_1revocation_1key(void* ctx_TODO, int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
11585         unsigned char per_commitment_secret_arr[32];
11586         CHECK(per_commitment_secret.len == 32);
11587         memcpy(per_commitment_secret_arr, per_commitment_secret.ptr, 32);
11588         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
11589         unsigned char countersignatory_revocation_base_secret_arr[32];
11590         CHECK(countersignatory_revocation_base_secret.len == 32);
11591         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret.ptr, 32);
11592         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
11593         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
11594         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
11595         return (long)ret_conv;
11596 }
11597
11598 uint32_t derive_1public_1revocation_1key(void* ctx_TODO, int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
11599         LDKPublicKey per_commitment_point_ref;
11600         CHECK(per_commitment_point.len == 33);
11601         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
11602         LDKPublicKey countersignatory_revocation_base_point_ref;
11603         CHECK(countersignatory_revocation_base_point.len == 33);
11604         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point.ptr, 33);
11605         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
11606         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
11607         return (long)ret_conv;
11608 }
11609
11610 void TxCreationKeys_1free(void* ctx_TODO, uint32_t this_ptr) {
11611         LDKTxCreationKeys this_ptr_conv;
11612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11613         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11614         TxCreationKeys_free(this_ptr_conv);
11615 }
11616
11617 uint32_t TxCreationKeys_1clone(void* ctx_TODO, uint32_t orig) {
11618         LDKTxCreationKeys orig_conv;
11619         orig_conv.inner = (void*)(orig & (~1));
11620         orig_conv.is_owned = false;
11621         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
11622         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11623         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11624         long ret_ref = (long)ret_var.inner;
11625         if (ret_var.is_owned) {
11626                 ret_ref |= 1;
11627         }
11628         return ret_ref;
11629 }
11630
11631 int8_tArray TxCreationKeys_1get_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
11632         LDKTxCreationKeys this_ptr_conv;
11633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11634         this_ptr_conv.is_owned = false;
11635         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11636         memcpy(arg_arr.ptr, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
11637         return arg_arr;
11638 }
11639
11640 void TxCreationKeys_1set_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11641         LDKTxCreationKeys this_ptr_conv;
11642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11643         this_ptr_conv.is_owned = false;
11644         LDKPublicKey val_ref;
11645         CHECK(val.len == 33);
11646         memcpy(val_ref.compressed_form, val.ptr, 33);
11647         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
11648 }
11649
11650 int8_tArray TxCreationKeys_1get_1revocation_1key(void* ctx_TODO, uint32_t this_ptr) {
11651         LDKTxCreationKeys this_ptr_conv;
11652         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11653         this_ptr_conv.is_owned = false;
11654         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11655         memcpy(arg_arr.ptr, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
11656         return arg_arr;
11657 }
11658
11659 void TxCreationKeys_1set_1revocation_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11660         LDKTxCreationKeys this_ptr_conv;
11661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11662         this_ptr_conv.is_owned = false;
11663         LDKPublicKey val_ref;
11664         CHECK(val.len == 33);
11665         memcpy(val_ref.compressed_form, val.ptr, 33);
11666         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
11667 }
11668
11669 int8_tArray TxCreationKeys_1get_1broadcaster_1htlc_1key(void* ctx_TODO, uint32_t this_ptr) {
11670         LDKTxCreationKeys this_ptr_conv;
11671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11672         this_ptr_conv.is_owned = false;
11673         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11674         memcpy(arg_arr.ptr, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
11675         return arg_arr;
11676 }
11677
11678 void TxCreationKeys_1set_1broadcaster_1htlc_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11679         LDKTxCreationKeys this_ptr_conv;
11680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11681         this_ptr_conv.is_owned = false;
11682         LDKPublicKey val_ref;
11683         CHECK(val.len == 33);
11684         memcpy(val_ref.compressed_form, val.ptr, 33);
11685         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
11686 }
11687
11688 int8_tArray TxCreationKeys_1get_1countersignatory_1htlc_1key(void* ctx_TODO, uint32_t this_ptr) {
11689         LDKTxCreationKeys this_ptr_conv;
11690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11691         this_ptr_conv.is_owned = false;
11692         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11693         memcpy(arg_arr.ptr, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
11694         return arg_arr;
11695 }
11696
11697 void TxCreationKeys_1set_1countersignatory_1htlc_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11698         LDKTxCreationKeys this_ptr_conv;
11699         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11700         this_ptr_conv.is_owned = false;
11701         LDKPublicKey val_ref;
11702         CHECK(val.len == 33);
11703         memcpy(val_ref.compressed_form, val.ptr, 33);
11704         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
11705 }
11706
11707 int8_tArray TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(void* ctx_TODO, uint32_t this_ptr) {
11708         LDKTxCreationKeys this_ptr_conv;
11709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11710         this_ptr_conv.is_owned = false;
11711         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11712         memcpy(arg_arr.ptr, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
11713         return arg_arr;
11714 }
11715
11716 void TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11717         LDKTxCreationKeys this_ptr_conv;
11718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11719         this_ptr_conv.is_owned = false;
11720         LDKPublicKey val_ref;
11721         CHECK(val.len == 33);
11722         memcpy(val_ref.compressed_form, val.ptr, 33);
11723         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
11724 }
11725
11726 uint32_t TxCreationKeys_1new(void* ctx_TODO, 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) {
11727         LDKPublicKey per_commitment_point_arg_ref;
11728         CHECK(per_commitment_point_arg.len == 33);
11729         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg.ptr, 33);
11730         LDKPublicKey revocation_key_arg_ref;
11731         CHECK(revocation_key_arg.len == 33);
11732         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg.ptr, 33);
11733         LDKPublicKey broadcaster_htlc_key_arg_ref;
11734         CHECK(broadcaster_htlc_key_arg.len == 33);
11735         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg.ptr, 33);
11736         LDKPublicKey countersignatory_htlc_key_arg_ref;
11737         CHECK(countersignatory_htlc_key_arg.len == 33);
11738         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg.ptr, 33);
11739         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
11740         CHECK(broadcaster_delayed_payment_key_arg.len == 33);
11741         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg.ptr, 33);
11742         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);
11743         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11744         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11745         long ret_ref = (long)ret_var.inner;
11746         if (ret_var.is_owned) {
11747                 ret_ref |= 1;
11748         }
11749         return ret_ref;
11750 }
11751
11752 int8_tArray TxCreationKeys_1write(void* ctx_TODO, uint32_t obj) {
11753         LDKTxCreationKeys obj_conv;
11754         obj_conv.inner = (void*)(obj & (~1));
11755         obj_conv.is_owned = false;
11756         LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
11757         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11758         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11759         CVec_u8Z_free(arg_var);
11760         return arg_arr;
11761 }
11762
11763 uint32_t TxCreationKeys_1read(void* ctx_TODO, int8_tArray ser) {
11764         LDKu8slice ser_ref;
11765         ser_ref.datalen = ser.len;
11766         ser_ref.data = ser.ptr;
11767         LDKTxCreationKeys ret_var = TxCreationKeys_read(ser_ref);
11768         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11769         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11770         long ret_ref = (long)ret_var.inner;
11771         if (ret_var.is_owned) {
11772                 ret_ref |= 1;
11773         }
11774         return ret_ref;
11775 }
11776
11777 void ChannelPublicKeys_1free(void* ctx_TODO, uint32_t this_ptr) {
11778         LDKChannelPublicKeys this_ptr_conv;
11779         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11780         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11781         ChannelPublicKeys_free(this_ptr_conv);
11782 }
11783
11784 uint32_t ChannelPublicKeys_1clone(void* ctx_TODO, uint32_t orig) {
11785         LDKChannelPublicKeys orig_conv;
11786         orig_conv.inner = (void*)(orig & (~1));
11787         orig_conv.is_owned = false;
11788         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
11789         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11790         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11791         long ret_ref = (long)ret_var.inner;
11792         if (ret_var.is_owned) {
11793                 ret_ref |= 1;
11794         }
11795         return ret_ref;
11796 }
11797
11798 int8_tArray ChannelPublicKeys_1get_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
11799         LDKChannelPublicKeys this_ptr_conv;
11800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11801         this_ptr_conv.is_owned = false;
11802         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11803         memcpy(arg_arr.ptr, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
11804         return arg_arr;
11805 }
11806
11807 void ChannelPublicKeys_1set_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11808         LDKChannelPublicKeys this_ptr_conv;
11809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11810         this_ptr_conv.is_owned = false;
11811         LDKPublicKey val_ref;
11812         CHECK(val.len == 33);
11813         memcpy(val_ref.compressed_form, val.ptr, 33);
11814         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
11815 }
11816
11817 int8_tArray ChannelPublicKeys_1get_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
11818         LDKChannelPublicKeys this_ptr_conv;
11819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11820         this_ptr_conv.is_owned = false;
11821         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11822         memcpy(arg_arr.ptr, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
11823         return arg_arr;
11824 }
11825
11826 void ChannelPublicKeys_1set_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11827         LDKChannelPublicKeys this_ptr_conv;
11828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11829         this_ptr_conv.is_owned = false;
11830         LDKPublicKey val_ref;
11831         CHECK(val.len == 33);
11832         memcpy(val_ref.compressed_form, val.ptr, 33);
11833         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
11834 }
11835
11836 int8_tArray ChannelPublicKeys_1get_1payment_1point(void* ctx_TODO, uint32_t this_ptr) {
11837         LDKChannelPublicKeys this_ptr_conv;
11838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11839         this_ptr_conv.is_owned = false;
11840         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11841         memcpy(arg_arr.ptr, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
11842         return arg_arr;
11843 }
11844
11845 void ChannelPublicKeys_1set_1payment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11846         LDKChannelPublicKeys this_ptr_conv;
11847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11848         this_ptr_conv.is_owned = false;
11849         LDKPublicKey val_ref;
11850         CHECK(val.len == 33);
11851         memcpy(val_ref.compressed_form, val.ptr, 33);
11852         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
11853 }
11854
11855 int8_tArray ChannelPublicKeys_1get_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
11856         LDKChannelPublicKeys this_ptr_conv;
11857         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11858         this_ptr_conv.is_owned = false;
11859         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11860         memcpy(arg_arr.ptr, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
11861         return arg_arr;
11862 }
11863
11864 void ChannelPublicKeys_1set_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11865         LDKChannelPublicKeys this_ptr_conv;
11866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11867         this_ptr_conv.is_owned = false;
11868         LDKPublicKey val_ref;
11869         CHECK(val.len == 33);
11870         memcpy(val_ref.compressed_form, val.ptr, 33);
11871         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
11872 }
11873
11874 int8_tArray ChannelPublicKeys_1get_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
11875         LDKChannelPublicKeys this_ptr_conv;
11876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11877         this_ptr_conv.is_owned = false;
11878         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
11879         memcpy(arg_arr.ptr, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
11880         return arg_arr;
11881 }
11882
11883 void ChannelPublicKeys_1set_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
11884         LDKChannelPublicKeys this_ptr_conv;
11885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11886         this_ptr_conv.is_owned = false;
11887         LDKPublicKey val_ref;
11888         CHECK(val.len == 33);
11889         memcpy(val_ref.compressed_form, val.ptr, 33);
11890         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
11891 }
11892
11893 uint32_t ChannelPublicKeys_1new(void* ctx_TODO, 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) {
11894         LDKPublicKey funding_pubkey_arg_ref;
11895         CHECK(funding_pubkey_arg.len == 33);
11896         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg.ptr, 33);
11897         LDKPublicKey revocation_basepoint_arg_ref;
11898         CHECK(revocation_basepoint_arg.len == 33);
11899         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg.ptr, 33);
11900         LDKPublicKey payment_point_arg_ref;
11901         CHECK(payment_point_arg.len == 33);
11902         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg.ptr, 33);
11903         LDKPublicKey delayed_payment_basepoint_arg_ref;
11904         CHECK(delayed_payment_basepoint_arg.len == 33);
11905         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg.ptr, 33);
11906         LDKPublicKey htlc_basepoint_arg_ref;
11907         CHECK(htlc_basepoint_arg.len == 33);
11908         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg.ptr, 33);
11909         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);
11910         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11911         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11912         long ret_ref = (long)ret_var.inner;
11913         if (ret_var.is_owned) {
11914                 ret_ref |= 1;
11915         }
11916         return ret_ref;
11917 }
11918
11919 int8_tArray ChannelPublicKeys_1write(void* ctx_TODO, uint32_t obj) {
11920         LDKChannelPublicKeys obj_conv;
11921         obj_conv.inner = (void*)(obj & (~1));
11922         obj_conv.is_owned = false;
11923         LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
11924         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11925         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11926         CVec_u8Z_free(arg_var);
11927         return arg_arr;
11928 }
11929
11930 uint32_t ChannelPublicKeys_1read(void* ctx_TODO, int8_tArray ser) {
11931         LDKu8slice ser_ref;
11932         ser_ref.datalen = ser.len;
11933         ser_ref.data = ser.ptr;
11934         LDKChannelPublicKeys ret_var = ChannelPublicKeys_read(ser_ref);
11935         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11936         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11937         long ret_ref = (long)ret_var.inner;
11938         if (ret_var.is_owned) {
11939                 ret_ref |= 1;
11940         }
11941         return ret_ref;
11942 }
11943
11944 uint32_t TxCreationKeys_1derive_1new(void* ctx_TODO, 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) {
11945         LDKPublicKey per_commitment_point_ref;
11946         CHECK(per_commitment_point.len == 33);
11947         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
11948         LDKPublicKey broadcaster_delayed_payment_base_ref;
11949         CHECK(broadcaster_delayed_payment_base.len == 33);
11950         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base.ptr, 33);
11951         LDKPublicKey broadcaster_htlc_base_ref;
11952         CHECK(broadcaster_htlc_base.len == 33);
11953         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base.ptr, 33);
11954         LDKPublicKey countersignatory_revocation_base_ref;
11955         CHECK(countersignatory_revocation_base.len == 33);
11956         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base.ptr, 33);
11957         LDKPublicKey countersignatory_htlc_base_ref;
11958         CHECK(countersignatory_htlc_base.len == 33);
11959         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base.ptr, 33);
11960         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
11961         *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);
11962         return (long)ret_conv;
11963 }
11964
11965 uint32_t TxCreationKeys_1from_1channel_1static_1keys(void* ctx_TODO, int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
11966         LDKPublicKey per_commitment_point_ref;
11967         CHECK(per_commitment_point.len == 33);
11968         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
11969         LDKChannelPublicKeys broadcaster_keys_conv;
11970         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
11971         broadcaster_keys_conv.is_owned = false;
11972         LDKChannelPublicKeys countersignatory_keys_conv;
11973         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
11974         countersignatory_keys_conv.is_owned = false;
11975         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
11976         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
11977         return (long)ret_conv;
11978 }
11979
11980 int8_tArray get_1revokeable_1redeemscript(void* ctx_TODO, int8_tArray revocation_key, jshort contest_delay, int8_tArray broadcaster_delayed_payment_key) {
11981         LDKPublicKey revocation_key_ref;
11982         CHECK(revocation_key.len == 33);
11983         memcpy(revocation_key_ref.compressed_form, revocation_key.ptr, 33);
11984         LDKPublicKey broadcaster_delayed_payment_key_ref;
11985         CHECK(broadcaster_delayed_payment_key.len == 33);
11986         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key.ptr, 33);
11987         LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
11988         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11989         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11990         CVec_u8Z_free(arg_var);
11991         return arg_arr;
11992 }
11993
11994 void HTLCOutputInCommitment_1free(void* ctx_TODO, uint32_t this_ptr) {
11995         LDKHTLCOutputInCommitment this_ptr_conv;
11996         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11997         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11998         HTLCOutputInCommitment_free(this_ptr_conv);
11999 }
12000
12001 uint32_t HTLCOutputInCommitment_1clone(void* ctx_TODO, uint32_t orig) {
12002         LDKHTLCOutputInCommitment orig_conv;
12003         orig_conv.inner = (void*)(orig & (~1));
12004         orig_conv.is_owned = false;
12005         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
12006         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12007         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12008         long ret_ref = (long)ret_var.inner;
12009         if (ret_var.is_owned) {
12010                 ret_ref |= 1;
12011         }
12012         return ret_ref;
12013 }
12014
12015 jboolean HTLCOutputInCommitment_1get_1offered(void* ctx_TODO, uint32_t this_ptr) {
12016         LDKHTLCOutputInCommitment this_ptr_conv;
12017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12018         this_ptr_conv.is_owned = false;
12019         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
12020         return ret_val;
12021 }
12022
12023 void HTLCOutputInCommitment_1set_1offered(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
12024         LDKHTLCOutputInCommitment this_ptr_conv;
12025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12026         this_ptr_conv.is_owned = false;
12027         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
12028 }
12029
12030 int64_t HTLCOutputInCommitment_1get_1amount_1msat(void* ctx_TODO, uint32_t this_ptr) {
12031         LDKHTLCOutputInCommitment this_ptr_conv;
12032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12033         this_ptr_conv.is_owned = false;
12034         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
12035         return ret_val;
12036 }
12037
12038 void HTLCOutputInCommitment_1set_1amount_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
12039         LDKHTLCOutputInCommitment this_ptr_conv;
12040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12041         this_ptr_conv.is_owned = false;
12042         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
12043 }
12044
12045 int32_t HTLCOutputInCommitment_1get_1cltv_1expiry(void* ctx_TODO, uint32_t this_ptr) {
12046         LDKHTLCOutputInCommitment this_ptr_conv;
12047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12048         this_ptr_conv.is_owned = false;
12049         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
12050         return ret_val;
12051 }
12052
12053 void HTLCOutputInCommitment_1set_1cltv_1expiry(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
12054         LDKHTLCOutputInCommitment this_ptr_conv;
12055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12056         this_ptr_conv.is_owned = false;
12057         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
12058 }
12059
12060 int8_tArray HTLCOutputInCommitment_1get_1payment_1hash(void* ctx_TODO, uint32_t this_ptr) {
12061         LDKHTLCOutputInCommitment this_ptr_conv;
12062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12063         this_ptr_conv.is_owned = false;
12064         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
12065         memcpy(ret_arr.ptr, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
12066         return ret_arr;
12067 }
12068
12069 void HTLCOutputInCommitment_1set_1payment_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12070         LDKHTLCOutputInCommitment this_ptr_conv;
12071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12072         this_ptr_conv.is_owned = false;
12073         LDKThirtyTwoBytes val_ref;
12074         CHECK(val.len == 32);
12075         memcpy(val_ref.data, val.ptr, 32);
12076         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
12077 }
12078
12079 int8_tArray HTLCOutputInCommitment_1write(void* ctx_TODO, uint32_t obj) {
12080         LDKHTLCOutputInCommitment obj_conv;
12081         obj_conv.inner = (void*)(obj & (~1));
12082         obj_conv.is_owned = false;
12083         LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
12084         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12085         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12086         CVec_u8Z_free(arg_var);
12087         return arg_arr;
12088 }
12089
12090 uint32_t HTLCOutputInCommitment_1read(void* ctx_TODO, int8_tArray ser) {
12091         LDKu8slice ser_ref;
12092         ser_ref.datalen = ser.len;
12093         ser_ref.data = ser.ptr;
12094         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_read(ser_ref);
12095         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12096         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12097         long ret_ref = (long)ret_var.inner;
12098         if (ret_var.is_owned) {
12099                 ret_ref |= 1;
12100         }
12101         return ret_ref;
12102 }
12103
12104 int8_tArray get_1htlc_1redeemscript(void* ctx_TODO, uint32_t htlc, uint32_t keys) {
12105         LDKHTLCOutputInCommitment htlc_conv;
12106         htlc_conv.inner = (void*)(htlc & (~1));
12107         htlc_conv.is_owned = false;
12108         LDKTxCreationKeys keys_conv;
12109         keys_conv.inner = (void*)(keys & (~1));
12110         keys_conv.is_owned = false;
12111         LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
12112         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12113         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12114         CVec_u8Z_free(arg_var);
12115         return arg_arr;
12116 }
12117
12118 int8_tArray make_1funding_1redeemscript(void* ctx_TODO, int8_tArray broadcaster, int8_tArray countersignatory) {
12119         LDKPublicKey broadcaster_ref;
12120         CHECK(broadcaster.len == 33);
12121         memcpy(broadcaster_ref.compressed_form, broadcaster.ptr, 33);
12122         LDKPublicKey countersignatory_ref;
12123         CHECK(countersignatory.len == 33);
12124         memcpy(countersignatory_ref.compressed_form, countersignatory.ptr, 33);
12125         LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
12126         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12127         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12128         CVec_u8Z_free(arg_var);
12129         return arg_arr;
12130 }
12131
12132 int8_tArray build_1htlc_1transaction(void* ctx_TODO, int8_tArray prev_hash, int32_t feerate_per_kw, jshort contest_delay, uint32_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
12133         unsigned char prev_hash_arr[32];
12134         CHECK(prev_hash.len == 32);
12135         memcpy(prev_hash_arr, prev_hash.ptr, 32);
12136         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
12137         LDKHTLCOutputInCommitment htlc_conv;
12138         htlc_conv.inner = (void*)(htlc & (~1));
12139         htlc_conv.is_owned = false;
12140         LDKPublicKey broadcaster_delayed_payment_key_ref;
12141         CHECK(broadcaster_delayed_payment_key.len == 33);
12142         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key.ptr, 33);
12143         LDKPublicKey revocation_key_ref;
12144         CHECK(revocation_key.len == 33);
12145         memcpy(revocation_key_ref.compressed_form, revocation_key.ptr, 33);
12146         LDKTransaction arg_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
12147         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12148         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12149         Transaction_free(arg_var);
12150         return arg_arr;
12151 }
12152
12153 void ChannelTransactionParameters_1free(void* ctx_TODO, uint32_t this_ptr) {
12154         LDKChannelTransactionParameters this_ptr_conv;
12155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12156         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12157         ChannelTransactionParameters_free(this_ptr_conv);
12158 }
12159
12160 uint32_t ChannelTransactionParameters_1clone(void* ctx_TODO, uint32_t orig) {
12161         LDKChannelTransactionParameters orig_conv;
12162         orig_conv.inner = (void*)(orig & (~1));
12163         orig_conv.is_owned = false;
12164         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
12165         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12166         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12167         long ret_ref = (long)ret_var.inner;
12168         if (ret_var.is_owned) {
12169                 ret_ref |= 1;
12170         }
12171         return ret_ref;
12172 }
12173
12174 uint32_t ChannelTransactionParameters_1get_1holder_1pubkeys(void* ctx_TODO, uint32_t this_ptr) {
12175         LDKChannelTransactionParameters this_ptr_conv;
12176         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12177         this_ptr_conv.is_owned = false;
12178         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
12179         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12180         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12181         long ret_ref = (long)ret_var.inner;
12182         if (ret_var.is_owned) {
12183                 ret_ref |= 1;
12184         }
12185         return ret_ref;
12186 }
12187
12188 void ChannelTransactionParameters_1set_1holder_1pubkeys(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
12189         LDKChannelTransactionParameters this_ptr_conv;
12190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12191         this_ptr_conv.is_owned = false;
12192         LDKChannelPublicKeys val_conv;
12193         val_conv.inner = (void*)(val & (~1));
12194         val_conv.is_owned = (val & 1) || (val == 0);
12195         if (val_conv.inner != NULL)
12196                 val_conv = ChannelPublicKeys_clone(&val_conv);
12197         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
12198 }
12199
12200 jshort ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_ptr) {
12201         LDKChannelTransactionParameters this_ptr_conv;
12202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12203         this_ptr_conv.is_owned = false;
12204         jshort ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
12205         return ret_val;
12206 }
12207
12208 void ChannelTransactionParameters_1set_1holder_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
12209         LDKChannelTransactionParameters this_ptr_conv;
12210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12211         this_ptr_conv.is_owned = false;
12212         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
12213 }
12214
12215 jboolean ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(void* ctx_TODO, uint32_t this_ptr) {
12216         LDKChannelTransactionParameters this_ptr_conv;
12217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12218         this_ptr_conv.is_owned = false;
12219         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
12220         return ret_val;
12221 }
12222
12223 void ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
12224         LDKChannelTransactionParameters this_ptr_conv;
12225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12226         this_ptr_conv.is_owned = false;
12227         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
12228 }
12229
12230 uint32_t ChannelTransactionParameters_1get_1counterparty_1parameters(void* ctx_TODO, uint32_t this_ptr) {
12231         LDKChannelTransactionParameters this_ptr_conv;
12232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12233         this_ptr_conv.is_owned = false;
12234         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
12235         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12236         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12237         long ret_ref = (long)ret_var.inner;
12238         if (ret_var.is_owned) {
12239                 ret_ref |= 1;
12240         }
12241         return ret_ref;
12242 }
12243
12244 void ChannelTransactionParameters_1set_1counterparty_1parameters(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
12245         LDKChannelTransactionParameters this_ptr_conv;
12246         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12247         this_ptr_conv.is_owned = false;
12248         LDKCounterpartyChannelTransactionParameters val_conv;
12249         val_conv.inner = (void*)(val & (~1));
12250         val_conv.is_owned = (val & 1) || (val == 0);
12251         if (val_conv.inner != NULL)
12252                 val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
12253         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
12254 }
12255
12256 uint32_t ChannelTransactionParameters_1get_1funding_1outpoint(void* ctx_TODO, uint32_t this_ptr) {
12257         LDKChannelTransactionParameters this_ptr_conv;
12258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12259         this_ptr_conv.is_owned = false;
12260         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
12261         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12262         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12263         long ret_ref = (long)ret_var.inner;
12264         if (ret_var.is_owned) {
12265                 ret_ref |= 1;
12266         }
12267         return ret_ref;
12268 }
12269
12270 void ChannelTransactionParameters_1set_1funding_1outpoint(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
12271         LDKChannelTransactionParameters this_ptr_conv;
12272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12273         this_ptr_conv.is_owned = false;
12274         LDKOutPoint val_conv;
12275         val_conv.inner = (void*)(val & (~1));
12276         val_conv.is_owned = (val & 1) || (val == 0);
12277         if (val_conv.inner != NULL)
12278                 val_conv = OutPoint_clone(&val_conv);
12279         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
12280 }
12281
12282 uint32_t ChannelTransactionParameters_1new(void* ctx_TODO, uint32_t holder_pubkeys_arg, jshort holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, uint32_t counterparty_parameters_arg, uint32_t funding_outpoint_arg) {
12283         LDKChannelPublicKeys holder_pubkeys_arg_conv;
12284         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
12285         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
12286         if (holder_pubkeys_arg_conv.inner != NULL)
12287                 holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
12288         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
12289         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
12290         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
12291         if (counterparty_parameters_arg_conv.inner != NULL)
12292                 counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
12293         LDKOutPoint funding_outpoint_arg_conv;
12294         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
12295         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
12296         if (funding_outpoint_arg_conv.inner != NULL)
12297                 funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
12298         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);
12299         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12300         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12301         long ret_ref = (long)ret_var.inner;
12302         if (ret_var.is_owned) {
12303                 ret_ref |= 1;
12304         }
12305         return ret_ref;
12306 }
12307
12308 void CounterpartyChannelTransactionParameters_1free(void* ctx_TODO, uint32_t this_ptr) {
12309         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12311         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12312         CounterpartyChannelTransactionParameters_free(this_ptr_conv);
12313 }
12314
12315 uint32_t CounterpartyChannelTransactionParameters_1clone(void* ctx_TODO, uint32_t orig) {
12316         LDKCounterpartyChannelTransactionParameters orig_conv;
12317         orig_conv.inner = (void*)(orig & (~1));
12318         orig_conv.is_owned = false;
12319         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
12320         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12321         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12322         long ret_ref = (long)ret_var.inner;
12323         if (ret_var.is_owned) {
12324                 ret_ref |= 1;
12325         }
12326         return ret_ref;
12327 }
12328
12329 uint32_t CounterpartyChannelTransactionParameters_1get_1pubkeys(void* ctx_TODO, uint32_t this_ptr) {
12330         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12332         this_ptr_conv.is_owned = false;
12333         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
12334         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12335         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12336         long ret_ref = (long)ret_var.inner;
12337         if (ret_var.is_owned) {
12338                 ret_ref |= 1;
12339         }
12340         return ret_ref;
12341 }
12342
12343 void CounterpartyChannelTransactionParameters_1set_1pubkeys(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
12344         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12345         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12346         this_ptr_conv.is_owned = false;
12347         LDKChannelPublicKeys val_conv;
12348         val_conv.inner = (void*)(val & (~1));
12349         val_conv.is_owned = (val & 1) || (val == 0);
12350         if (val_conv.inner != NULL)
12351                 val_conv = ChannelPublicKeys_clone(&val_conv);
12352         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
12353 }
12354
12355 jshort CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_ptr) {
12356         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12358         this_ptr_conv.is_owned = false;
12359         jshort ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
12360         return ret_val;
12361 }
12362
12363 void CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
12364         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12366         this_ptr_conv.is_owned = false;
12367         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
12368 }
12369
12370 uint32_t CounterpartyChannelTransactionParameters_1new(void* ctx_TODO, uint32_t pubkeys_arg, jshort selected_contest_delay_arg) {
12371         LDKChannelPublicKeys pubkeys_arg_conv;
12372         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
12373         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
12374         if (pubkeys_arg_conv.inner != NULL)
12375                 pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
12376         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
12377         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12378         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12379         long ret_ref = (long)ret_var.inner;
12380         if (ret_var.is_owned) {
12381                 ret_ref |= 1;
12382         }
12383         return ret_ref;
12384 }
12385
12386 jboolean ChannelTransactionParameters_1is_1populated(void* ctx_TODO, uint32_t this_arg) {
12387         LDKChannelTransactionParameters this_arg_conv;
12388         this_arg_conv.inner = (void*)(this_arg & (~1));
12389         this_arg_conv.is_owned = false;
12390         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
12391         return ret_val;
12392 }
12393
12394 uint32_t ChannelTransactionParameters_1as_1holder_1broadcastable(void* ctx_TODO, uint32_t this_arg) {
12395         LDKChannelTransactionParameters this_arg_conv;
12396         this_arg_conv.inner = (void*)(this_arg & (~1));
12397         this_arg_conv.is_owned = false;
12398         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
12399         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12400         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12401         long ret_ref = (long)ret_var.inner;
12402         if (ret_var.is_owned) {
12403                 ret_ref |= 1;
12404         }
12405         return ret_ref;
12406 }
12407
12408 uint32_t ChannelTransactionParameters_1as_1counterparty_1broadcastable(void* ctx_TODO, uint32_t this_arg) {
12409         LDKChannelTransactionParameters this_arg_conv;
12410         this_arg_conv.inner = (void*)(this_arg & (~1));
12411         this_arg_conv.is_owned = false;
12412         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
12413         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12414         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12415         long ret_ref = (long)ret_var.inner;
12416         if (ret_var.is_owned) {
12417                 ret_ref |= 1;
12418         }
12419         return ret_ref;
12420 }
12421
12422 int8_tArray CounterpartyChannelTransactionParameters_1write(void* ctx_TODO, uint32_t obj) {
12423         LDKCounterpartyChannelTransactionParameters obj_conv;
12424         obj_conv.inner = (void*)(obj & (~1));
12425         obj_conv.is_owned = false;
12426         LDKCVec_u8Z arg_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
12427         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12428         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12429         CVec_u8Z_free(arg_var);
12430         return arg_arr;
12431 }
12432
12433 uint32_t CounterpartyChannelTransactionParameters_1read(void* ctx_TODO, int8_tArray ser) {
12434         LDKu8slice ser_ref;
12435         ser_ref.datalen = ser.len;
12436         ser_ref.data = ser.ptr;
12437         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_read(ser_ref);
12438         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12439         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12440         long ret_ref = (long)ret_var.inner;
12441         if (ret_var.is_owned) {
12442                 ret_ref |= 1;
12443         }
12444         return ret_ref;
12445 }
12446
12447 int8_tArray ChannelTransactionParameters_1write(void* ctx_TODO, uint32_t obj) {
12448         LDKChannelTransactionParameters obj_conv;
12449         obj_conv.inner = (void*)(obj & (~1));
12450         obj_conv.is_owned = false;
12451         LDKCVec_u8Z arg_var = ChannelTransactionParameters_write(&obj_conv);
12452         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12453         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12454         CVec_u8Z_free(arg_var);
12455         return arg_arr;
12456 }
12457
12458 uint32_t ChannelTransactionParameters_1read(void* ctx_TODO, int8_tArray ser) {
12459         LDKu8slice ser_ref;
12460         ser_ref.datalen = ser.len;
12461         ser_ref.data = ser.ptr;
12462         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_read(ser_ref);
12463         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12464         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12465         long ret_ref = (long)ret_var.inner;
12466         if (ret_var.is_owned) {
12467                 ret_ref |= 1;
12468         }
12469         return ret_ref;
12470 }
12471
12472 void DirectedChannelTransactionParameters_1free(void* ctx_TODO, uint32_t this_ptr) {
12473         LDKDirectedChannelTransactionParameters this_ptr_conv;
12474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12475         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12476         DirectedChannelTransactionParameters_free(this_ptr_conv);
12477 }
12478
12479 uint32_t DirectedChannelTransactionParameters_1broadcaster_1pubkeys(void* ctx_TODO, uint32_t this_arg) {
12480         LDKDirectedChannelTransactionParameters this_arg_conv;
12481         this_arg_conv.inner = (void*)(this_arg & (~1));
12482         this_arg_conv.is_owned = false;
12483         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
12484         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12485         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12486         long ret_ref = (long)ret_var.inner;
12487         if (ret_var.is_owned) {
12488                 ret_ref |= 1;
12489         }
12490         return ret_ref;
12491 }
12492
12493 uint32_t DirectedChannelTransactionParameters_1countersignatory_1pubkeys(void* ctx_TODO, uint32_t this_arg) {
12494         LDKDirectedChannelTransactionParameters this_arg_conv;
12495         this_arg_conv.inner = (void*)(this_arg & (~1));
12496         this_arg_conv.is_owned = false;
12497         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
12498         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12499         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12500         long ret_ref = (long)ret_var.inner;
12501         if (ret_var.is_owned) {
12502                 ret_ref |= 1;
12503         }
12504         return ret_ref;
12505 }
12506
12507 jshort DirectedChannelTransactionParameters_1contest_1delay(void* ctx_TODO, uint32_t this_arg) {
12508         LDKDirectedChannelTransactionParameters this_arg_conv;
12509         this_arg_conv.inner = (void*)(this_arg & (~1));
12510         this_arg_conv.is_owned = false;
12511         jshort ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
12512         return ret_val;
12513 }
12514
12515 jboolean DirectedChannelTransactionParameters_1is_1outbound(void* ctx_TODO, uint32_t this_arg) {
12516         LDKDirectedChannelTransactionParameters this_arg_conv;
12517         this_arg_conv.inner = (void*)(this_arg & (~1));
12518         this_arg_conv.is_owned = false;
12519         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
12520         return ret_val;
12521 }
12522
12523 uint32_t DirectedChannelTransactionParameters_1funding_1outpoint(void* ctx_TODO, uint32_t this_arg) {
12524         LDKDirectedChannelTransactionParameters this_arg_conv;
12525         this_arg_conv.inner = (void*)(this_arg & (~1));
12526         this_arg_conv.is_owned = false;
12527         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
12528         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12529         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12530         long ret_ref = (long)ret_var.inner;
12531         if (ret_var.is_owned) {
12532                 ret_ref |= 1;
12533         }
12534         return ret_ref;
12535 }
12536
12537 void HolderCommitmentTransaction_1free(void* ctx_TODO, uint32_t this_ptr) {
12538         LDKHolderCommitmentTransaction this_ptr_conv;
12539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12540         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12541         HolderCommitmentTransaction_free(this_ptr_conv);
12542 }
12543
12544 uint32_t HolderCommitmentTransaction_1clone(void* ctx_TODO, uint32_t orig) {
12545         LDKHolderCommitmentTransaction orig_conv;
12546         orig_conv.inner = (void*)(orig & (~1));
12547         orig_conv.is_owned = false;
12548         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
12549         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12550         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12551         long ret_ref = (long)ret_var.inner;
12552         if (ret_var.is_owned) {
12553                 ret_ref |= 1;
12554         }
12555         return ret_ref;
12556 }
12557
12558 int8_tArray HolderCommitmentTransaction_1get_1counterparty_1sig(void* ctx_TODO, uint32_t this_ptr) {
12559         LDKHolderCommitmentTransaction this_ptr_conv;
12560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12561         this_ptr_conv.is_owned = false;
12562         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
12563         memcpy(arg_arr.ptr, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
12564         return arg_arr;
12565 }
12566
12567 void HolderCommitmentTransaction_1set_1counterparty_1sig(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12568         LDKHolderCommitmentTransaction this_ptr_conv;
12569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12570         this_ptr_conv.is_owned = false;
12571         LDKSignature val_ref;
12572         CHECK(val.len == 64);
12573         memcpy(val_ref.compact_form, val.ptr, 64);
12574         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
12575 }
12576
12577 void HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
12578         LDKHolderCommitmentTransaction this_ptr_conv;
12579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12580         this_ptr_conv.is_owned = false;
12581         LDKCVec_SignatureZ val_constr;
12582         val_constr.datalen = val.len;
12583         if (val_constr.datalen > 0)
12584                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12585         else
12586                 val_constr.data = NULL;
12587         int8_tArray* val_vals = (int8_tArray*) val.ptr;
12588         for (size_t i = 0; i < val_constr.datalen; i++) {
12589                 int8_tArray arr_conv_8 = val_vals[i];
12590                 LDKSignature arr_conv_8_ref;
12591                 CHECK(arr_conv_8.len == 64);
12592                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
12593                 val_constr.data[i] = arr_conv_8_ref;
12594         }
12595         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
12596 }
12597
12598 int8_tArray HolderCommitmentTransaction_1write(void* ctx_TODO, uint32_t obj) {
12599         LDKHolderCommitmentTransaction obj_conv;
12600         obj_conv.inner = (void*)(obj & (~1));
12601         obj_conv.is_owned = false;
12602         LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
12603         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12604         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12605         CVec_u8Z_free(arg_var);
12606         return arg_arr;
12607 }
12608
12609 uint32_t HolderCommitmentTransaction_1read(void* ctx_TODO, int8_tArray ser) {
12610         LDKu8slice ser_ref;
12611         ser_ref.datalen = ser.len;
12612         ser_ref.data = ser.ptr;
12613         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_read(ser_ref);
12614         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12615         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12616         long ret_ref = (long)ret_var.inner;
12617         if (ret_var.is_owned) {
12618                 ret_ref |= 1;
12619         }
12620         return ret_ref;
12621 }
12622
12623 uint32_t HolderCommitmentTransaction_1new(void* ctx_TODO, uint32_t commitment_tx, int8_tArray counterparty_sig, uint32_tArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
12624         LDKCommitmentTransaction commitment_tx_conv;
12625         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
12626         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
12627         if (commitment_tx_conv.inner != NULL)
12628                 commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
12629         LDKSignature counterparty_sig_ref;
12630         CHECK(counterparty_sig.len == 64);
12631         memcpy(counterparty_sig_ref.compact_form, counterparty_sig.ptr, 64);
12632         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
12633         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs.len;
12634         if (counterparty_htlc_sigs_constr.datalen > 0)
12635                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
12636         else
12637                 counterparty_htlc_sigs_constr.data = NULL;
12638         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*) counterparty_htlc_sigs.ptr;
12639         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
12640                 int8_tArray arr_conv_8 = counterparty_htlc_sigs_vals[i];
12641                 LDKSignature arr_conv_8_ref;
12642                 CHECK(arr_conv_8.len == 64);
12643                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
12644                 counterparty_htlc_sigs_constr.data[i] = arr_conv_8_ref;
12645         }
12646         LDKPublicKey holder_funding_key_ref;
12647         CHECK(holder_funding_key.len == 33);
12648         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key.ptr, 33);
12649         LDKPublicKey counterparty_funding_key_ref;
12650         CHECK(counterparty_funding_key.len == 33);
12651         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key.ptr, 33);
12652         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
12653         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12654         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12655         long ret_ref = (long)ret_var.inner;
12656         if (ret_var.is_owned) {
12657                 ret_ref |= 1;
12658         }
12659         return ret_ref;
12660 }
12661
12662 void BuiltCommitmentTransaction_1free(void* ctx_TODO, uint32_t this_ptr) {
12663         LDKBuiltCommitmentTransaction this_ptr_conv;
12664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12665         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12666         BuiltCommitmentTransaction_free(this_ptr_conv);
12667 }
12668
12669 uint32_t BuiltCommitmentTransaction_1clone(void* ctx_TODO, uint32_t orig) {
12670         LDKBuiltCommitmentTransaction orig_conv;
12671         orig_conv.inner = (void*)(orig & (~1));
12672         orig_conv.is_owned = false;
12673         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
12674         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12675         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12676         long ret_ref = (long)ret_var.inner;
12677         if (ret_var.is_owned) {
12678                 ret_ref |= 1;
12679         }
12680         return ret_ref;
12681 }
12682
12683 int8_tArray BuiltCommitmentTransaction_1get_1transaction(void* ctx_TODO, uint32_t this_ptr) {
12684         LDKBuiltCommitmentTransaction this_ptr_conv;
12685         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12686         this_ptr_conv.is_owned = false;
12687         LDKTransaction arg_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
12688         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12689         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12690         Transaction_free(arg_var);
12691         return arg_arr;
12692 }
12693
12694 void BuiltCommitmentTransaction_1set_1transaction(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12695         LDKBuiltCommitmentTransaction this_ptr_conv;
12696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12697         this_ptr_conv.is_owned = false;
12698         LDKTransaction val_ref;
12699         val_ref.datalen = val.len;
12700         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
12701         memcpy(val_ref.data, val.ptr, val_ref.datalen);
12702         val_ref.data_is_owned = true;
12703         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
12704 }
12705
12706 int8_tArray BuiltCommitmentTransaction_1get_1txid(void* ctx_TODO, uint32_t this_ptr) {
12707         LDKBuiltCommitmentTransaction this_ptr_conv;
12708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12709         this_ptr_conv.is_owned = false;
12710         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
12711         memcpy(ret_arr.ptr, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
12712         return ret_arr;
12713 }
12714
12715 void BuiltCommitmentTransaction_1set_1txid(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12716         LDKBuiltCommitmentTransaction this_ptr_conv;
12717         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12718         this_ptr_conv.is_owned = false;
12719         LDKThirtyTwoBytes val_ref;
12720         CHECK(val.len == 32);
12721         memcpy(val_ref.data, val.ptr, 32);
12722         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
12723 }
12724
12725 uint32_t BuiltCommitmentTransaction_1new(void* ctx_TODO, int8_tArray transaction_arg, int8_tArray txid_arg) {
12726         LDKTransaction transaction_arg_ref;
12727         transaction_arg_ref.datalen = transaction_arg.len;
12728         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
12729         memcpy(transaction_arg_ref.data, transaction_arg.ptr, transaction_arg_ref.datalen);
12730         transaction_arg_ref.data_is_owned = true;
12731         LDKThirtyTwoBytes txid_arg_ref;
12732         CHECK(txid_arg.len == 32);
12733         memcpy(txid_arg_ref.data, txid_arg.ptr, 32);
12734         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
12735         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12736         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12737         long ret_ref = (long)ret_var.inner;
12738         if (ret_var.is_owned) {
12739                 ret_ref |= 1;
12740         }
12741         return ret_ref;
12742 }
12743
12744 int8_tArray BuiltCommitmentTransaction_1write(void* ctx_TODO, uint32_t obj) {
12745         LDKBuiltCommitmentTransaction obj_conv;
12746         obj_conv.inner = (void*)(obj & (~1));
12747         obj_conv.is_owned = false;
12748         LDKCVec_u8Z arg_var = BuiltCommitmentTransaction_write(&obj_conv);
12749         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12750         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12751         CVec_u8Z_free(arg_var);
12752         return arg_arr;
12753 }
12754
12755 uint32_t BuiltCommitmentTransaction_1read(void* ctx_TODO, int8_tArray ser) {
12756         LDKu8slice ser_ref;
12757         ser_ref.datalen = ser.len;
12758         ser_ref.data = ser.ptr;
12759         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_read(ser_ref);
12760         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12761         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12762         long ret_ref = (long)ret_var.inner;
12763         if (ret_var.is_owned) {
12764                 ret_ref |= 1;
12765         }
12766         return ret_ref;
12767 }
12768
12769 int8_tArray BuiltCommitmentTransaction_1get_1sighash_1all(void* ctx_TODO, uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
12770         LDKBuiltCommitmentTransaction this_arg_conv;
12771         this_arg_conv.inner = (void*)(this_arg & (~1));
12772         this_arg_conv.is_owned = false;
12773         LDKu8slice funding_redeemscript_ref;
12774         funding_redeemscript_ref.datalen = funding_redeemscript.len;
12775         funding_redeemscript_ref.data = funding_redeemscript.ptr;
12776         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
12777         memcpy(arg_arr.ptr, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
12778         return arg_arr;
12779 }
12780
12781 int8_tArray BuiltCommitmentTransaction_1sign(void* ctx_TODO, uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
12782         LDKBuiltCommitmentTransaction this_arg_conv;
12783         this_arg_conv.inner = (void*)(this_arg & (~1));
12784         this_arg_conv.is_owned = false;
12785         unsigned char funding_key_arr[32];
12786         CHECK(funding_key.len == 32);
12787         memcpy(funding_key_arr, funding_key.ptr, 32);
12788         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
12789         LDKu8slice funding_redeemscript_ref;
12790         funding_redeemscript_ref.datalen = funding_redeemscript.len;
12791         funding_redeemscript_ref.data = funding_redeemscript.ptr;
12792         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
12793         memcpy(arg_arr.ptr, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
12794         return arg_arr;
12795 }
12796
12797 void CommitmentTransaction_1free(void* ctx_TODO, uint32_t this_ptr) {
12798         LDKCommitmentTransaction this_ptr_conv;
12799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12800         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12801         CommitmentTransaction_free(this_ptr_conv);
12802 }
12803
12804 uint32_t CommitmentTransaction_1clone(void* ctx_TODO, uint32_t orig) {
12805         LDKCommitmentTransaction orig_conv;
12806         orig_conv.inner = (void*)(orig & (~1));
12807         orig_conv.is_owned = false;
12808         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
12809         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12810         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12811         long ret_ref = (long)ret_var.inner;
12812         if (ret_var.is_owned) {
12813                 ret_ref |= 1;
12814         }
12815         return ret_ref;
12816 }
12817
12818 int8_tArray CommitmentTransaction_1write(void* ctx_TODO, uint32_t obj) {
12819         LDKCommitmentTransaction obj_conv;
12820         obj_conv.inner = (void*)(obj & (~1));
12821         obj_conv.is_owned = false;
12822         LDKCVec_u8Z arg_var = CommitmentTransaction_write(&obj_conv);
12823         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12824         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12825         CVec_u8Z_free(arg_var);
12826         return arg_arr;
12827 }
12828
12829 uint32_t CommitmentTransaction_1read(void* ctx_TODO, int8_tArray ser) {
12830         LDKu8slice ser_ref;
12831         ser_ref.datalen = ser.len;
12832         ser_ref.data = ser.ptr;
12833         LDKCommitmentTransaction ret_var = CommitmentTransaction_read(ser_ref);
12834         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12835         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12836         long ret_ref = (long)ret_var.inner;
12837         if (ret_var.is_owned) {
12838                 ret_ref |= 1;
12839         }
12840         return ret_ref;
12841 }
12842
12843 int64_t CommitmentTransaction_1commitment_1number(void* ctx_TODO, uint32_t this_arg) {
12844         LDKCommitmentTransaction this_arg_conv;
12845         this_arg_conv.inner = (void*)(this_arg & (~1));
12846         this_arg_conv.is_owned = false;
12847         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
12848         return ret_val;
12849 }
12850
12851 int64_t CommitmentTransaction_1to_1broadcaster_1value_1sat(void* ctx_TODO, uint32_t this_arg) {
12852         LDKCommitmentTransaction this_arg_conv;
12853         this_arg_conv.inner = (void*)(this_arg & (~1));
12854         this_arg_conv.is_owned = false;
12855         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
12856         return ret_val;
12857 }
12858
12859 int64_t CommitmentTransaction_1to_1countersignatory_1value_1sat(void* ctx_TODO, uint32_t this_arg) {
12860         LDKCommitmentTransaction this_arg_conv;
12861         this_arg_conv.inner = (void*)(this_arg & (~1));
12862         this_arg_conv.is_owned = false;
12863         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
12864         return ret_val;
12865 }
12866
12867 int32_t CommitmentTransaction_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_arg) {
12868         LDKCommitmentTransaction this_arg_conv;
12869         this_arg_conv.inner = (void*)(this_arg & (~1));
12870         this_arg_conv.is_owned = false;
12871         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
12872         return ret_val;
12873 }
12874
12875 uint32_t CommitmentTransaction_1trust(void* ctx_TODO, uint32_t this_arg) {
12876         LDKCommitmentTransaction this_arg_conv;
12877         this_arg_conv.inner = (void*)(this_arg & (~1));
12878         this_arg_conv.is_owned = false;
12879         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
12880         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12881         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12882         long ret_ref = (long)ret_var.inner;
12883         if (ret_var.is_owned) {
12884                 ret_ref |= 1;
12885         }
12886         return ret_ref;
12887 }
12888
12889 uint32_t CommitmentTransaction_1verify(void* ctx_TODO, uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
12890         LDKCommitmentTransaction this_arg_conv;
12891         this_arg_conv.inner = (void*)(this_arg & (~1));
12892         this_arg_conv.is_owned = false;
12893         LDKDirectedChannelTransactionParameters channel_parameters_conv;
12894         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
12895         channel_parameters_conv.is_owned = false;
12896         LDKChannelPublicKeys broadcaster_keys_conv;
12897         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
12898         broadcaster_keys_conv.is_owned = false;
12899         LDKChannelPublicKeys countersignatory_keys_conv;
12900         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
12901         countersignatory_keys_conv.is_owned = false;
12902         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
12903         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
12904         return (long)ret_conv;
12905 }
12906
12907 void TrustedCommitmentTransaction_1free(void* ctx_TODO, uint32_t this_ptr) {
12908         LDKTrustedCommitmentTransaction this_ptr_conv;
12909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12910         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12911         TrustedCommitmentTransaction_free(this_ptr_conv);
12912 }
12913
12914 int8_tArray TrustedCommitmentTransaction_1txid(void* ctx_TODO, uint32_t this_arg) {
12915         LDKTrustedCommitmentTransaction this_arg_conv;
12916         this_arg_conv.inner = (void*)(this_arg & (~1));
12917         this_arg_conv.is_owned = false;
12918         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
12919         memcpy(arg_arr.ptr, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
12920         return arg_arr;
12921 }
12922
12923 uint32_t TrustedCommitmentTransaction_1built_1transaction(void* ctx_TODO, uint32_t this_arg) {
12924         LDKTrustedCommitmentTransaction this_arg_conv;
12925         this_arg_conv.inner = (void*)(this_arg & (~1));
12926         this_arg_conv.is_owned = false;
12927         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
12928         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12929         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12930         long ret_ref = (long)ret_var.inner;
12931         if (ret_var.is_owned) {
12932                 ret_ref |= 1;
12933         }
12934         return ret_ref;
12935 }
12936
12937 uint32_t TrustedCommitmentTransaction_1keys(void* ctx_TODO, uint32_t this_arg) {
12938         LDKTrustedCommitmentTransaction this_arg_conv;
12939         this_arg_conv.inner = (void*)(this_arg & (~1));
12940         this_arg_conv.is_owned = false;
12941         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
12942         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12943         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12944         long ret_ref = (long)ret_var.inner;
12945         if (ret_var.is_owned) {
12946                 ret_ref |= 1;
12947         }
12948         return ret_ref;
12949 }
12950
12951 uint32_t TrustedCommitmentTransaction_1get_1htlc_1sigs(void* ctx_TODO, uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
12952         LDKTrustedCommitmentTransaction this_arg_conv;
12953         this_arg_conv.inner = (void*)(this_arg & (~1));
12954         this_arg_conv.is_owned = false;
12955         unsigned char htlc_base_key_arr[32];
12956         CHECK(htlc_base_key.len == 32);
12957         memcpy(htlc_base_key_arr, htlc_base_key.ptr, 32);
12958         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
12959         LDKDirectedChannelTransactionParameters channel_parameters_conv;
12960         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
12961         channel_parameters_conv.is_owned = false;
12962         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
12963         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
12964         return (long)ret_conv;
12965 }
12966
12967 int64_t get_1commitment_1transaction_1number_1obscure_1factor(void* ctx_TODO, int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
12968         LDKPublicKey broadcaster_payment_basepoint_ref;
12969         CHECK(broadcaster_payment_basepoint.len == 33);
12970         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint.ptr, 33);
12971         LDKPublicKey countersignatory_payment_basepoint_ref;
12972         CHECK(countersignatory_payment_basepoint.len == 33);
12973         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint.ptr, 33);
12974         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
12975         return ret_val;
12976 }
12977
12978 void InitFeatures_1free(void* ctx_TODO, uint32_t this_ptr) {
12979         LDKInitFeatures this_ptr_conv;
12980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12981         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12982         InitFeatures_free(this_ptr_conv);
12983 }
12984
12985 void NodeFeatures_1free(void* ctx_TODO, uint32_t this_ptr) {
12986         LDKNodeFeatures this_ptr_conv;
12987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12988         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12989         NodeFeatures_free(this_ptr_conv);
12990 }
12991
12992 void ChannelFeatures_1free(void* ctx_TODO, uint32_t this_ptr) {
12993         LDKChannelFeatures this_ptr_conv;
12994         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12995         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12996         ChannelFeatures_free(this_ptr_conv);
12997 }
12998
12999 void RouteHop_1free(void* ctx_TODO, uint32_t this_ptr) {
13000         LDKRouteHop this_ptr_conv;
13001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13002         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13003         RouteHop_free(this_ptr_conv);
13004 }
13005
13006 uint32_t RouteHop_1clone(void* ctx_TODO, uint32_t orig) {
13007         LDKRouteHop orig_conv;
13008         orig_conv.inner = (void*)(orig & (~1));
13009         orig_conv.is_owned = false;
13010         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
13011         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13012         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13013         long ret_ref = (long)ret_var.inner;
13014         if (ret_var.is_owned) {
13015                 ret_ref |= 1;
13016         }
13017         return ret_ref;
13018 }
13019
13020 int8_tArray RouteHop_1get_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
13021         LDKRouteHop this_ptr_conv;
13022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13023         this_ptr_conv.is_owned = false;
13024         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
13025         memcpy(arg_arr.ptr, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
13026         return arg_arr;
13027 }
13028
13029 void RouteHop_1set_1pubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13030         LDKRouteHop this_ptr_conv;
13031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13032         this_ptr_conv.is_owned = false;
13033         LDKPublicKey val_ref;
13034         CHECK(val.len == 33);
13035         memcpy(val_ref.compressed_form, val.ptr, 33);
13036         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
13037 }
13038
13039 uint32_t RouteHop_1get_1node_1features(void* ctx_TODO, uint32_t this_ptr) {
13040         LDKRouteHop this_ptr_conv;
13041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13042         this_ptr_conv.is_owned = false;
13043         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
13044         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13045         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13046         long ret_ref = (long)ret_var.inner;
13047         if (ret_var.is_owned) {
13048                 ret_ref |= 1;
13049         }
13050         return ret_ref;
13051 }
13052
13053 void RouteHop_1set_1node_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13054         LDKRouteHop this_ptr_conv;
13055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13056         this_ptr_conv.is_owned = false;
13057         LDKNodeFeatures val_conv;
13058         val_conv.inner = (void*)(val & (~1));
13059         val_conv.is_owned = (val & 1) || (val == 0);
13060         // Warning: we may need a move here but can't clone!
13061         RouteHop_set_node_features(&this_ptr_conv, val_conv);
13062 }
13063
13064 int64_t RouteHop_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
13065         LDKRouteHop this_ptr_conv;
13066         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13067         this_ptr_conv.is_owned = false;
13068         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
13069         return ret_val;
13070 }
13071
13072 void RouteHop_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13073         LDKRouteHop this_ptr_conv;
13074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13075         this_ptr_conv.is_owned = false;
13076         RouteHop_set_short_channel_id(&this_ptr_conv, val);
13077 }
13078
13079 uint32_t RouteHop_1get_1channel_1features(void* ctx_TODO, uint32_t this_ptr) {
13080         LDKRouteHop this_ptr_conv;
13081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13082         this_ptr_conv.is_owned = false;
13083         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
13084         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13085         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13086         long ret_ref = (long)ret_var.inner;
13087         if (ret_var.is_owned) {
13088                 ret_ref |= 1;
13089         }
13090         return ret_ref;
13091 }
13092
13093 void RouteHop_1set_1channel_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13094         LDKRouteHop this_ptr_conv;
13095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13096         this_ptr_conv.is_owned = false;
13097         LDKChannelFeatures val_conv;
13098         val_conv.inner = (void*)(val & (~1));
13099         val_conv.is_owned = (val & 1) || (val == 0);
13100         // Warning: we may need a move here but can't clone!
13101         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
13102 }
13103
13104 int64_t RouteHop_1get_1fee_1msat(void* ctx_TODO, uint32_t this_ptr) {
13105         LDKRouteHop this_ptr_conv;
13106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13107         this_ptr_conv.is_owned = false;
13108         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
13109         return ret_val;
13110 }
13111
13112 void RouteHop_1set_1fee_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13113         LDKRouteHop this_ptr_conv;
13114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13115         this_ptr_conv.is_owned = false;
13116         RouteHop_set_fee_msat(&this_ptr_conv, val);
13117 }
13118
13119 int32_t RouteHop_1get_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr) {
13120         LDKRouteHop this_ptr_conv;
13121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13122         this_ptr_conv.is_owned = false;
13123         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
13124         return ret_val;
13125 }
13126
13127 void RouteHop_1set_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
13128         LDKRouteHop this_ptr_conv;
13129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13130         this_ptr_conv.is_owned = false;
13131         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
13132 }
13133
13134 uint32_t RouteHop_1new(void* ctx_TODO, 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) {
13135         LDKPublicKey pubkey_arg_ref;
13136         CHECK(pubkey_arg.len == 33);
13137         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg.ptr, 33);
13138         LDKNodeFeatures node_features_arg_conv;
13139         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
13140         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
13141         // Warning: we may need a move here but can't clone!
13142         LDKChannelFeatures channel_features_arg_conv;
13143         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
13144         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
13145         // Warning: we may need a move here but can't clone!
13146         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);
13147         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13148         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13149         long ret_ref = (long)ret_var.inner;
13150         if (ret_var.is_owned) {
13151                 ret_ref |= 1;
13152         }
13153         return ret_ref;
13154 }
13155
13156 void Route_1free(void* ctx_TODO, uint32_t this_ptr) {
13157         LDKRoute this_ptr_conv;
13158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13159         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13160         Route_free(this_ptr_conv);
13161 }
13162
13163 uint32_t Route_1clone(void* ctx_TODO, uint32_t orig) {
13164         LDKRoute orig_conv;
13165         orig_conv.inner = (void*)(orig & (~1));
13166         orig_conv.is_owned = false;
13167         LDKRoute ret_var = Route_clone(&orig_conv);
13168         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13169         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13170         long ret_ref = (long)ret_var.inner;
13171         if (ret_var.is_owned) {
13172                 ret_ref |= 1;
13173         }
13174         return ret_ref;
13175 }
13176
13177 void Route_1set_1paths(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
13178         LDKRoute this_ptr_conv;
13179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13180         this_ptr_conv.is_owned = false;
13181         LDKCVec_CVec_RouteHopZZ val_constr;
13182         val_constr.datalen = val.len;
13183         if (val_constr.datalen > 0)
13184                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
13185         else
13186                 val_constr.data = NULL;
13187         uint32_tArray* val_vals = (uint32_tArray*) val.ptr;
13188         for (size_t m = 0; m < val_constr.datalen; m++) {
13189                 uint32_tArray arr_conv_12 = val_vals[m];
13190                 LDKCVec_RouteHopZ arr_conv_12_constr;
13191                 arr_conv_12_constr.datalen = arr_conv_12.len;
13192                 if (arr_conv_12_constr.datalen > 0)
13193                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13194                 else
13195                         arr_conv_12_constr.data = NULL;
13196                 uint32_t* arr_conv_12_vals = (uint32_t*) arr_conv_12.ptr;
13197                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
13198                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
13199                         LDKRouteHop arr_conv_10_conv;
13200                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
13201                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
13202                         if (arr_conv_10_conv.inner != NULL)
13203                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
13204                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
13205                 }
13206                 val_constr.data[m] = arr_conv_12_constr;
13207         }
13208         Route_set_paths(&this_ptr_conv, val_constr);
13209 }
13210
13211 uint32_t Route_1new(void* ctx_TODO, uint32_tArray paths_arg) {
13212         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
13213         paths_arg_constr.datalen = paths_arg.len;
13214         if (paths_arg_constr.datalen > 0)
13215                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
13216         else
13217                 paths_arg_constr.data = NULL;
13218         uint32_tArray* paths_arg_vals = (uint32_tArray*) paths_arg.ptr;
13219         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
13220                 uint32_tArray arr_conv_12 = paths_arg_vals[m];
13221                 LDKCVec_RouteHopZ arr_conv_12_constr;
13222                 arr_conv_12_constr.datalen = arr_conv_12.len;
13223                 if (arr_conv_12_constr.datalen > 0)
13224                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13225                 else
13226                         arr_conv_12_constr.data = NULL;
13227                 uint32_t* arr_conv_12_vals = (uint32_t*) arr_conv_12.ptr;
13228                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
13229                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
13230                         LDKRouteHop arr_conv_10_conv;
13231                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
13232                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
13233                         if (arr_conv_10_conv.inner != NULL)
13234                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
13235                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
13236                 }
13237                 paths_arg_constr.data[m] = arr_conv_12_constr;
13238         }
13239         LDKRoute ret_var = Route_new(paths_arg_constr);
13240         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13241         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13242         long ret_ref = (long)ret_var.inner;
13243         if (ret_var.is_owned) {
13244                 ret_ref |= 1;
13245         }
13246         return ret_ref;
13247 }
13248
13249 int8_tArray Route_1write(void* ctx_TODO, uint32_t obj) {
13250         LDKRoute obj_conv;
13251         obj_conv.inner = (void*)(obj & (~1));
13252         obj_conv.is_owned = false;
13253         LDKCVec_u8Z arg_var = Route_write(&obj_conv);
13254         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13255         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13256         CVec_u8Z_free(arg_var);
13257         return arg_arr;
13258 }
13259
13260 uint32_t Route_1read(void* ctx_TODO, int8_tArray ser) {
13261         LDKu8slice ser_ref;
13262         ser_ref.datalen = ser.len;
13263         ser_ref.data = ser.ptr;
13264         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
13265         *ret_conv = Route_read(ser_ref);
13266         return (long)ret_conv;
13267 }
13268
13269 void RouteHint_1free(void* ctx_TODO, uint32_t this_ptr) {
13270         LDKRouteHint this_ptr_conv;
13271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13272         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13273         RouteHint_free(this_ptr_conv);
13274 }
13275
13276 uint32_t RouteHint_1clone(void* ctx_TODO, uint32_t orig) {
13277         LDKRouteHint orig_conv;
13278         orig_conv.inner = (void*)(orig & (~1));
13279         orig_conv.is_owned = false;
13280         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
13281         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13282         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13283         long ret_ref = (long)ret_var.inner;
13284         if (ret_var.is_owned) {
13285                 ret_ref |= 1;
13286         }
13287         return ret_ref;
13288 }
13289
13290 int8_tArray RouteHint_1get_1src_1node_1id(void* ctx_TODO, uint32_t this_ptr) {
13291         LDKRouteHint this_ptr_conv;
13292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13293         this_ptr_conv.is_owned = false;
13294         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
13295         memcpy(arg_arr.ptr, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
13296         return arg_arr;
13297 }
13298
13299 void RouteHint_1set_1src_1node_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13300         LDKRouteHint this_ptr_conv;
13301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13302         this_ptr_conv.is_owned = false;
13303         LDKPublicKey val_ref;
13304         CHECK(val.len == 33);
13305         memcpy(val_ref.compressed_form, val.ptr, 33);
13306         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
13307 }
13308
13309 int64_t RouteHint_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
13310         LDKRouteHint this_ptr_conv;
13311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13312         this_ptr_conv.is_owned = false;
13313         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
13314         return ret_val;
13315 }
13316
13317 void RouteHint_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13318         LDKRouteHint this_ptr_conv;
13319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13320         this_ptr_conv.is_owned = false;
13321         RouteHint_set_short_channel_id(&this_ptr_conv, val);
13322 }
13323
13324 uint32_t RouteHint_1get_1fees(void* ctx_TODO, uint32_t this_ptr) {
13325         LDKRouteHint this_ptr_conv;
13326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13327         this_ptr_conv.is_owned = false;
13328         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
13329         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13330         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13331         long ret_ref = (long)ret_var.inner;
13332         if (ret_var.is_owned) {
13333                 ret_ref |= 1;
13334         }
13335         return ret_ref;
13336 }
13337
13338 void RouteHint_1set_1fees(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13339         LDKRouteHint this_ptr_conv;
13340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13341         this_ptr_conv.is_owned = false;
13342         LDKRoutingFees val_conv;
13343         val_conv.inner = (void*)(val & (~1));
13344         val_conv.is_owned = (val & 1) || (val == 0);
13345         if (val_conv.inner != NULL)
13346                 val_conv = RoutingFees_clone(&val_conv);
13347         RouteHint_set_fees(&this_ptr_conv, val_conv);
13348 }
13349
13350 jshort RouteHint_1get_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr) {
13351         LDKRouteHint this_ptr_conv;
13352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13353         this_ptr_conv.is_owned = false;
13354         jshort ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
13355         return ret_val;
13356 }
13357
13358 void RouteHint_1set_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr, jshort val) {
13359         LDKRouteHint this_ptr_conv;
13360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13361         this_ptr_conv.is_owned = false;
13362         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
13363 }
13364
13365 int64_t RouteHint_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
13366         LDKRouteHint this_ptr_conv;
13367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13368         this_ptr_conv.is_owned = false;
13369         int64_t ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
13370         return ret_val;
13371 }
13372
13373 void RouteHint_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13374         LDKRouteHint this_ptr_conv;
13375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13376         this_ptr_conv.is_owned = false;
13377         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
13378 }
13379
13380 uint32_t RouteHint_1new(void* ctx_TODO, int8_tArray src_node_id_arg, int64_t short_channel_id_arg, uint32_t fees_arg, jshort cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg) {
13381         LDKPublicKey src_node_id_arg_ref;
13382         CHECK(src_node_id_arg.len == 33);
13383         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg.ptr, 33);
13384         LDKRoutingFees fees_arg_conv;
13385         fees_arg_conv.inner = (void*)(fees_arg & (~1));
13386         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
13387         if (fees_arg_conv.inner != NULL)
13388                 fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
13389         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);
13390         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13391         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13392         long ret_ref = (long)ret_var.inner;
13393         if (ret_var.is_owned) {
13394                 ret_ref |= 1;
13395         }
13396         return ret_ref;
13397 }
13398
13399 uint32_t get_1route(void* ctx_TODO, 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) {
13400         LDKPublicKey our_node_id_ref;
13401         CHECK(our_node_id.len == 33);
13402         memcpy(our_node_id_ref.compressed_form, our_node_id.ptr, 33);
13403         LDKNetworkGraph network_conv;
13404         network_conv.inner = (void*)(network & (~1));
13405         network_conv.is_owned = false;
13406         LDKPublicKey target_ref;
13407         CHECK(target.len == 33);
13408         memcpy(target_ref.compressed_form, target.ptr, 33);
13409         LDKCVec_ChannelDetailsZ first_hops_constr;
13410         first_hops_constr.datalen = first_hops.len;
13411         if (first_hops_constr.datalen > 0)
13412                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
13413         else
13414                 first_hops_constr.data = NULL;
13415         uint32_t* first_hops_vals = (uint32_t*) first_hops.ptr;
13416         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
13417                 uint32_t arr_conv_16 = first_hops_vals[q];
13418                 LDKChannelDetails arr_conv_16_conv;
13419                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
13420                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
13421                 first_hops_constr.data[q] = arr_conv_16_conv;
13422         }
13423         LDKCVec_RouteHintZ last_hops_constr;
13424         last_hops_constr.datalen = last_hops.len;
13425         if (last_hops_constr.datalen > 0)
13426                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
13427         else
13428                 last_hops_constr.data = NULL;
13429         uint32_t* last_hops_vals = (uint32_t*) last_hops.ptr;
13430         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
13431                 uint32_t arr_conv_11 = last_hops_vals[l];
13432                 LDKRouteHint arr_conv_11_conv;
13433                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
13434                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
13435                 if (arr_conv_11_conv.inner != NULL)
13436                         arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
13437                 last_hops_constr.data[l] = arr_conv_11_conv;
13438         }
13439         LDKLogger logger_conv = *(LDKLogger*)logger;
13440         if (logger_conv.free == LDKLogger_JCalls_free) {
13441                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13442                 LDKLogger_JCalls_clone(logger_conv.this_arg);
13443         }
13444         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
13445         *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);
13446         FREE(first_hops_constr.data);
13447         return (long)ret_conv;
13448 }
13449
13450 void NetworkGraph_1free(void* ctx_TODO, uint32_t this_ptr) {
13451         LDKNetworkGraph this_ptr_conv;
13452         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13453         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13454         NetworkGraph_free(this_ptr_conv);
13455 }
13456
13457 void LockedNetworkGraph_1free(void* ctx_TODO, uint32_t this_ptr) {
13458         LDKLockedNetworkGraph this_ptr_conv;
13459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13460         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13461         LockedNetworkGraph_free(this_ptr_conv);
13462 }
13463
13464 void NetGraphMsgHandler_1free(void* ctx_TODO, uint32_t this_ptr) {
13465         LDKNetGraphMsgHandler this_ptr_conv;
13466         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13467         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13468         NetGraphMsgHandler_free(this_ptr_conv);
13469 }
13470
13471 uint32_t NetGraphMsgHandler_1new(void* ctx_TODO, int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
13472         LDKThirtyTwoBytes genesis_hash_ref;
13473         CHECK(genesis_hash.len == 32);
13474         memcpy(genesis_hash_ref.data, genesis_hash.ptr, 32);
13475         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
13476         LDKLogger logger_conv = *(LDKLogger*)logger;
13477         if (logger_conv.free == LDKLogger_JCalls_free) {
13478                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13479                 LDKLogger_JCalls_clone(logger_conv.this_arg);
13480         }
13481         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv, logger_conv);
13482         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13483         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13484         long ret_ref = (long)ret_var.inner;
13485         if (ret_var.is_owned) {
13486                 ret_ref |= 1;
13487         }
13488         return ret_ref;
13489 }
13490
13491 uint32_t NetGraphMsgHandler_1from_1net_1graph(void* ctx_TODO, uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
13492         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
13493         LDKLogger logger_conv = *(LDKLogger*)logger;
13494         if (logger_conv.free == LDKLogger_JCalls_free) {
13495                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13496                 LDKLogger_JCalls_clone(logger_conv.this_arg);
13497         }
13498         LDKNetworkGraph network_graph_conv;
13499         network_graph_conv.inner = (void*)(network_graph & (~1));
13500         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
13501         // Warning: we may need a move here but can't clone!
13502         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
13503         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13504         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13505         long ret_ref = (long)ret_var.inner;
13506         if (ret_var.is_owned) {
13507                 ret_ref |= 1;
13508         }
13509         return ret_ref;
13510 }
13511
13512 uint32_t NetGraphMsgHandler_1read_1locked_1graph(void* ctx_TODO, uint32_t this_arg) {
13513         LDKNetGraphMsgHandler this_arg_conv;
13514         this_arg_conv.inner = (void*)(this_arg & (~1));
13515         this_arg_conv.is_owned = false;
13516         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
13517         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13518         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13519         long ret_ref = (long)ret_var.inner;
13520         if (ret_var.is_owned) {
13521                 ret_ref |= 1;
13522         }
13523         return ret_ref;
13524 }
13525
13526 uint32_t LockedNetworkGraph_1graph(void* ctx_TODO, uint32_t this_arg) {
13527         LDKLockedNetworkGraph this_arg_conv;
13528         this_arg_conv.inner = (void*)(this_arg & (~1));
13529         this_arg_conv.is_owned = false;
13530         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
13531         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13532         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13533         long ret_ref = (long)ret_var.inner;
13534         if (ret_var.is_owned) {
13535                 ret_ref |= 1;
13536         }
13537         return ret_ref;
13538 }
13539
13540 uint32_t NetGraphMsgHandler_1as_1RoutingMessageHandler(void* ctx_TODO, uint32_t this_arg) {
13541         LDKNetGraphMsgHandler this_arg_conv;
13542         this_arg_conv.inner = (void*)(this_arg & (~1));
13543         this_arg_conv.is_owned = false;
13544         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13545         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
13546         return (long)ret;
13547 }
13548
13549 uint32_t NetGraphMsgHandler_1as_1MessageSendEventsProvider(void* ctx_TODO, uint32_t this_arg) {
13550         LDKNetGraphMsgHandler this_arg_conv;
13551         this_arg_conv.inner = (void*)(this_arg & (~1));
13552         this_arg_conv.is_owned = false;
13553         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
13554         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
13555         return (long)ret;
13556 }
13557
13558 void DirectionalChannelInfo_1free(void* ctx_TODO, uint32_t this_ptr) {
13559         LDKDirectionalChannelInfo this_ptr_conv;
13560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13561         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13562         DirectionalChannelInfo_free(this_ptr_conv);
13563 }
13564
13565 int32_t DirectionalChannelInfo_1get_1last_1update(void* ctx_TODO, uint32_t this_ptr) {
13566         LDKDirectionalChannelInfo this_ptr_conv;
13567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13568         this_ptr_conv.is_owned = false;
13569         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
13570         return ret_val;
13571 }
13572
13573 void DirectionalChannelInfo_1set_1last_1update(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
13574         LDKDirectionalChannelInfo this_ptr_conv;
13575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13576         this_ptr_conv.is_owned = false;
13577         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
13578 }
13579
13580 jboolean DirectionalChannelInfo_1get_1enabled(void* ctx_TODO, uint32_t this_ptr) {
13581         LDKDirectionalChannelInfo this_ptr_conv;
13582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13583         this_ptr_conv.is_owned = false;
13584         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
13585         return ret_val;
13586 }
13587
13588 void DirectionalChannelInfo_1set_1enabled(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
13589         LDKDirectionalChannelInfo this_ptr_conv;
13590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13591         this_ptr_conv.is_owned = false;
13592         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
13593 }
13594
13595 jshort DirectionalChannelInfo_1get_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr) {
13596         LDKDirectionalChannelInfo this_ptr_conv;
13597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13598         this_ptr_conv.is_owned = false;
13599         jshort ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
13600         return ret_val;
13601 }
13602
13603 void DirectionalChannelInfo_1set_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr, jshort val) {
13604         LDKDirectionalChannelInfo this_ptr_conv;
13605         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13606         this_ptr_conv.is_owned = false;
13607         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
13608 }
13609
13610 int64_t DirectionalChannelInfo_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
13611         LDKDirectionalChannelInfo this_ptr_conv;
13612         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13613         this_ptr_conv.is_owned = false;
13614         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
13615         return ret_val;
13616 }
13617
13618 void DirectionalChannelInfo_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13619         LDKDirectionalChannelInfo this_ptr_conv;
13620         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13621         this_ptr_conv.is_owned = false;
13622         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
13623 }
13624
13625 uint32_t DirectionalChannelInfo_1get_1fees(void* ctx_TODO, uint32_t this_ptr) {
13626         LDKDirectionalChannelInfo this_ptr_conv;
13627         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13628         this_ptr_conv.is_owned = false;
13629         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
13630         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13631         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13632         long ret_ref = (long)ret_var.inner;
13633         if (ret_var.is_owned) {
13634                 ret_ref |= 1;
13635         }
13636         return ret_ref;
13637 }
13638
13639 void DirectionalChannelInfo_1set_1fees(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13640         LDKDirectionalChannelInfo this_ptr_conv;
13641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13642         this_ptr_conv.is_owned = false;
13643         LDKRoutingFees val_conv;
13644         val_conv.inner = (void*)(val & (~1));
13645         val_conv.is_owned = (val & 1) || (val == 0);
13646         if (val_conv.inner != NULL)
13647                 val_conv = RoutingFees_clone(&val_conv);
13648         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
13649 }
13650
13651 uint32_t DirectionalChannelInfo_1get_1last_1update_1message(void* ctx_TODO, uint32_t this_ptr) {
13652         LDKDirectionalChannelInfo this_ptr_conv;
13653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13654         this_ptr_conv.is_owned = false;
13655         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
13656         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13657         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13658         long ret_ref = (long)ret_var.inner;
13659         if (ret_var.is_owned) {
13660                 ret_ref |= 1;
13661         }
13662         return ret_ref;
13663 }
13664
13665 void DirectionalChannelInfo_1set_1last_1update_1message(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13666         LDKDirectionalChannelInfo this_ptr_conv;
13667         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13668         this_ptr_conv.is_owned = false;
13669         LDKChannelUpdate val_conv;
13670         val_conv.inner = (void*)(val & (~1));
13671         val_conv.is_owned = (val & 1) || (val == 0);
13672         if (val_conv.inner != NULL)
13673                 val_conv = ChannelUpdate_clone(&val_conv);
13674         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
13675 }
13676
13677 int8_tArray DirectionalChannelInfo_1write(void* ctx_TODO, uint32_t obj) {
13678         LDKDirectionalChannelInfo obj_conv;
13679         obj_conv.inner = (void*)(obj & (~1));
13680         obj_conv.is_owned = false;
13681         LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
13682         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13683         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13684         CVec_u8Z_free(arg_var);
13685         return arg_arr;
13686 }
13687
13688 uint32_t DirectionalChannelInfo_1read(void* ctx_TODO, int8_tArray ser) {
13689         LDKu8slice ser_ref;
13690         ser_ref.datalen = ser.len;
13691         ser_ref.data = ser.ptr;
13692         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_read(ser_ref);
13693         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13694         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13695         long ret_ref = (long)ret_var.inner;
13696         if (ret_var.is_owned) {
13697                 ret_ref |= 1;
13698         }
13699         return ret_ref;
13700 }
13701
13702 void ChannelInfo_1free(void* ctx_TODO, uint32_t this_ptr) {
13703         LDKChannelInfo this_ptr_conv;
13704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13705         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13706         ChannelInfo_free(this_ptr_conv);
13707 }
13708
13709 uint32_t ChannelInfo_1get_1features(void* ctx_TODO, uint32_t this_ptr) {
13710         LDKChannelInfo this_ptr_conv;
13711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13712         this_ptr_conv.is_owned = false;
13713         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
13714         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13715         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13716         long ret_ref = (long)ret_var.inner;
13717         if (ret_var.is_owned) {
13718                 ret_ref |= 1;
13719         }
13720         return ret_ref;
13721 }
13722
13723 void ChannelInfo_1set_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13724         LDKChannelInfo this_ptr_conv;
13725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13726         this_ptr_conv.is_owned = false;
13727         LDKChannelFeatures val_conv;
13728         val_conv.inner = (void*)(val & (~1));
13729         val_conv.is_owned = (val & 1) || (val == 0);
13730         // Warning: we may need a move here but can't clone!
13731         ChannelInfo_set_features(&this_ptr_conv, val_conv);
13732 }
13733
13734 int8_tArray ChannelInfo_1get_1node_1one(void* ctx_TODO, uint32_t this_ptr) {
13735         LDKChannelInfo this_ptr_conv;
13736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13737         this_ptr_conv.is_owned = false;
13738         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
13739         memcpy(arg_arr.ptr, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
13740         return arg_arr;
13741 }
13742
13743 void ChannelInfo_1set_1node_1one(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13744         LDKChannelInfo this_ptr_conv;
13745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13746         this_ptr_conv.is_owned = false;
13747         LDKPublicKey val_ref;
13748         CHECK(val.len == 33);
13749         memcpy(val_ref.compressed_form, val.ptr, 33);
13750         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
13751 }
13752
13753 uint32_t ChannelInfo_1get_1one_1to_1two(void* ctx_TODO, uint32_t this_ptr) {
13754         LDKChannelInfo this_ptr_conv;
13755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13756         this_ptr_conv.is_owned = false;
13757         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
13758         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13759         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13760         long ret_ref = (long)ret_var.inner;
13761         if (ret_var.is_owned) {
13762                 ret_ref |= 1;
13763         }
13764         return ret_ref;
13765 }
13766
13767 void ChannelInfo_1set_1one_1to_1two(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13768         LDKChannelInfo this_ptr_conv;
13769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13770         this_ptr_conv.is_owned = false;
13771         LDKDirectionalChannelInfo val_conv;
13772         val_conv.inner = (void*)(val & (~1));
13773         val_conv.is_owned = (val & 1) || (val == 0);
13774         // Warning: we may need a move here but can't clone!
13775         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
13776 }
13777
13778 int8_tArray ChannelInfo_1get_1node_1two(void* ctx_TODO, uint32_t this_ptr) {
13779         LDKChannelInfo this_ptr_conv;
13780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13781         this_ptr_conv.is_owned = false;
13782         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
13783         memcpy(arg_arr.ptr, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
13784         return arg_arr;
13785 }
13786
13787 void ChannelInfo_1set_1node_1two(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13788         LDKChannelInfo this_ptr_conv;
13789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13790         this_ptr_conv.is_owned = false;
13791         LDKPublicKey val_ref;
13792         CHECK(val.len == 33);
13793         memcpy(val_ref.compressed_form, val.ptr, 33);
13794         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
13795 }
13796
13797 uint32_t ChannelInfo_1get_1two_1to_1one(void* ctx_TODO, uint32_t this_ptr) {
13798         LDKChannelInfo this_ptr_conv;
13799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13800         this_ptr_conv.is_owned = false;
13801         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
13802         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13803         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13804         long ret_ref = (long)ret_var.inner;
13805         if (ret_var.is_owned) {
13806                 ret_ref |= 1;
13807         }
13808         return ret_ref;
13809 }
13810
13811 void ChannelInfo_1set_1two_1to_1one(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13812         LDKChannelInfo this_ptr_conv;
13813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13814         this_ptr_conv.is_owned = false;
13815         LDKDirectionalChannelInfo val_conv;
13816         val_conv.inner = (void*)(val & (~1));
13817         val_conv.is_owned = (val & 1) || (val == 0);
13818         // Warning: we may need a move here but can't clone!
13819         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
13820 }
13821
13822 uint32_t ChannelInfo_1get_1announcement_1message(void* ctx_TODO, uint32_t this_ptr) {
13823         LDKChannelInfo this_ptr_conv;
13824         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13825         this_ptr_conv.is_owned = false;
13826         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
13827         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13828         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13829         long ret_ref = (long)ret_var.inner;
13830         if (ret_var.is_owned) {
13831                 ret_ref |= 1;
13832         }
13833         return ret_ref;
13834 }
13835
13836 void ChannelInfo_1set_1announcement_1message(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13837         LDKChannelInfo this_ptr_conv;
13838         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13839         this_ptr_conv.is_owned = false;
13840         LDKChannelAnnouncement val_conv;
13841         val_conv.inner = (void*)(val & (~1));
13842         val_conv.is_owned = (val & 1) || (val == 0);
13843         if (val_conv.inner != NULL)
13844                 val_conv = ChannelAnnouncement_clone(&val_conv);
13845         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
13846 }
13847
13848 int8_tArray ChannelInfo_1write(void* ctx_TODO, uint32_t obj) {
13849         LDKChannelInfo obj_conv;
13850         obj_conv.inner = (void*)(obj & (~1));
13851         obj_conv.is_owned = false;
13852         LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
13853         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13854         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13855         CVec_u8Z_free(arg_var);
13856         return arg_arr;
13857 }
13858
13859 uint32_t ChannelInfo_1read(void* ctx_TODO, int8_tArray ser) {
13860         LDKu8slice ser_ref;
13861         ser_ref.datalen = ser.len;
13862         ser_ref.data = ser.ptr;
13863         LDKChannelInfo ret_var = ChannelInfo_read(ser_ref);
13864         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13865         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13866         long ret_ref = (long)ret_var.inner;
13867         if (ret_var.is_owned) {
13868                 ret_ref |= 1;
13869         }
13870         return ret_ref;
13871 }
13872
13873 void RoutingFees_1free(void* ctx_TODO, uint32_t this_ptr) {
13874         LDKRoutingFees this_ptr_conv;
13875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13876         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13877         RoutingFees_free(this_ptr_conv);
13878 }
13879
13880 uint32_t RoutingFees_1clone(void* ctx_TODO, uint32_t orig) {
13881         LDKRoutingFees orig_conv;
13882         orig_conv.inner = (void*)(orig & (~1));
13883         orig_conv.is_owned = false;
13884         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
13885         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13886         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13887         long ret_ref = (long)ret_var.inner;
13888         if (ret_var.is_owned) {
13889                 ret_ref |= 1;
13890         }
13891         return ret_ref;
13892 }
13893
13894 int32_t RoutingFees_1get_1base_1msat(void* ctx_TODO, uint32_t this_ptr) {
13895         LDKRoutingFees this_ptr_conv;
13896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13897         this_ptr_conv.is_owned = false;
13898         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
13899         return ret_val;
13900 }
13901
13902 void RoutingFees_1set_1base_1msat(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
13903         LDKRoutingFees this_ptr_conv;
13904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13905         this_ptr_conv.is_owned = false;
13906         RoutingFees_set_base_msat(&this_ptr_conv, val);
13907 }
13908
13909 int32_t RoutingFees_1get_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr) {
13910         LDKRoutingFees this_ptr_conv;
13911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13912         this_ptr_conv.is_owned = false;
13913         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
13914         return ret_val;
13915 }
13916
13917 void RoutingFees_1set_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
13918         LDKRoutingFees this_ptr_conv;
13919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13920         this_ptr_conv.is_owned = false;
13921         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
13922 }
13923
13924 uint32_t RoutingFees_1new(void* ctx_TODO, int32_t base_msat_arg, int32_t proportional_millionths_arg) {
13925         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
13926         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13927         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13928         long ret_ref = (long)ret_var.inner;
13929         if (ret_var.is_owned) {
13930                 ret_ref |= 1;
13931         }
13932         return ret_ref;
13933 }
13934
13935 uint32_t RoutingFees_1read(void* ctx_TODO, int8_tArray ser) {
13936         LDKu8slice ser_ref;
13937         ser_ref.datalen = ser.len;
13938         ser_ref.data = ser.ptr;
13939         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
13940         *ret_conv = RoutingFees_read(ser_ref);
13941         return (long)ret_conv;
13942 }
13943
13944 int8_tArray RoutingFees_1write(void* ctx_TODO, uint32_t obj) {
13945         LDKRoutingFees obj_conv;
13946         obj_conv.inner = (void*)(obj & (~1));
13947         obj_conv.is_owned = false;
13948         LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
13949         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13950         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13951         CVec_u8Z_free(arg_var);
13952         return arg_arr;
13953 }
13954
13955 void NodeAnnouncementInfo_1free(void* ctx_TODO, uint32_t this_ptr) {
13956         LDKNodeAnnouncementInfo this_ptr_conv;
13957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13958         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13959         NodeAnnouncementInfo_free(this_ptr_conv);
13960 }
13961
13962 uint32_t NodeAnnouncementInfo_1get_1features(void* ctx_TODO, uint32_t this_ptr) {
13963         LDKNodeAnnouncementInfo this_ptr_conv;
13964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13965         this_ptr_conv.is_owned = false;
13966         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
13967         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13968         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13969         long ret_ref = (long)ret_var.inner;
13970         if (ret_var.is_owned) {
13971                 ret_ref |= 1;
13972         }
13973         return ret_ref;
13974 }
13975
13976 void NodeAnnouncementInfo_1set_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13977         LDKNodeAnnouncementInfo this_ptr_conv;
13978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13979         this_ptr_conv.is_owned = false;
13980         LDKNodeFeatures val_conv;
13981         val_conv.inner = (void*)(val & (~1));
13982         val_conv.is_owned = (val & 1) || (val == 0);
13983         // Warning: we may need a move here but can't clone!
13984         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
13985 }
13986
13987 int32_t NodeAnnouncementInfo_1get_1last_1update(void* ctx_TODO, uint32_t this_ptr) {
13988         LDKNodeAnnouncementInfo this_ptr_conv;
13989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13990         this_ptr_conv.is_owned = false;
13991         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
13992         return ret_val;
13993 }
13994
13995 void NodeAnnouncementInfo_1set_1last_1update(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
13996         LDKNodeAnnouncementInfo this_ptr_conv;
13997         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13998         this_ptr_conv.is_owned = false;
13999         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
14000 }
14001
14002 int8_tArray NodeAnnouncementInfo_1get_1rgb(void* ctx_TODO, uint32_t this_ptr) {
14003         LDKNodeAnnouncementInfo this_ptr_conv;
14004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14005         this_ptr_conv.is_owned = false;
14006         int8_tArray ret_arr = { .len = 3, .ptr = MALLOC(3, "Native int8_tArray Bytes") };
14007         memcpy(ret_arr.ptr, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
14008         return ret_arr;
14009 }
14010
14011 void NodeAnnouncementInfo_1set_1rgb(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
14012         LDKNodeAnnouncementInfo this_ptr_conv;
14013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14014         this_ptr_conv.is_owned = false;
14015         LDKThreeBytes val_ref;
14016         CHECK(val.len == 3);
14017         memcpy(val_ref.data, val.ptr, 3);
14018         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
14019 }
14020
14021 int8_tArray NodeAnnouncementInfo_1get_1alias(void* ctx_TODO, uint32_t this_ptr) {
14022         LDKNodeAnnouncementInfo this_ptr_conv;
14023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14024         this_ptr_conv.is_owned = false;
14025         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
14026         memcpy(ret_arr.ptr, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
14027         return ret_arr;
14028 }
14029
14030 void NodeAnnouncementInfo_1set_1alias(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
14031         LDKNodeAnnouncementInfo this_ptr_conv;
14032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14033         this_ptr_conv.is_owned = false;
14034         LDKThirtyTwoBytes val_ref;
14035         CHECK(val.len == 32);
14036         memcpy(val_ref.data, val.ptr, 32);
14037         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
14038 }
14039
14040 void NodeAnnouncementInfo_1set_1addresses(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
14041         LDKNodeAnnouncementInfo this_ptr_conv;
14042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14043         this_ptr_conv.is_owned = false;
14044         LDKCVec_NetAddressZ val_constr;
14045         val_constr.datalen = val.len;
14046         if (val_constr.datalen > 0)
14047                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14048         else
14049                 val_constr.data = NULL;
14050         uint32_t* val_vals = (uint32_t*) val.ptr;
14051         for (size_t m = 0; m < val_constr.datalen; m++) {
14052                 uint32_t arr_conv_12 = val_vals[m];
14053                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
14054                 FREE((void*)arr_conv_12);
14055                 val_constr.data[m] = arr_conv_12_conv;
14056         }
14057         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
14058 }
14059
14060 uint32_t NodeAnnouncementInfo_1get_1announcement_1message(void* ctx_TODO, uint32_t this_ptr) {
14061         LDKNodeAnnouncementInfo this_ptr_conv;
14062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14063         this_ptr_conv.is_owned = false;
14064         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
14065         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14066         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14067         long ret_ref = (long)ret_var.inner;
14068         if (ret_var.is_owned) {
14069                 ret_ref |= 1;
14070         }
14071         return ret_ref;
14072 }
14073
14074 void NodeAnnouncementInfo_1set_1announcement_1message(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14075         LDKNodeAnnouncementInfo this_ptr_conv;
14076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14077         this_ptr_conv.is_owned = false;
14078         LDKNodeAnnouncement val_conv;
14079         val_conv.inner = (void*)(val & (~1));
14080         val_conv.is_owned = (val & 1) || (val == 0);
14081         if (val_conv.inner != NULL)
14082                 val_conv = NodeAnnouncement_clone(&val_conv);
14083         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
14084 }
14085
14086 uint32_t NodeAnnouncementInfo_1new(void* ctx_TODO, 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) {
14087         LDKNodeFeatures features_arg_conv;
14088         features_arg_conv.inner = (void*)(features_arg & (~1));
14089         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
14090         // Warning: we may need a move here but can't clone!
14091         LDKThreeBytes rgb_arg_ref;
14092         CHECK(rgb_arg.len == 3);
14093         memcpy(rgb_arg_ref.data, rgb_arg.ptr, 3);
14094         LDKThirtyTwoBytes alias_arg_ref;
14095         CHECK(alias_arg.len == 32);
14096         memcpy(alias_arg_ref.data, alias_arg.ptr, 32);
14097         LDKCVec_NetAddressZ addresses_arg_constr;
14098         addresses_arg_constr.datalen = addresses_arg.len;
14099         if (addresses_arg_constr.datalen > 0)
14100                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14101         else
14102                 addresses_arg_constr.data = NULL;
14103         uint32_t* addresses_arg_vals = (uint32_t*) addresses_arg.ptr;
14104         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
14105                 uint32_t arr_conv_12 = addresses_arg_vals[m];
14106                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
14107                 FREE((void*)arr_conv_12);
14108                 addresses_arg_constr.data[m] = arr_conv_12_conv;
14109         }
14110         LDKNodeAnnouncement announcement_message_arg_conv;
14111         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
14112         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
14113         if (announcement_message_arg_conv.inner != NULL)
14114                 announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
14115         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
14116         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14117         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14118         long ret_ref = (long)ret_var.inner;
14119         if (ret_var.is_owned) {
14120                 ret_ref |= 1;
14121         }
14122         return ret_ref;
14123 }
14124
14125 int8_tArray NodeAnnouncementInfo_1write(void* ctx_TODO, uint32_t obj) {
14126         LDKNodeAnnouncementInfo obj_conv;
14127         obj_conv.inner = (void*)(obj & (~1));
14128         obj_conv.is_owned = false;
14129         LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
14130         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14131         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14132         CVec_u8Z_free(arg_var);
14133         return arg_arr;
14134 }
14135
14136 uint32_t NodeAnnouncementInfo_1read(void* ctx_TODO, int8_tArray ser) {
14137         LDKu8slice ser_ref;
14138         ser_ref.datalen = ser.len;
14139         ser_ref.data = ser.ptr;
14140         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14141         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
14142         return (long)ret_conv;
14143 }
14144
14145 void NodeInfo_1free(void* ctx_TODO, uint32_t this_ptr) {
14146         LDKNodeInfo this_ptr_conv;
14147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14148         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14149         NodeInfo_free(this_ptr_conv);
14150 }
14151
14152 void NodeInfo_1set_1channels(void* ctx_TODO, uint32_t this_ptr, int64_tArray val) {
14153         LDKNodeInfo this_ptr_conv;
14154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14155         this_ptr_conv.is_owned = false;
14156         LDKCVec_u64Z val_constr;
14157         val_constr.datalen = val.len;
14158         if (val_constr.datalen > 0)
14159                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14160         else
14161                 val_constr.data = NULL;
14162         int64_t* val_vals = (int64_t*) val.ptr;
14163         for (size_t g = 0; g < val_constr.datalen; g++) {
14164                 int64_t arr_conv_6 = val_vals[g];
14165                 val_constr.data[g] = arr_conv_6;
14166         }
14167         NodeInfo_set_channels(&this_ptr_conv, val_constr);
14168 }
14169
14170 uint32_t NodeInfo_1get_1lowest_1inbound_1channel_1fees(void* ctx_TODO, uint32_t this_ptr) {
14171         LDKNodeInfo this_ptr_conv;
14172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14173         this_ptr_conv.is_owned = false;
14174         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
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 void NodeInfo_1set_1lowest_1inbound_1channel_1fees(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14185         LDKNodeInfo this_ptr_conv;
14186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14187         this_ptr_conv.is_owned = false;
14188         LDKRoutingFees val_conv;
14189         val_conv.inner = (void*)(val & (~1));
14190         val_conv.is_owned = (val & 1) || (val == 0);
14191         if (val_conv.inner != NULL)
14192                 val_conv = RoutingFees_clone(&val_conv);
14193         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
14194 }
14195
14196 uint32_t NodeInfo_1get_1announcement_1info(void* ctx_TODO, uint32_t this_ptr) {
14197         LDKNodeInfo this_ptr_conv;
14198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14199         this_ptr_conv.is_owned = false;
14200         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
14201         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14202         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14203         long ret_ref = (long)ret_var.inner;
14204         if (ret_var.is_owned) {
14205                 ret_ref |= 1;
14206         }
14207         return ret_ref;
14208 }
14209
14210 void NodeInfo_1set_1announcement_1info(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14211         LDKNodeInfo this_ptr_conv;
14212         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14213         this_ptr_conv.is_owned = false;
14214         LDKNodeAnnouncementInfo val_conv;
14215         val_conv.inner = (void*)(val & (~1));
14216         val_conv.is_owned = (val & 1) || (val == 0);
14217         // Warning: we may need a move here but can't clone!
14218         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
14219 }
14220
14221 uint32_t NodeInfo_1new(void* ctx_TODO, int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
14222         LDKCVec_u64Z channels_arg_constr;
14223         channels_arg_constr.datalen = channels_arg.len;
14224         if (channels_arg_constr.datalen > 0)
14225                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14226         else
14227                 channels_arg_constr.data = NULL;
14228         int64_t* channels_arg_vals = (int64_t*) channels_arg.ptr;
14229         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
14230                 int64_t arr_conv_6 = channels_arg_vals[g];
14231                 channels_arg_constr.data[g] = arr_conv_6;
14232         }
14233         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
14234         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
14235         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
14236         if (lowest_inbound_channel_fees_arg_conv.inner != NULL)
14237                 lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
14238         LDKNodeAnnouncementInfo announcement_info_arg_conv;
14239         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
14240         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
14241         // Warning: we may need a move here but can't clone!
14242         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
14243         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14244         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14245         long ret_ref = (long)ret_var.inner;
14246         if (ret_var.is_owned) {
14247                 ret_ref |= 1;
14248         }
14249         return ret_ref;
14250 }
14251
14252 int8_tArray NodeInfo_1write(void* ctx_TODO, uint32_t obj) {
14253         LDKNodeInfo obj_conv;
14254         obj_conv.inner = (void*)(obj & (~1));
14255         obj_conv.is_owned = false;
14256         LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
14257         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14258         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14259         CVec_u8Z_free(arg_var);
14260         return arg_arr;
14261 }
14262
14263 uint32_t NodeInfo_1read(void* ctx_TODO, int8_tArray ser) {
14264         LDKu8slice ser_ref;
14265         ser_ref.datalen = ser.len;
14266         ser_ref.data = ser.ptr;
14267         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14268         *ret_conv = NodeInfo_read(ser_ref);
14269         return (long)ret_conv;
14270 }
14271
14272 int8_tArray NetworkGraph_1write(void* ctx_TODO, uint32_t obj) {
14273         LDKNetworkGraph obj_conv;
14274         obj_conv.inner = (void*)(obj & (~1));
14275         obj_conv.is_owned = false;
14276         LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
14277         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14278         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14279         CVec_u8Z_free(arg_var);
14280         return arg_arr;
14281 }
14282
14283 uint32_t NetworkGraph_1read(void* ctx_TODO, int8_tArray ser) {
14284         LDKu8slice ser_ref;
14285         ser_ref.datalen = ser.len;
14286         ser_ref.data = ser.ptr;
14287         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14288         *ret_conv = NetworkGraph_read(ser_ref);
14289         return (long)ret_conv;
14290 }
14291
14292 uint32_t NetworkGraph_1new(void* ctx_TODO, int8_tArray genesis_hash) {
14293         LDKThirtyTwoBytes genesis_hash_ref;
14294         CHECK(genesis_hash.len == 32);
14295         memcpy(genesis_hash_ref.data, genesis_hash.ptr, 32);
14296         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
14297         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14298         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14299         long ret_ref = (long)ret_var.inner;
14300         if (ret_var.is_owned) {
14301                 ret_ref |= 1;
14302         }
14303         return ret_ref;
14304 }
14305
14306 uint32_t NetworkGraph_1update_1node_1from_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
14307         LDKNetworkGraph this_arg_conv;
14308         this_arg_conv.inner = (void*)(this_arg & (~1));
14309         this_arg_conv.is_owned = false;
14310         LDKNodeAnnouncement msg_conv;
14311         msg_conv.inner = (void*)(msg & (~1));
14312         msg_conv.is_owned = false;
14313         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14314         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
14315         return (long)ret_conv;
14316 }
14317
14318 uint32_t NetworkGraph_1update_1node_1from_1unsigned_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
14319         LDKNetworkGraph this_arg_conv;
14320         this_arg_conv.inner = (void*)(this_arg & (~1));
14321         this_arg_conv.is_owned = false;
14322         LDKUnsignedNodeAnnouncement msg_conv;
14323         msg_conv.inner = (void*)(msg & (~1));
14324         msg_conv.is_owned = false;
14325         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14326         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
14327         return (long)ret_conv;
14328 }
14329
14330 uint32_t NetworkGraph_1update_1channel_1from_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
14331         LDKNetworkGraph this_arg_conv;
14332         this_arg_conv.inner = (void*)(this_arg & (~1));
14333         this_arg_conv.is_owned = false;
14334         LDKChannelAnnouncement msg_conv;
14335         msg_conv.inner = (void*)(msg & (~1));
14336         msg_conv.is_owned = false;
14337         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14338         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14339         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
14340         return (long)ret_conv;
14341 }
14342
14343 uint32_t NetworkGraph_1update_1channel_1from_1unsigned_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
14344         LDKNetworkGraph this_arg_conv;
14345         this_arg_conv.inner = (void*)(this_arg & (~1));
14346         this_arg_conv.is_owned = false;
14347         LDKUnsignedChannelAnnouncement msg_conv;
14348         msg_conv.inner = (void*)(msg & (~1));
14349         msg_conv.is_owned = false;
14350         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14351         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14352         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
14353         return (long)ret_conv;
14354 }
14355
14356 void NetworkGraph_1close_1channel_1from_1update(void* ctx_TODO, uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
14357         LDKNetworkGraph this_arg_conv;
14358         this_arg_conv.inner = (void*)(this_arg & (~1));
14359         this_arg_conv.is_owned = false;
14360         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
14361 }
14362
14363 uint32_t NetworkGraph_1update_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
14364         LDKNetworkGraph this_arg_conv;
14365         this_arg_conv.inner = (void*)(this_arg & (~1));
14366         this_arg_conv.is_owned = false;
14367         LDKChannelUpdate msg_conv;
14368         msg_conv.inner = (void*)(msg & (~1));
14369         msg_conv.is_owned = false;
14370         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14371         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
14372         return (long)ret_conv;
14373 }
14374
14375 uint32_t NetworkGraph_1update_1channel_1unsigned(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
14376         LDKNetworkGraph this_arg_conv;
14377         this_arg_conv.inner = (void*)(this_arg & (~1));
14378         this_arg_conv.is_owned = false;
14379         LDKUnsignedChannelUpdate msg_conv;
14380         msg_conv.inner = (void*)(msg & (~1));
14381         msg_conv.is_owned = false;
14382         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14383         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
14384         return (long)ret_conv;
14385 }
14386