TS bindings
[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 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
972         LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
973         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
974         return (void*) this_arg;
975 }
976 static inline LDKChannelKeys LDKChannelKeys_init (void* ctx_TODO, jobject o, uint32_t pubkeys) {
977         jclass c = (*env)->GetObjectClass(env, o);
978         CHECK(c != NULL);
979         LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
980         atomic_init(&calls->refcnt, 1);
981         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
982         calls->o = (*env)->NewWeakGlobalRef(env, o);
983         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
984         CHECK(calls->get_per_commitment_point_meth != NULL);
985         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
986         CHECK(calls->release_commitment_secret_meth != NULL);
987         calls->key_derivation_params_meth = (*env)->GetMethodID(env, c, "key_derivation_params", "()J");
988         CHECK(calls->key_derivation_params_meth != NULL);
989         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
990         CHECK(calls->sign_counterparty_commitment_meth != NULL);
991         calls->sign_holder_commitment_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment", "(J)J");
992         CHECK(calls->sign_holder_commitment_meth != NULL);
993         calls->sign_holder_commitment_htlc_transactions_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_htlc_transactions", "(J)J");
994         CHECK(calls->sign_holder_commitment_htlc_transactions_meth != NULL);
995         calls->sign_justice_transaction_meth = (*env)->GetMethodID(env, c, "sign_justice_transaction", "([BJJ[BJ)J");
996         CHECK(calls->sign_justice_transaction_meth != NULL);
997         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
998         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
999         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "([B)J");
1000         CHECK(calls->sign_closing_transaction_meth != NULL);
1001         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
1002         CHECK(calls->sign_channel_announcement_meth != NULL);
1003         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
1004         CHECK(calls->ready_channel_meth != NULL);
1005         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
1006         CHECK(calls->write_meth != NULL);
1007
1008         LDKChannelPublicKeys pubkeys_conv;
1009         pubkeys_conv.inner = (void*)(pubkeys & (~1));
1010         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1011         if (pubkeys_conv.inner != NULL)
1012                 pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1013
1014         LDKChannelKeys ret = {
1015                 .this_arg = (void*) calls,
1016                 .get_per_commitment_point = get_per_commitment_point_jcall,
1017                 .release_commitment_secret = release_commitment_secret_jcall,
1018                 .key_derivation_params = key_derivation_params_jcall,
1019                 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1020                 .sign_holder_commitment = sign_holder_commitment_jcall,
1021                 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1022                 .sign_justice_transaction = sign_justice_transaction_jcall,
1023                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1024                 .sign_closing_transaction = sign_closing_transaction_jcall,
1025                 .sign_channel_announcement = sign_channel_announcement_jcall,
1026                 .ready_channel = ready_channel_jcall,
1027                 .clone = LDKChannelKeys_JCalls_clone,
1028                 .write = write_jcall,
1029                 .free = LDKChannelKeys_JCalls_free,
1030                 .pubkeys = pubkeys_conv,
1031                 .set_pubkeys = NULL,
1032         };
1033         return ret;
1034 }
1035 long LDKChannelKeys_1new (void* ctx_TODO, jobject o, uint32_t pubkeys) {
1036         LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1037         *res_ptr = LDKChannelKeys_init(env, clz, o, pubkeys);
1038         return (long)res_ptr;
1039 }
1040 jobject LDKChannelKeys_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
1041         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelKeys_JCalls*)val)->o);
1042         CHECK(ret != NULL);
1043         return ret;
1044 }
1045 int8_tArray ChannelKeys_1get_1per_1commitment_1point(void* ctx_TODO, uint32_t this_arg, int64_t idx) {
1046         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1047         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
1048         memcpy(arg_arr.ptr, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1049         return arg_arr;
1050 }
1051
1052 int8_tArray ChannelKeys_1release_1commitment_1secret(void* ctx_TODO, uint32_t this_arg, int64_t idx) {
1053         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1054         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1055         memcpy(arg_arr.ptr, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1056         return arg_arr;
1057 }
1058
1059 uint32_t ChannelKeys_1key_1derivation_1params(void* ctx_TODO, uint32_t this_arg) {
1060         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1061         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1062         *ret_ref = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
1063         return (long)ret_ref;
1064 }
1065
1066 uint32_t ChannelKeys_1sign_1counterparty_1commitment(void* ctx_TODO, uint32_t this_arg, uint32_t commitment_tx) {
1067         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1068         LDKCommitmentTransaction commitment_tx_conv;
1069         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1070         commitment_tx_conv.is_owned = false;
1071         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1072         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1073         return (long)ret_conv;
1074 }
1075
1076 uint32_t ChannelKeys_1sign_1holder_1commitment(void* ctx_TODO, uint32_t this_arg, uint32_t commitment_tx) {
1077         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1078         LDKHolderCommitmentTransaction commitment_tx_conv;
1079         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1080         commitment_tx_conv.is_owned = false;
1081         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1082         *ret_conv = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1083         return (long)ret_conv;
1084 }
1085
1086 uint32_t ChannelKeys_1sign_1holder_1commitment_1htlc_1transactions(void* ctx_TODO, uint32_t this_arg, uint32_t commitment_tx) {
1087         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1088         LDKHolderCommitmentTransaction commitment_tx_conv;
1089         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1090         commitment_tx_conv.is_owned = false;
1091         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1092         *ret_conv = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &commitment_tx_conv);
1093         return (long)ret_conv;
1094 }
1095
1096 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) {
1097         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1098         LDKTransaction justice_tx_ref;
1099         justice_tx_ref.datalen = justice_tx.len;
1100         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1101         memcpy(justice_tx_ref.data, justice_tx.ptr, justice_tx_ref.datalen);
1102         justice_tx_ref.data_is_owned = true;
1103         unsigned char per_commitment_key_arr[32];
1104         CHECK(per_commitment_key.len == 32);
1105         memcpy(per_commitment_key_arr, per_commitment_key.ptr, 32);
1106         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1107         LDKHTLCOutputInCommitment htlc_conv;
1108         htlc_conv.inner = (void*)(htlc & (~1));
1109         htlc_conv.is_owned = false;
1110         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1111         *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1112         return (long)ret_conv;
1113 }
1114
1115 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) {
1116         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1117         LDKTransaction htlc_tx_ref;
1118         htlc_tx_ref.datalen = htlc_tx.len;
1119         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1120         memcpy(htlc_tx_ref.data, htlc_tx.ptr, htlc_tx_ref.datalen);
1121         htlc_tx_ref.data_is_owned = true;
1122         LDKPublicKey per_commitment_point_ref;
1123         CHECK(per_commitment_point.len == 33);
1124         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
1125         LDKHTLCOutputInCommitment htlc_conv;
1126         htlc_conv.inner = (void*)(htlc & (~1));
1127         htlc_conv.is_owned = false;
1128         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1129         *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);
1130         return (long)ret_conv;
1131 }
1132
1133 uint32_t ChannelKeys_1sign_1closing_1transaction(void* ctx_TODO, uint32_t this_arg, int8_tArray closing_tx) {
1134         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1135         LDKTransaction closing_tx_ref;
1136         closing_tx_ref.datalen = closing_tx.len;
1137         closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1138         memcpy(closing_tx_ref.data, closing_tx.ptr, closing_tx_ref.datalen);
1139         closing_tx_ref.data_is_owned = true;
1140         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1141         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1142         return (long)ret_conv;
1143 }
1144
1145 uint32_t ChannelKeys_1sign_1channel_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
1146         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1147         LDKUnsignedChannelAnnouncement msg_conv;
1148         msg_conv.inner = (void*)(msg & (~1));
1149         msg_conv.is_owned = false;
1150         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1151         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1152         return (long)ret_conv;
1153 }
1154
1155 void ChannelKeys_1ready_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t channel_parameters) {
1156         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1157         LDKChannelTransactionParameters channel_parameters_conv;
1158         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1159         channel_parameters_conv.is_owned = false;
1160         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1161 }
1162
1163 int8_tArray ChannelKeys_1write(void* ctx_TODO, uint32_t this_arg) {
1164         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1165         LDKCVec_u8Z arg_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1166         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
1167         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
1168         CVec_u8Z_free(arg_var);
1169         return arg_arr;
1170 }
1171
1172 LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* this_arg) {
1173         if (this_arg->set_pubkeys != NULL)
1174                 this_arg->set_pubkeys(this_arg);
1175         return this_arg->pubkeys;
1176 }
1177 uint32_t ChannelKeys_1get_1pubkeys(void* ctx_TODO, uint32_t this_arg) {
1178         LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1179         LDKChannelPublicKeys ret_var = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
1180         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1181         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1182         long ret_ref = (long)ret_var.inner;
1183         if (ret_var.is_owned) {
1184                 ret_ref |= 1;
1185         }
1186         return ret_ref;
1187 }
1188
1189 uint32_t LDKC2Tuple_1BlockHashChannelMonitorZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) {
1190         LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1191         LDKThirtyTwoBytes a_ref;
1192         CHECK(a.len == 32);
1193         memcpy(a_ref.data, a.ptr, 32);
1194         ret->a = a_ref;
1195         LDKChannelMonitor b_conv;
1196         b_conv.inner = (void*)(b & (~1));
1197         b_conv.is_owned = (b & 1) || (b == 0);
1198         // Warning: we may need a move here but can't clone!
1199         ret->b = b_conv;
1200         return (long)ret;
1201 }
1202 int8_tArray LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
1203         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
1204         int8_tArray a_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1205         memcpy(a_arr.ptr, tuple->a.data, 32);
1206         return a_arr;
1207 }
1208 uint32_t LDKC2Tuple_1BlockHashChannelMonitorZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
1209         LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
1210         LDKChannelMonitor b_var = tuple->b;
1211         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1212         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1213         long b_ref = (long)b_var.inner & ~1;
1214         return b_ref;
1215 }
1216 jboolean LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1217         return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
1218 }
1219 uint32_t LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1220         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
1221         CHECK(val->result_ok);
1222         long res_ref = (long)&(*val->contents.result);
1223         return res_ref;
1224 }
1225 uint32_t LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1226         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
1227         CHECK(!val->result_ok);
1228         LDKDecodeError err_var = (*val->contents.err);
1229         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1230         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1231         long err_ref = (long)err_var.inner & ~1;
1232         return err_ref;
1233 }
1234 jboolean LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1235         return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1236 }
1237 uint32_t LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1238         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
1239         CHECK(val->result_ok);
1240         long res_ref = (long)&(*val->contents.result);
1241         return res_ref;
1242 }
1243 uint32_t LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1244         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
1245         CHECK(!val->result_ok);
1246         LDKDecodeError err_var = (*val->contents.err);
1247         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1248         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1249         long err_ref = (long)err_var.inner & ~1;
1250         return err_ref;
1251 }
1252 jboolean LDKCResult_1ChanKeySignerDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1253         return ((LDKCResult_ChanKeySignerDecodeErrorZ*)arg)->result_ok;
1254 }
1255 uint32_t LDKCResult_1ChanKeySignerDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1256         LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
1257         CHECK(val->result_ok);
1258         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1259         *ret = (*val->contents.result);
1260         return (long)ret;
1261 }
1262 uint32_t LDKCResult_1ChanKeySignerDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1263         LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
1264         CHECK(!val->result_ok);
1265         LDKDecodeError err_var = (*val->contents.err);
1266         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1267         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1268         long err_ref = (long)err_var.inner & ~1;
1269         return err_ref;
1270 }
1271 jboolean LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1272         return ((LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg)->result_ok;
1273 }
1274 uint32_t LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1275         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
1276         CHECK(val->result_ok);
1277         LDKInMemoryChannelKeys res_var = (*val->contents.result);
1278         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1279         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1280         long res_ref = (long)res_var.inner & ~1;
1281         return res_ref;
1282 }
1283 uint32_t LDKCResult_1InMemoryChannelKeysDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1284         LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
1285         CHECK(!val->result_ok);
1286         LDKDecodeError err_var = (*val->contents.err);
1287         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1288         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1289         long err_ref = (long)err_var.inner & ~1;
1290         return err_ref;
1291 }
1292 jboolean LDKCResult_1TxOutAccessErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1293         return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1294 }
1295 uint32_t LDKCResult_1TxOutAccessErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1296         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1297         CHECK(val->result_ok);
1298         long res_ref = (long)&(*val->contents.result);
1299         return (long)res_ref;
1300 }
1301 uint32_t LDKCResult_1TxOutAccessErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1302         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1303         CHECK(!val->result_ok);
1304         uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
1305         return err_conv;
1306 }
1307 uint32_t LDKAPIError_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
1308         LDKAPIError *obj = (LDKAPIError*)ptr;
1309         switch(obj->tag) {
1310                 case LDKAPIError_APIMisuseError: {
1311                         LDKCVec_u8Z err_var = obj->api_misuse_error.err;
1312                         int8_tArray err_arr = { .len = err_var.datalen, .ptr = MALLOC(err_var.datalen, "Native int8_tArray Bytes") };
1313                         memcpy(err_arr.ptr, err_var.data, err_var.datalen);
1314                         return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
1315                 }
1316                 case LDKAPIError_FeeRateTooHigh: {
1317                         LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
1318                         int8_tArray err_arr = { .len = err_var.datalen, .ptr = MALLOC(err_var.datalen, "Native int8_tArray Bytes") };
1319                         memcpy(err_arr.ptr, err_var.data, err_var.datalen);
1320                         return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
1321                 }
1322                 case LDKAPIError_RouteError: {
1323                         LDKStr err_str = obj->route_error.err;
1324                         char* err_buf = MALLOC(err_str.len + 1, "str conv buf");
1325                         memcpy(err_buf, err_str.chars, err_str.len);
1326                         err_buf[err_str.len] = 0;
1327                         jstring err_conv = (*env)->NewStringUTF(env, err_str.chars);
1328                         FREE(err_buf);
1329                         return 0 /* LDKAPIError - RouteError */; (void) err_conv;
1330                 }
1331                 case LDKAPIError_ChannelUnavailable: {
1332                         LDKCVec_u8Z err_var = obj->channel_unavailable.err;
1333                         int8_tArray err_arr = { .len = err_var.datalen, .ptr = MALLOC(err_var.datalen, "Native int8_tArray Bytes") };
1334                         memcpy(err_arr.ptr, err_var.data, err_var.datalen);
1335                         return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
1336                 }
1337                 case LDKAPIError_MonitorUpdateFailed: {
1338                         return 0 /* LDKAPIError - MonitorUpdateFailed */;
1339                 }
1340                 default: abort();
1341         }
1342 }
1343 jboolean LDKCResult_1NoneAPIErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1344         return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
1345 }
1346 void LDKCResult_1NoneAPIErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1347         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
1348         CHECK(val->result_ok);
1349         return *val->contents.result;
1350 }
1351 uint32_t LDKCResult_1NoneAPIErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1352         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
1353         CHECK(!val->result_ok);
1354         long err_ref = (long)&(*val->contents.err);
1355         return err_ref;
1356 }
1357 static inline LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const LDKCResult_NoneAPIErrorZ *orig) {
1358         LDKCResult_NoneAPIErrorZ res = { .result_ok = orig->result_ok };
1359         if (orig->result_ok) {
1360                 res.contents.result = NULL;
1361         } else {
1362                 LDKAPIError* contents = MALLOC(sizeof(LDKAPIError), "LDKAPIError result Err clone");
1363                 *contents = APIError_clone(orig->contents.err);
1364                 res.contents.err = contents;
1365         }
1366         return res;
1367 }
1368 uint32_t LDKCVec_1ChannelDetailsZ_1new(void* ctx_TODO, uint32_tArray elems) {
1369         LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1370         ret->datalen = elems.len;
1371         if (ret->datalen == 0) {
1372                 ret->data = NULL;
1373         } else {
1374                 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1375                 uint32_t *java_elems = elems.ptr;
1376                 for (size_t i = 0; i < ret->datalen; i++) {
1377                         uint32_t arr_elem = java_elems[i];
1378                         LDKChannelDetails arr_elem_conv;
1379                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1380                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1381                         if (arr_elem_conv.inner != NULL)
1382                                 arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1383                         ret->data[i] = arr_elem_conv;
1384                 }
1385         }
1386         return (long)ret;
1387 }
1388 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1389         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1390         for (size_t i = 0; i < ret.datalen; i++) {
1391                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1392         }
1393         return ret;
1394 }
1395 jboolean LDKCResult_1NonePaymentSendFailureZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1396         return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
1397 }
1398 void LDKCResult_1NonePaymentSendFailureZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1399         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
1400         CHECK(val->result_ok);
1401         return *val->contents.result;
1402 }
1403 uint32_t LDKCResult_1NonePaymentSendFailureZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1404         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
1405         CHECK(!val->result_ok);
1406         LDKPaymentSendFailure err_var = (*val->contents.err);
1407         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1408         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1409         long err_ref = (long)err_var.inner & ~1;
1410         return err_ref;
1411 }
1412 uint32_t LDKNetAddress_1ref_1from_1ptr (void* ctx_TODO, uint32_t ptr) {
1413         LDKNetAddress *obj = (LDKNetAddress*)ptr;
1414         switch(obj->tag) {
1415                 case LDKNetAddress_IPv4: {
1416                         int8_tArray addr_arr = { .len = 4, .ptr = MALLOC(4, "Native int8_tArray Bytes") };
1417                         memcpy(addr_arr.ptr, obj->i_pv4.addr.data, 4);
1418                         return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
1419                 }
1420                 case LDKNetAddress_IPv6: {
1421                         int8_tArray addr_arr = { .len = 16, .ptr = MALLOC(16, "Native int8_tArray Bytes") };
1422                         memcpy(addr_arr.ptr, obj->i_pv6.addr.data, 16);
1423                         return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
1424                 }
1425                 case LDKNetAddress_OnionV2: {
1426                         int8_tArray addr_arr = { .len = 10, .ptr = MALLOC(10, "Native int8_tArray Bytes") };
1427                         memcpy(addr_arr.ptr, obj->onion_v2.addr.data, 10);
1428                         return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
1429                 }
1430                 case LDKNetAddress_OnionV3: {
1431                         int8_tArray ed25519_pubkey_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1432                         memcpy(ed25519_pubkey_arr.ptr, obj->onion_v3.ed25519_pubkey.data, 32);
1433                         return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
1434                 }
1435                 default: abort();
1436         }
1437 }
1438 uint32_t LDKCVec_1NetAddressZ_1new(void* ctx_TODO, uint32_tArray elems) {
1439         LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1440         ret->datalen = elems.len;
1441         if (ret->datalen == 0) {
1442                 ret->data = NULL;
1443         } else {
1444                 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1445                 uint32_t *java_elems = elems.ptr;
1446                 for (size_t i = 0; i < ret->datalen; i++) {
1447                         uint32_t arr_elem = java_elems[i];
1448                         LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
1449                         FREE((void*)arr_elem);
1450                         ret->data[i] = arr_elem_conv;
1451                 }
1452         }
1453         return (long)ret;
1454 }
1455 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1456         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1457         for (size_t i = 0; i < ret.datalen; i++) {
1458                 ret.data[i] = NetAddress_clone(&orig->data[i]);
1459         }
1460         return ret;
1461 }
1462 uint32_t LDKCVec_1ChannelMonitorZ_1new(void* ctx_TODO, uint32_tArray elems) {
1463         LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
1464         ret->datalen = elems.len;
1465         if (ret->datalen == 0) {
1466                 ret->data = NULL;
1467         } else {
1468                 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
1469                 uint32_t *java_elems = elems.ptr;
1470                 for (size_t i = 0; i < ret->datalen; i++) {
1471                         uint32_t arr_elem = java_elems[i];
1472                         LDKChannelMonitor arr_elem_conv;
1473                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1474                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1475                         // Warning: we may need a move here but can't clone!
1476                         ret->data[i] = arr_elem_conv;
1477                 }
1478         }
1479         return (long)ret;
1480 }
1481 static void* LDKWatch_JCalls_clone(const void* this_arg) {
1482         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1483         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1484         return (void*) this_arg;
1485 }
1486 static inline LDKWatch LDKWatch_init (void* ctx_TODO, jobject o) {
1487         jclass c = (*env)->GetObjectClass(env, o);
1488         CHECK(c != NULL);
1489         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
1490         atomic_init(&calls->refcnt, 1);
1491         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1492         calls->o = (*env)->NewWeakGlobalRef(env, o);
1493         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
1494         CHECK(calls->watch_channel_meth != NULL);
1495         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
1496         CHECK(calls->update_channel_meth != NULL);
1497         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
1498         CHECK(calls->release_pending_monitor_events_meth != NULL);
1499
1500         LDKWatch ret = {
1501                 .this_arg = (void*) calls,
1502                 .watch_channel = watch_channel_jcall,
1503                 .update_channel = update_channel_jcall,
1504                 .release_pending_monitor_events = release_pending_monitor_events_jcall,
1505                 .free = LDKWatch_JCalls_free,
1506         };
1507         return ret;
1508 }
1509 long LDKWatch_1new (void* ctx_TODO, jobject o) {
1510         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
1511         *res_ptr = LDKWatch_init(env, clz, o);
1512         return (long)res_ptr;
1513 }
1514 jobject LDKWatch_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
1515         jobject ret = (*env)->NewLocalRef(env, ((LDKWatch_JCalls*)val)->o);
1516         CHECK(ret != NULL);
1517         return ret;
1518 }
1519 uint32_t Watch_1watch_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
1520         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1521         LDKOutPoint funding_txo_conv;
1522         funding_txo_conv.inner = (void*)(funding_txo & (~1));
1523         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1524         if (funding_txo_conv.inner != NULL)
1525                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1526         LDKChannelMonitor monitor_conv;
1527         monitor_conv.inner = (void*)(monitor & (~1));
1528         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
1529         // Warning: we may need a move here but can't clone!
1530         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1531         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
1532         return (long)ret_conv;
1533 }
1534
1535 uint32_t Watch_1update_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
1536         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1537         LDKOutPoint funding_txo_conv;
1538         funding_txo_conv.inner = (void*)(funding_txo & (~1));
1539         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1540         if (funding_txo_conv.inner != NULL)
1541                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1542         LDKChannelMonitorUpdate update_conv;
1543         update_conv.inner = (void*)(update & (~1));
1544         update_conv.is_owned = (update & 1) || (update == 0);
1545         if (update_conv.inner != NULL)
1546                 update_conv = ChannelMonitorUpdate_clone(&update_conv);
1547         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1548         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
1549         return (long)ret_conv;
1550 }
1551
1552 uint32_tArray Watch_1release_1pending_1monitor_1events(void* ctx_TODO, uint32_t this_arg) {
1553         LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1554         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
1555         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
1556         uint32_t *ret_arr_ptr = ret_arr.ptr;
1557         for (size_t o = 0; o < ret_var.datalen; o++) {
1558                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
1559                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1560                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1561                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
1562                 if (arr_conv_14_var.is_owned) {
1563                         arr_conv_14_ref |= 1;
1564                 }
1565                 ret_arr_ptr[o] = arr_conv_14_ref;
1566         }
1567         FREE(ret_var.data);
1568         return ret_arr;
1569 }
1570
1571 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
1572         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1573         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1574         return (void*) this_arg;
1575 }
1576 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (void* ctx_TODO, jobject o) {
1577         jclass c = (*env)->GetObjectClass(env, o);
1578         CHECK(c != NULL);
1579         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
1580         atomic_init(&calls->refcnt, 1);
1581         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1582         calls->o = (*env)->NewWeakGlobalRef(env, o);
1583         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
1584         CHECK(calls->broadcast_transaction_meth != NULL);
1585
1586         LDKBroadcasterInterface ret = {
1587                 .this_arg = (void*) calls,
1588                 .broadcast_transaction = broadcast_transaction_jcall,
1589                 .free = LDKBroadcasterInterface_JCalls_free,
1590         };
1591         return ret;
1592 }
1593 long LDKBroadcasterInterface_1new (void* ctx_TODO, jobject o) {
1594         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
1595         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
1596         return (long)res_ptr;
1597 }
1598 jobject LDKBroadcasterInterface_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
1599         jobject ret = (*env)->NewLocalRef(env, ((LDKBroadcasterInterface_JCalls*)val)->o);
1600         CHECK(ret != NULL);
1601         return ret;
1602 }
1603 void BroadcasterInterface_1broadcast_1transaction(void* ctx_TODO, uint32_t this_arg, int8_tArray tx) {
1604         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
1605         LDKTransaction tx_ref;
1606         tx_ref.datalen = tx.len;
1607         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
1608         memcpy(tx_ref.data, tx.ptr, tx_ref.datalen);
1609         tx_ref.data_is_owned = true;
1610         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
1611 }
1612
1613 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
1614         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1615         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1616         return (void*) this_arg;
1617 }
1618 static inline LDKKeysInterface LDKKeysInterface_init (void* ctx_TODO, jobject o) {
1619         jclass c = (*env)->GetObjectClass(env, o);
1620         CHECK(c != NULL);
1621         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
1622         atomic_init(&calls->refcnt, 1);
1623         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1624         calls->o = (*env)->NewWeakGlobalRef(env, o);
1625         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
1626         CHECK(calls->get_node_secret_meth != NULL);
1627         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
1628         CHECK(calls->get_destination_script_meth != NULL);
1629         calls->get_shutdown_pubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_pubkey", "()[B");
1630         CHECK(calls->get_shutdown_pubkey_meth != NULL);
1631         calls->get_channel_keys_meth = (*env)->GetMethodID(env, c, "get_channel_keys", "(ZJ)J");
1632         CHECK(calls->get_channel_keys_meth != NULL);
1633         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
1634         CHECK(calls->get_secure_random_bytes_meth != NULL);
1635         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
1636         CHECK(calls->read_chan_signer_meth != NULL);
1637
1638         LDKKeysInterface ret = {
1639                 .this_arg = (void*) calls,
1640                 .get_node_secret = get_node_secret_jcall,
1641                 .get_destination_script = get_destination_script_jcall,
1642                 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
1643                 .get_channel_keys = get_channel_keys_jcall,
1644                 .get_secure_random_bytes = get_secure_random_bytes_jcall,
1645                 .read_chan_signer = read_chan_signer_jcall,
1646                 .free = LDKKeysInterface_JCalls_free,
1647         };
1648         return ret;
1649 }
1650 long LDKKeysInterface_1new (void* ctx_TODO, jobject o) {
1651         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
1652         *res_ptr = LDKKeysInterface_init(env, clz, o);
1653         return (long)res_ptr;
1654 }
1655 jobject LDKKeysInterface_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
1656         jobject ret = (*env)->NewLocalRef(env, ((LDKKeysInterface_JCalls*)val)->o);
1657         CHECK(ret != NULL);
1658         return ret;
1659 }
1660 int8_tArray KeysInterface_1get_1node_1secret(void* ctx_TODO, uint32_t this_arg) {
1661         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1662         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1663         memcpy(arg_arr.ptr, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
1664         return arg_arr;
1665 }
1666
1667 int8_tArray KeysInterface_1get_1destination_1script(void* ctx_TODO, uint32_t this_arg) {
1668         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1669         LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
1670         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
1671         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
1672         CVec_u8Z_free(arg_var);
1673         return arg_arr;
1674 }
1675
1676 int8_tArray KeysInterface_1get_1shutdown_1pubkey(void* ctx_TODO, uint32_t this_arg) {
1677         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1678         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
1679         memcpy(arg_arr.ptr, (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
1680         return arg_arr;
1681 }
1682
1683 uint32_t KeysInterface_1get_1channel_1keys(void* ctx_TODO, uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
1684         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1685         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1686         *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
1687         return (long)ret;
1688 }
1689
1690 int8_tArray KeysInterface_1get_1secure_1random_1bytes(void* ctx_TODO, uint32_t this_arg) {
1691         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1692         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1693         memcpy(arg_arr.ptr, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
1694         return arg_arr;
1695 }
1696
1697 uint32_t KeysInterface_1read_1chan_1signer(void* ctx_TODO, uint32_t this_arg, int8_tArray reader) {
1698         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1699         LDKu8slice reader_ref;
1700         reader_ref.datalen = reader.len;
1701         reader_ref.data = reader.ptr;
1702         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
1703         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
1704         return (long)ret_conv;
1705 }
1706
1707 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
1708         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
1709         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1710         return (void*) this_arg;
1711 }
1712 static inline LDKFeeEstimator LDKFeeEstimator_init (void* ctx_TODO, jobject o) {
1713         jclass c = (*env)->GetObjectClass(env, o);
1714         CHECK(c != NULL);
1715         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
1716         atomic_init(&calls->refcnt, 1);
1717         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1718         calls->o = (*env)->NewWeakGlobalRef(env, o);
1719         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/LDKConfirmationTarget;)I");
1720         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
1721
1722         LDKFeeEstimator ret = {
1723                 .this_arg = (void*) calls,
1724                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
1725                 .free = LDKFeeEstimator_JCalls_free,
1726         };
1727         return ret;
1728 }
1729 long LDKFeeEstimator_1new (void* ctx_TODO, jobject o) {
1730         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
1731         *res_ptr = LDKFeeEstimator_init(env, clz, o);
1732         return (long)res_ptr;
1733 }
1734 jobject LDKFeeEstimator_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
1735         jobject ret = (*env)->NewLocalRef(env, ((LDKFeeEstimator_JCalls*)val)->o);
1736         CHECK(ret != NULL);
1737         return ret;
1738 }
1739 int32_t FeeEstimator_1get_1est_1sat_1per_11000_1weight(void* ctx_TODO, uint32_t this_arg, uint32_t confirmation_target) {
1740         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
1741         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
1742         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
1743         return ret_val;
1744 }
1745
1746 static void* LDKLogger_JCalls_clone(const void* this_arg) {
1747         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
1748         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1749         return (void*) this_arg;
1750 }
1751 static inline LDKLogger LDKLogger_init (void* ctx_TODO, jobject o) {
1752         jclass c = (*env)->GetObjectClass(env, o);
1753         CHECK(c != NULL);
1754         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
1755         atomic_init(&calls->refcnt, 1);
1756         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1757         calls->o = (*env)->NewWeakGlobalRef(env, o);
1758         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(Ljava/lang/String;)V");
1759         CHECK(calls->log_meth != NULL);
1760
1761         LDKLogger ret = {
1762                 .this_arg = (void*) calls,
1763                 .log = log_jcall,
1764                 .free = LDKLogger_JCalls_free,
1765         };
1766         return ret;
1767 }
1768 long LDKLogger_1new (void* ctx_TODO, jobject o) {
1769         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
1770         *res_ptr = LDKLogger_init(env, clz, o);
1771         return (long)res_ptr;
1772 }
1773 jobject LDKLogger_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
1774         jobject ret = (*env)->NewLocalRef(env, ((LDKLogger_JCalls*)val)->o);
1775         CHECK(ret != NULL);
1776         return ret;
1777 }
1778 uint32_t LDKC2Tuple_1BlockHashChannelManagerZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) {
1779         LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
1780         LDKThirtyTwoBytes a_ref;
1781         CHECK(a.len == 32);
1782         memcpy(a_ref.data, a.ptr, 32);
1783         ret->a = a_ref;
1784         LDKChannelManager b_conv;
1785         b_conv.inner = (void*)(b & (~1));
1786         b_conv.is_owned = (b & 1) || (b == 0);
1787         // Warning: we may need a move here but can't clone!
1788         ret->b = b_conv;
1789         return (long)ret;
1790 }
1791 int8_tArray LDKC2Tuple_1BlockHashChannelManagerZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
1792         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)ptr;
1793         int8_tArray a_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
1794         memcpy(a_arr.ptr, tuple->a.data, 32);
1795         return a_arr;
1796 }
1797 uint32_t LDKC2Tuple_1BlockHashChannelManagerZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
1798         LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)ptr;
1799         LDKChannelManager 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 jboolean LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1806         return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
1807 }
1808 uint32_t LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1809         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg;
1810         CHECK(val->result_ok);
1811         long res_ref = (long)&(*val->contents.result);
1812         return res_ref;
1813 }
1814 uint32_t LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1815         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg;
1816         CHECK(!val->result_ok);
1817         LDKDecodeError err_var = (*val->contents.err);
1818         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1819         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1820         long err_ref = (long)err_var.inner & ~1;
1821         return err_ref;
1822 }
1823 jboolean LDKCResult_1NetAddressu8Z_1result_1ok (void* ctx_TODO, uint32_t arg) {
1824         return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
1825 }
1826 uint32_t LDKCResult_1NetAddressu8Z_1get_1ok (void* ctx_TODO, uint32_t arg) {
1827         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)arg;
1828         CHECK(val->result_ok);
1829         long res_ref = (long)&(*val->contents.result);
1830         return res_ref;
1831 }
1832 int8_t LDKCResult_1NetAddressu8Z_1get_1err (void* ctx_TODO, uint32_t arg) {
1833         LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)arg;
1834         CHECK(!val->result_ok);
1835         return *val->contents.err;
1836 }
1837 static inline LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const LDKCResult_NetAddressu8Z *orig) {
1838         LDKCResult_NetAddressu8Z res = { .result_ok = orig->result_ok };
1839         if (orig->result_ok) {
1840                 LDKNetAddress* contents = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress result OK clone");
1841                 *contents = NetAddress_clone(orig->contents.result);
1842                 res.contents.result = contents;
1843         } else {
1844                 int8_t* contents = MALLOC(sizeof(int8_t), "int8_t result Err clone");
1845                 *contents = *orig->contents.err;
1846                 res.contents.err = contents;
1847         }
1848         return res;
1849 }
1850 jboolean LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1851         return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
1852 }
1853 uint32_t LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
1854         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg;
1855         CHECK(val->result_ok);
1856         LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
1857         *res_conv = (*val->contents.result);
1858         *res_conv = CResult_NetAddressu8Z_clone(res_conv);
1859         return (long)res_conv;
1860 }
1861 uint32_t LDKCResult_1CResult_1NetAddressu8ZDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
1862         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg;
1863         CHECK(!val->result_ok);
1864         LDKDecodeError err_var = (*val->contents.err);
1865         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1866         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1867         long err_ref = (long)err_var.inner & ~1;
1868         return err_ref;
1869 }
1870 uint32_t LDKCVec_1u64Z_1new(void* ctx_TODO, int64_tArray elems) {
1871         LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
1872         ret->datalen = elems.len;
1873         if (ret->datalen == 0) {
1874                 ret->data = NULL;
1875         } else {
1876                 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
1877                 int64_t *java_elems = elems.ptr;
1878                 for (size_t i = 0; i < ret->datalen; i++) {
1879                         ret->data[i] = java_elems[i];
1880                 }
1881         }
1882         return (long)ret;
1883 }
1884 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
1885         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
1886         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
1887         return ret;
1888 }
1889 uint32_t LDKCVec_1UpdateAddHTLCZ_1new(void* ctx_TODO, uint32_tArray elems) {
1890         LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
1891         ret->datalen = elems.len;
1892         if (ret->datalen == 0) {
1893                 ret->data = NULL;
1894         } else {
1895                 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
1896                 uint32_t *java_elems = elems.ptr;
1897                 for (size_t i = 0; i < ret->datalen; i++) {
1898                         uint32_t arr_elem = java_elems[i];
1899                         LDKUpdateAddHTLC arr_elem_conv;
1900                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1901                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1902                         if (arr_elem_conv.inner != NULL)
1903                                 arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
1904                         ret->data[i] = arr_elem_conv;
1905                 }
1906         }
1907         return (long)ret;
1908 }
1909 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
1910         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
1911         for (size_t i = 0; i < ret.datalen; i++) {
1912                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
1913         }
1914         return ret;
1915 }
1916 uint32_t LDKCVec_1UpdateFulfillHTLCZ_1new(void* ctx_TODO, uint32_tArray elems) {
1917         LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
1918         ret->datalen = elems.len;
1919         if (ret->datalen == 0) {
1920                 ret->data = NULL;
1921         } else {
1922                 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
1923                 uint32_t *java_elems = elems.ptr;
1924                 for (size_t i = 0; i < ret->datalen; i++) {
1925                         uint32_t arr_elem = java_elems[i];
1926                         LDKUpdateFulfillHTLC arr_elem_conv;
1927                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1928                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1929                         if (arr_elem_conv.inner != NULL)
1930                                 arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
1931                         ret->data[i] = arr_elem_conv;
1932                 }
1933         }
1934         return (long)ret;
1935 }
1936 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
1937         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
1938         for (size_t i = 0; i < ret.datalen; i++) {
1939                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
1940         }
1941         return ret;
1942 }
1943 uint32_t LDKCVec_1UpdateFailHTLCZ_1new(void* ctx_TODO, uint32_tArray elems) {
1944         LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
1945         ret->datalen = elems.len;
1946         if (ret->datalen == 0) {
1947                 ret->data = NULL;
1948         } else {
1949                 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
1950                 uint32_t *java_elems = elems.ptr;
1951                 for (size_t i = 0; i < ret->datalen; i++) {
1952                         uint32_t arr_elem = java_elems[i];
1953                         LDKUpdateFailHTLC arr_elem_conv;
1954                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1955                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1956                         if (arr_elem_conv.inner != NULL)
1957                                 arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
1958                         ret->data[i] = arr_elem_conv;
1959                 }
1960         }
1961         return (long)ret;
1962 }
1963 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
1964         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
1965         for (size_t i = 0; i < ret.datalen; i++) {
1966                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
1967         }
1968         return ret;
1969 }
1970 uint32_t LDKCVec_1UpdateFailMalformedHTLCZ_1new(void* ctx_TODO, uint32_tArray elems) {
1971         LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
1972         ret->datalen = elems.len;
1973         if (ret->datalen == 0) {
1974                 ret->data = NULL;
1975         } else {
1976                 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
1977                 uint32_t *java_elems = elems.ptr;
1978                 for (size_t i = 0; i < ret->datalen; i++) {
1979                         uint32_t arr_elem = java_elems[i];
1980                         LDKUpdateFailMalformedHTLC arr_elem_conv;
1981                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
1982                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1983                         if (arr_elem_conv.inner != NULL)
1984                                 arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
1985                         ret->data[i] = arr_elem_conv;
1986                 }
1987         }
1988         return (long)ret;
1989 }
1990 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
1991         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
1992         for (size_t i = 0; i < ret.datalen; i++) {
1993                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
1994         }
1995         return ret;
1996 }
1997 jboolean LDKCResult_1boolLightningErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
1998         return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
1999 }
2000 jboolean LDKCResult_1boolLightningErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2001         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
2002         CHECK(val->result_ok);
2003         return *val->contents.result;
2004 }
2005 uint32_t LDKCResult_1boolLightningErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2006         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
2007         CHECK(!val->result_ok);
2008         LDKLightningError err_var = (*val->contents.err);
2009         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2010         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2011         long err_ref = (long)err_var.inner & ~1;
2012         return err_ref;
2013 }
2014 uint32_t LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(void* ctx_TODO, uint32_t a, uint32_t b, uint32_t c) {
2015         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
2016         LDKChannelAnnouncement a_conv;
2017         a_conv.inner = (void*)(a & (~1));
2018         a_conv.is_owned = (a & 1) || (a == 0);
2019         if (a_conv.inner != NULL)
2020                 a_conv = ChannelAnnouncement_clone(&a_conv);
2021         ret->a = a_conv;
2022         LDKChannelUpdate b_conv;
2023         b_conv.inner = (void*)(b & (~1));
2024         b_conv.is_owned = (b & 1) || (b == 0);
2025         if (b_conv.inner != NULL)
2026                 b_conv = ChannelUpdate_clone(&b_conv);
2027         ret->b = b_conv;
2028         LDKChannelUpdate c_conv;
2029         c_conv.inner = (void*)(c & (~1));
2030         c_conv.is_owned = (c & 1) || (c == 0);
2031         if (c_conv.inner != NULL)
2032                 c_conv = ChannelUpdate_clone(&c_conv);
2033         ret->c = c_conv;
2034         return (long)ret;
2035 }
2036 static inline LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *orig) {
2037         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret = {
2038                 .a = ChannelAnnouncement_clone(&orig->a),
2039                 .b = ChannelUpdate_clone(&orig->b),
2040                 .c = ChannelUpdate_clone(&orig->c),
2041         };
2042         return ret;
2043 }
2044 uint32_t LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(void* ctx_TODO, uint32_t ptr) {
2045         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2046         LDKChannelAnnouncement a_var = tuple->a;
2047         CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2048         CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2049         long a_ref = (long)a_var.inner & ~1;
2050         return a_ref;
2051 }
2052 uint32_t LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(void* ctx_TODO, uint32_t ptr) {
2053         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2054         LDKChannelUpdate b_var = tuple->b;
2055         CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2056         CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2057         long b_ref = (long)b_var.inner & ~1;
2058         return b_ref;
2059 }
2060 uint32_t LDKC3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(void* ctx_TODO, uint32_t ptr) {
2061         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2062         LDKChannelUpdate c_var = tuple->c;
2063         CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2064         CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2065         long c_ref = (long)c_var.inner & ~1;
2066         return c_ref;
2067 }
2068 uint32_t LDKCVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1new(void* ctx_TODO, uint32_tArray elems) {
2069         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
2070         ret->datalen = elems.len;
2071         if (ret->datalen == 0) {
2072                 ret->data = NULL;
2073         } else {
2074                 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
2075                 uint32_t *java_elems = elems.ptr;
2076                 for (size_t i = 0; i < ret->datalen; i++) {
2077                         uint32_t arr_elem = java_elems[i];
2078                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_elem;
2079                         FREE((void*)arr_elem);
2080                         ret->data[i] = arr_elem_conv;
2081                 }
2082         }
2083         return (long)ret;
2084 }
2085 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
2086         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
2087         for (size_t i = 0; i < ret.datalen; i++) {
2088                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
2089         }
2090         return ret;
2091 }
2092 uint32_t LDKCVec_1NodeAnnouncementZ_1new(void* ctx_TODO, uint32_tArray elems) {
2093         LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
2094         ret->datalen = elems.len;
2095         if (ret->datalen == 0) {
2096                 ret->data = NULL;
2097         } else {
2098                 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
2099                 uint32_t *java_elems = elems.ptr;
2100                 for (size_t i = 0; i < ret->datalen; i++) {
2101                         uint32_t arr_elem = java_elems[i];
2102                         LDKNodeAnnouncement arr_elem_conv;
2103                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2104                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2105                         if (arr_elem_conv.inner != NULL)
2106                                 arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
2107                         ret->data[i] = arr_elem_conv;
2108                 }
2109         }
2110         return (long)ret;
2111 }
2112 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
2113         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
2114         for (size_t i = 0; i < ret.datalen; i++) {
2115                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
2116         }
2117         return ret;
2118 }
2119 jboolean LDKCResult_1NoneLightningErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2120         return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
2121 }
2122 void LDKCResult_1NoneLightningErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2123         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)arg;
2124         CHECK(val->result_ok);
2125         return *val->contents.result;
2126 }
2127 uint32_t LDKCResult_1NoneLightningErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2128         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)arg;
2129         CHECK(!val->result_ok);
2130         LDKLightningError err_var = (*val->contents.err);
2131         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2132         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2133         long err_ref = (long)err_var.inner & ~1;
2134         return err_ref;
2135 }
2136 jboolean LDKCResult_1ChannelReestablishDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2137         return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
2138 }
2139 uint32_t LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2140         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)arg;
2141         CHECK(val->result_ok);
2142         LDKChannelReestablish res_var = (*val->contents.result);
2143         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2144         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2145         long res_ref = (long)res_var.inner & ~1;
2146         return res_ref;
2147 }
2148 uint32_t LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2149         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)arg;
2150         CHECK(!val->result_ok);
2151         LDKDecodeError err_var = (*val->contents.err);
2152         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2153         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2154         long err_ref = (long)err_var.inner & ~1;
2155         return err_ref;
2156 }
2157 jboolean LDKCResult_1InitDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2158         return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
2159 }
2160 uint32_t LDKCResult_1InitDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2161         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)arg;
2162         CHECK(val->result_ok);
2163         LDKInit res_var = (*val->contents.result);
2164         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2165         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2166         long res_ref = (long)res_var.inner & ~1;
2167         return res_ref;
2168 }
2169 uint32_t LDKCResult_1InitDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2170         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)arg;
2171         CHECK(!val->result_ok);
2172         LDKDecodeError err_var = (*val->contents.err);
2173         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2174         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2175         long err_ref = (long)err_var.inner & ~1;
2176         return err_ref;
2177 }
2178 jboolean LDKCResult_1PingDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2179         return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
2180 }
2181 uint32_t LDKCResult_1PingDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2182         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)arg;
2183         CHECK(val->result_ok);
2184         LDKPing res_var = (*val->contents.result);
2185         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2186         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2187         long res_ref = (long)res_var.inner & ~1;
2188         return res_ref;
2189 }
2190 uint32_t LDKCResult_1PingDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2191         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)arg;
2192         CHECK(!val->result_ok);
2193         LDKDecodeError err_var = (*val->contents.err);
2194         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2195         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2196         long err_ref = (long)err_var.inner & ~1;
2197         return err_ref;
2198 }
2199 jboolean LDKCResult_1PongDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2200         return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
2201 }
2202 uint32_t LDKCResult_1PongDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2203         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)arg;
2204         CHECK(val->result_ok);
2205         LDKPong res_var = (*val->contents.result);
2206         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2207         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2208         long res_ref = (long)res_var.inner & ~1;
2209         return res_ref;
2210 }
2211 uint32_t LDKCResult_1PongDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2212         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)arg;
2213         CHECK(!val->result_ok);
2214         LDKDecodeError err_var = (*val->contents.err);
2215         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2216         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2217         long err_ref = (long)err_var.inner & ~1;
2218         return err_ref;
2219 }
2220 jboolean LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2221         return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
2222 }
2223 uint32_t LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2224         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg;
2225         CHECK(val->result_ok);
2226         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
2227         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2228         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2229         long res_ref = (long)res_var.inner & ~1;
2230         return res_ref;
2231 }
2232 uint32_t LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2233         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg;
2234         CHECK(!val->result_ok);
2235         LDKDecodeError err_var = (*val->contents.err);
2236         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2237         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2238         long err_ref = (long)err_var.inner & ~1;
2239         return err_ref;
2240 }
2241 jboolean LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2242         return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
2243 }
2244 uint32_t LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2245         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg;
2246         CHECK(val->result_ok);
2247         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
2248         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2249         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2250         long res_ref = (long)res_var.inner & ~1;
2251         return res_ref;
2252 }
2253 uint32_t LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2254         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg;
2255         CHECK(!val->result_ok);
2256         LDKDecodeError err_var = (*val->contents.err);
2257         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2258         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2259         long err_ref = (long)err_var.inner & ~1;
2260         return err_ref;
2261 }
2262 jboolean LDKCResult_1ErrorMessageDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2263         return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
2264 }
2265 uint32_t LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2266         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)arg;
2267         CHECK(val->result_ok);
2268         LDKErrorMessage res_var = (*val->contents.result);
2269         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2270         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2271         long res_ref = (long)res_var.inner & ~1;
2272         return res_ref;
2273 }
2274 uint32_t LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2275         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)arg;
2276         CHECK(!val->result_ok);
2277         LDKDecodeError err_var = (*val->contents.err);
2278         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2279         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2280         long err_ref = (long)err_var.inner & ~1;
2281         return err_ref;
2282 }
2283 jboolean LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2284         return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
2285 }
2286 uint32_t LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2287         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg;
2288         CHECK(val->result_ok);
2289         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
2290         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2291         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2292         long res_ref = (long)res_var.inner & ~1;
2293         return res_ref;
2294 }
2295 uint32_t LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2296         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg;
2297         CHECK(!val->result_ok);
2298         LDKDecodeError err_var = (*val->contents.err);
2299         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2300         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2301         long err_ref = (long)err_var.inner & ~1;
2302         return err_ref;
2303 }
2304 jboolean LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2305         return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
2306 }
2307 uint32_t LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2308         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg;
2309         CHECK(val->result_ok);
2310         LDKQueryShortChannelIds res_var = (*val->contents.result);
2311         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2312         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2313         long res_ref = (long)res_var.inner & ~1;
2314         return res_ref;
2315 }
2316 uint32_t LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2317         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg;
2318         CHECK(!val->result_ok);
2319         LDKDecodeError err_var = (*val->contents.err);
2320         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2321         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2322         long err_ref = (long)err_var.inner & ~1;
2323         return err_ref;
2324 }
2325 jboolean LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2326         return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
2327 }
2328 uint32_t LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2329         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg;
2330         CHECK(val->result_ok);
2331         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
2332         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2333         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2334         long res_ref = (long)res_var.inner & ~1;
2335         return res_ref;
2336 }
2337 uint32_t LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2338         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg;
2339         CHECK(!val->result_ok);
2340         LDKDecodeError err_var = (*val->contents.err);
2341         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2342         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2343         long err_ref = (long)err_var.inner & ~1;
2344         return err_ref;
2345 }
2346 jboolean LDKCResult_1QueryChannelRangeDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2347         return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
2348 }
2349 uint32_t LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2350         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)arg;
2351         CHECK(val->result_ok);
2352         LDKQueryChannelRange res_var = (*val->contents.result);
2353         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2354         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2355         long res_ref = (long)res_var.inner & ~1;
2356         return res_ref;
2357 }
2358 uint32_t LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2359         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)arg;
2360         CHECK(!val->result_ok);
2361         LDKDecodeError err_var = (*val->contents.err);
2362         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2363         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2364         long err_ref = (long)err_var.inner & ~1;
2365         return err_ref;
2366 }
2367 jboolean LDKCResult_1ReplyChannelRangeDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2368         return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
2369 }
2370 uint32_t LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2371         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg;
2372         CHECK(val->result_ok);
2373         LDKReplyChannelRange res_var = (*val->contents.result);
2374         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2375         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2376         long res_ref = (long)res_var.inner & ~1;
2377         return res_ref;
2378 }
2379 uint32_t LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2380         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg;
2381         CHECK(!val->result_ok);
2382         LDKDecodeError err_var = (*val->contents.err);
2383         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2384         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2385         long err_ref = (long)err_var.inner & ~1;
2386         return err_ref;
2387 }
2388 jboolean LDKCResult_1GossipTimestampFilterDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2389         return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
2390 }
2391 uint32_t LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2392         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg;
2393         CHECK(val->result_ok);
2394         LDKGossipTimestampFilter res_var = (*val->contents.result);
2395         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2396         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2397         long res_ref = (long)res_var.inner & ~1;
2398         return res_ref;
2399 }
2400 uint32_t LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2401         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg;
2402         CHECK(!val->result_ok);
2403         LDKDecodeError err_var = (*val->contents.err);
2404         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2405         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2406         long err_ref = (long)err_var.inner & ~1;
2407         return err_ref;
2408 }
2409 jboolean LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2410         return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
2411 }
2412 int8_tArray LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2413         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
2414         CHECK(val->result_ok);
2415         LDKCVec_u8Z res_var = (*val->contents.result);
2416         int8_tArray res_arr = { .len = res_var.datalen, .ptr = MALLOC(res_var.datalen, "Native int8_tArray Bytes") };
2417         memcpy(res_arr.ptr, res_var.data, res_var.datalen);
2418         return res_arr;
2419 }
2420 uint32_t LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2421         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
2422         CHECK(!val->result_ok);
2423         LDKPeerHandleError err_var = (*val->contents.err);
2424         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2425         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2426         long err_ref = (long)err_var.inner & ~1;
2427         return err_ref;
2428 }
2429 jboolean LDKCResult_1NonePeerHandleErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2430         return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
2431 }
2432 void LDKCResult_1NonePeerHandleErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2433         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
2434         CHECK(val->result_ok);
2435         return *val->contents.result;
2436 }
2437 uint32_t LDKCResult_1NonePeerHandleErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2438         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
2439         CHECK(!val->result_ok);
2440         LDKPeerHandleError err_var = (*val->contents.err);
2441         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2442         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2443         long err_ref = (long)err_var.inner & ~1;
2444         return err_ref;
2445 }
2446 jboolean LDKCResult_1boolPeerHandleErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2447         return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
2448 }
2449 jboolean LDKCResult_1boolPeerHandleErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2450         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
2451         CHECK(val->result_ok);
2452         return *val->contents.result;
2453 }
2454 uint32_t LDKCResult_1boolPeerHandleErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2455         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
2456         CHECK(!val->result_ok);
2457         LDKPeerHandleError err_var = (*val->contents.err);
2458         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2459         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2460         long err_ref = (long)err_var.inner & ~1;
2461         return err_ref;
2462 }
2463 jboolean LDKCResult_1SecretKeySecpErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2464         return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
2465 }
2466 int8_tArray LDKCResult_1SecretKeySecpErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2467         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
2468         CHECK(val->result_ok);
2469         int8_tArray res_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
2470         memcpy(res_arr.ptr, (*val->contents.result).bytes, 32);
2471         return res_arr;
2472 }
2473 uint32_t LDKCResult_1SecretKeySecpErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2474         LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
2475         CHECK(!val->result_ok);
2476         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2477         return err_conv;
2478 }
2479 jboolean LDKCResult_1PublicKeySecpErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2480         return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
2481 }
2482 int8_tArray LDKCResult_1PublicKeySecpErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2483         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
2484         CHECK(val->result_ok);
2485         int8_tArray res_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
2486         memcpy(res_arr.ptr, (*val->contents.result).compressed_form, 33);
2487         return res_arr;
2488 }
2489 uint32_t LDKCResult_1PublicKeySecpErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2490         LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
2491         CHECK(!val->result_ok);
2492         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2493         return err_conv;
2494 }
2495 jboolean LDKCResult_1TxCreationKeysSecpErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2496         return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
2497 }
2498 uint32_t LDKCResult_1TxCreationKeysSecpErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2499         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
2500         CHECK(val->result_ok);
2501         LDKTxCreationKeys res_var = (*val->contents.result);
2502         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2503         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2504         long res_ref = (long)res_var.inner & ~1;
2505         return res_ref;
2506 }
2507 uint32_t LDKCResult_1TxCreationKeysSecpErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2508         LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
2509         CHECK(!val->result_ok);
2510         uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2511         return err_conv;
2512 }
2513 jboolean LDKCResult_1TrustedCommitmentTransactionNoneZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2514         return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
2515 }
2516 uint32_t LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2517         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)arg;
2518         CHECK(val->result_ok);
2519         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
2520         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2521         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2522         long res_ref = (long)res_var.inner & ~1;
2523         return res_ref;
2524 }
2525 void LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2526         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)arg;
2527         CHECK(!val->result_ok);
2528         return *val->contents.err;
2529 }
2530 uint32_t LDKCVec_1RouteHopZ_1new(void* ctx_TODO, uint32_tArray elems) {
2531         LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2532         ret->datalen = elems.len;
2533         if (ret->datalen == 0) {
2534                 ret->data = NULL;
2535         } else {
2536                 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2537                 uint32_t *java_elems = elems.ptr;
2538                 for (size_t i = 0; i < ret->datalen; i++) {
2539                         uint32_t arr_elem = java_elems[i];
2540                         LDKRouteHop arr_elem_conv;
2541                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2542                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2543                         if (arr_elem_conv.inner != NULL)
2544                                 arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2545                         ret->data[i] = arr_elem_conv;
2546                 }
2547         }
2548         return (long)ret;
2549 }
2550 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2551         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2552         for (size_t i = 0; i < ret.datalen; i++) {
2553                 ret.data[i] = RouteHop_clone(&orig->data[i]);
2554         }
2555         return ret;
2556 }
2557 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2558         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2559         for (size_t i = 0; i < ret.datalen; i++) {
2560                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2561         }
2562         return ret;
2563 }
2564 jboolean LDKCResult_1RouteDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2565         return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2566 }
2567 uint32_t LDKCResult_1RouteDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2568         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)arg;
2569         CHECK(val->result_ok);
2570         LDKRoute res_var = (*val->contents.result);
2571         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2572         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2573         long res_ref = (long)res_var.inner & ~1;
2574         return res_ref;
2575 }
2576 uint32_t LDKCResult_1RouteDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2577         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)arg;
2578         CHECK(!val->result_ok);
2579         LDKDecodeError err_var = (*val->contents.err);
2580         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2581         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2582         long err_ref = (long)err_var.inner & ~1;
2583         return err_ref;
2584 }
2585 uint32_t LDKCVec_1RouteHintZ_1new(void* ctx_TODO, uint32_tArray elems) {
2586         LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2587         ret->datalen = elems.len;
2588         if (ret->datalen == 0) {
2589                 ret->data = NULL;
2590         } else {
2591                 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2592                 uint32_t *java_elems = elems.ptr;
2593                 for (size_t i = 0; i < ret->datalen; i++) {
2594                         uint32_t arr_elem = java_elems[i];
2595                         LDKRouteHint arr_elem_conv;
2596                         arr_elem_conv.inner = (void*)(arr_elem & (~1));
2597                         arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2598                         if (arr_elem_conv.inner != NULL)
2599                                 arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2600                         ret->data[i] = arr_elem_conv;
2601                 }
2602         }
2603         return (long)ret;
2604 }
2605 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2606         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2607         for (size_t i = 0; i < ret.datalen; i++) {
2608                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2609         }
2610         return ret;
2611 }
2612 jboolean LDKCResult_1RouteLightningErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2613         return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
2614 }
2615 uint32_t LDKCResult_1RouteLightningErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2616         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
2617         CHECK(val->result_ok);
2618         LDKRoute res_var = (*val->contents.result);
2619         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2620         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2621         long res_ref = (long)res_var.inner & ~1;
2622         return res_ref;
2623 }
2624 uint32_t LDKCResult_1RouteLightningErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2625         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
2626         CHECK(!val->result_ok);
2627         LDKLightningError err_var = (*val->contents.err);
2628         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2629         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2630         long err_ref = (long)err_var.inner & ~1;
2631         return err_ref;
2632 }
2633 jboolean LDKCResult_1RoutingFeesDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2634         return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
2635 }
2636 uint32_t LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2637         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)arg;
2638         CHECK(val->result_ok);
2639         LDKRoutingFees res_var = (*val->contents.result);
2640         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2641         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2642         long res_ref = (long)res_var.inner & ~1;
2643         return res_ref;
2644 }
2645 uint32_t LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2646         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)arg;
2647         CHECK(!val->result_ok);
2648         LDKDecodeError err_var = (*val->contents.err);
2649         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2650         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2651         long err_ref = (long)err_var.inner & ~1;
2652         return err_ref;
2653 }
2654 jboolean LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2655         return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
2656 }
2657 uint32_t LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2658         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg;
2659         CHECK(val->result_ok);
2660         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
2661         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2662         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2663         long res_ref = (long)res_var.inner & ~1;
2664         return res_ref;
2665 }
2666 uint32_t LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2667         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg;
2668         CHECK(!val->result_ok);
2669         LDKDecodeError err_var = (*val->contents.err);
2670         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2671         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2672         long err_ref = (long)err_var.inner & ~1;
2673         return err_ref;
2674 }
2675 jboolean LDKCResult_1NodeInfoDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2676         return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
2677 }
2678 uint32_t LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2679         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)arg;
2680         CHECK(val->result_ok);
2681         LDKNodeInfo res_var = (*val->contents.result);
2682         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2683         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2684         long res_ref = (long)res_var.inner & ~1;
2685         return res_ref;
2686 }
2687 uint32_t LDKCResult_1NodeInfoDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2688         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)arg;
2689         CHECK(!val->result_ok);
2690         LDKDecodeError err_var = (*val->contents.err);
2691         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2692         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2693         long err_ref = (long)err_var.inner & ~1;
2694         return err_ref;
2695 }
2696 jboolean LDKCResult_1NetworkGraphDecodeErrorZ_1result_1ok (void* ctx_TODO, uint32_t arg) {
2697         return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
2698 }
2699 uint32_t LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok (void* ctx_TODO, uint32_t arg) {
2700         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)arg;
2701         CHECK(val->result_ok);
2702         LDKNetworkGraph res_var = (*val->contents.result);
2703         CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2704         CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2705         long res_ref = (long)res_var.inner & ~1;
2706         return res_ref;
2707 }
2708 uint32_t LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err (void* ctx_TODO, uint32_t arg) {
2709         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)arg;
2710         CHECK(!val->result_ok);
2711         LDKDecodeError err_var = (*val->contents.err);
2712         CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2713         CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2714         long err_ref = (long)err_var.inner & ~1;
2715         return err_ref;
2716 }
2717 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
2718         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
2719         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2720         return (void*) this_arg;
2721 }
2722 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (void* ctx_TODO, jobject o) {
2723         jclass c = (*env)->GetObjectClass(env, o);
2724         CHECK(c != NULL);
2725         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
2726         atomic_init(&calls->refcnt, 1);
2727         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2728         calls->o = (*env)->NewWeakGlobalRef(env, o);
2729         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
2730         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
2731
2732         LDKMessageSendEventsProvider ret = {
2733                 .this_arg = (void*) calls,
2734                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
2735                 .free = LDKMessageSendEventsProvider_JCalls_free,
2736         };
2737         return ret;
2738 }
2739 long LDKMessageSendEventsProvider_1new (void* ctx_TODO, jobject o) {
2740         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
2741         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
2742         return (long)res_ptr;
2743 }
2744 jobject LDKMessageSendEventsProvider_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
2745         jobject ret = (*env)->NewLocalRef(env, ((LDKMessageSendEventsProvider_JCalls*)val)->o);
2746         CHECK(ret != NULL);
2747         return ret;
2748 }
2749 uint32_tArray MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(void* ctx_TODO, uint32_t this_arg) {
2750         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
2751         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
2752         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
2753         uint32_t *ret_arr_ptr = ret_arr.ptr;
2754         for (size_t s = 0; s < ret_var.datalen; s++) {
2755                 LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
2756                 *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
2757                 long arr_conv_18_ref = (long)arr_conv_18_copy;
2758                 ret_arr_ptr[s] = arr_conv_18_ref;
2759         }
2760         FREE(ret_var.data);
2761         return ret_arr;
2762 }
2763
2764 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
2765         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
2766         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2767         return (void*) this_arg;
2768 }
2769 static inline LDKEventsProvider LDKEventsProvider_init (void* ctx_TODO, jobject o) {
2770         jclass c = (*env)->GetObjectClass(env, o);
2771         CHECK(c != NULL);
2772         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
2773         atomic_init(&calls->refcnt, 1);
2774         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2775         calls->o = (*env)->NewWeakGlobalRef(env, o);
2776         calls->get_and_clear_pending_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_events", "()[J");
2777         CHECK(calls->get_and_clear_pending_events_meth != NULL);
2778
2779         LDKEventsProvider ret = {
2780                 .this_arg = (void*) calls,
2781                 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
2782                 .free = LDKEventsProvider_JCalls_free,
2783         };
2784         return ret;
2785 }
2786 long LDKEventsProvider_1new (void* ctx_TODO, jobject o) {
2787         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
2788         *res_ptr = LDKEventsProvider_init(env, clz, o);
2789         return (long)res_ptr;
2790 }
2791 jobject LDKEventsProvider_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
2792         jobject ret = (*env)->NewLocalRef(env, ((LDKEventsProvider_JCalls*)val)->o);
2793         CHECK(ret != NULL);
2794         return ret;
2795 }
2796 uint32_tArray EventsProvider_1get_1and_1clear_1pending_1events(void* ctx_TODO, uint32_t this_arg) {
2797         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
2798         LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
2799         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
2800         uint32_t *ret_arr_ptr = ret_arr.ptr;
2801         for (size_t h = 0; h < ret_var.datalen; h++) {
2802                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
2803                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
2804                 long arr_conv_7_ref = (long)arr_conv_7_copy;
2805                 ret_arr_ptr[h] = arr_conv_7_ref;
2806         }
2807         FREE(ret_var.data);
2808         return ret_arr;
2809 }
2810
2811 static void* LDKAccess_JCalls_clone(const void* this_arg) {
2812         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
2813         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2814         return (void*) this_arg;
2815 }
2816 static inline LDKAccess LDKAccess_init (void* ctx_TODO, jobject o) {
2817         jclass c = (*env)->GetObjectClass(env, o);
2818         CHECK(c != NULL);
2819         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
2820         atomic_init(&calls->refcnt, 1);
2821         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2822         calls->o = (*env)->NewWeakGlobalRef(env, o);
2823         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
2824         CHECK(calls->get_utxo_meth != NULL);
2825
2826         LDKAccess ret = {
2827                 .this_arg = (void*) calls,
2828                 .get_utxo = get_utxo_jcall,
2829                 .free = LDKAccess_JCalls_free,
2830         };
2831         return ret;
2832 }
2833 long LDKAccess_1new (void* ctx_TODO, jobject o) {
2834         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
2835         *res_ptr = LDKAccess_init(env, clz, o);
2836         return (long)res_ptr;
2837 }
2838 jobject LDKAccess_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
2839         jobject ret = (*env)->NewLocalRef(env, ((LDKAccess_JCalls*)val)->o);
2840         CHECK(ret != NULL);
2841         return ret;
2842 }
2843 uint32_t Access_1get_1utxo(void* ctx_TODO, uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
2844         LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
2845         unsigned char genesis_hash_arr[32];
2846         CHECK(genesis_hash.len == 32);
2847         memcpy(genesis_hash_arr, genesis_hash.ptr, 32);
2848         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
2849         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
2850         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
2851         return (long)ret_conv;
2852 }
2853
2854 static void* LDKFilter_JCalls_clone(const void* this_arg) {
2855         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
2856         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2857         return (void*) this_arg;
2858 }
2859 static inline LDKFilter LDKFilter_init (void* ctx_TODO, jobject o) {
2860         jclass c = (*env)->GetObjectClass(env, o);
2861         CHECK(c != NULL);
2862         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
2863         atomic_init(&calls->refcnt, 1);
2864         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2865         calls->o = (*env)->NewWeakGlobalRef(env, o);
2866         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
2867         CHECK(calls->register_tx_meth != NULL);
2868         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J[B)V");
2869         CHECK(calls->register_output_meth != NULL);
2870
2871         LDKFilter ret = {
2872                 .this_arg = (void*) calls,
2873                 .register_tx = register_tx_jcall,
2874                 .register_output = register_output_jcall,
2875                 .free = LDKFilter_JCalls_free,
2876         };
2877         return ret;
2878 }
2879 long LDKFilter_1new (void* ctx_TODO, jobject o) {
2880         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
2881         *res_ptr = LDKFilter_init(env, clz, o);
2882         return (long)res_ptr;
2883 }
2884 jobject LDKFilter_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
2885         jobject ret = (*env)->NewLocalRef(env, ((LDKFilter_JCalls*)val)->o);
2886         CHECK(ret != NULL);
2887         return ret;
2888 }
2889 void Filter_1register_1tx(void* ctx_TODO, uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
2890         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2891         unsigned char txid_arr[32];
2892         CHECK(txid.len == 32);
2893         memcpy(txid_arr, txid.ptr, 32);
2894         unsigned char (*txid_ref)[32] = &txid_arr;
2895         LDKu8slice script_pubkey_ref;
2896         script_pubkey_ref.datalen = script_pubkey.len;
2897         script_pubkey_ref.data = script_pubkey.ptr;
2898         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
2899 }
2900
2901 void Filter_1register_1output(void* ctx_TODO, uint32_t this_arg, uint32_t outpoint, int8_tArray script_pubkey) {
2902         LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
2903         LDKOutPoint outpoint_conv;
2904         outpoint_conv.inner = (void*)(outpoint & (~1));
2905         outpoint_conv.is_owned = false;
2906         LDKu8slice script_pubkey_ref;
2907         script_pubkey_ref.datalen = script_pubkey.len;
2908         script_pubkey_ref.data = script_pubkey.ptr;
2909         (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
2910 }
2911
2912 static void* LDKPersist_JCalls_clone(const void* this_arg) {
2913         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
2914         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2915         return (void*) this_arg;
2916 }
2917 static inline LDKPersist LDKPersist_init (void* ctx_TODO, jobject o) {
2918         jclass c = (*env)->GetObjectClass(env, o);
2919         CHECK(c != NULL);
2920         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
2921         atomic_init(&calls->refcnt, 1);
2922         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2923         calls->o = (*env)->NewWeakGlobalRef(env, o);
2924         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJ)J");
2925         CHECK(calls->persist_new_channel_meth != NULL);
2926         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJ)J");
2927         CHECK(calls->update_persisted_channel_meth != NULL);
2928
2929         LDKPersist ret = {
2930                 .this_arg = (void*) calls,
2931                 .persist_new_channel = persist_new_channel_jcall,
2932                 .update_persisted_channel = update_persisted_channel_jcall,
2933                 .free = LDKPersist_JCalls_free,
2934         };
2935         return ret;
2936 }
2937 long LDKPersist_1new (void* ctx_TODO, jobject o) {
2938         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
2939         *res_ptr = LDKPersist_init(env, clz, o);
2940         return (long)res_ptr;
2941 }
2942 jobject LDKPersist_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
2943         jobject ret = (*env)->NewLocalRef(env, ((LDKPersist_JCalls*)val)->o);
2944         CHECK(ret != NULL);
2945         return ret;
2946 }
2947 uint32_t Persist_1persist_1new_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t id, uint32_t data) {
2948         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
2949         LDKOutPoint id_conv;
2950         id_conv.inner = (void*)(id & (~1));
2951         id_conv.is_owned = (id & 1) || (id == 0);
2952         if (id_conv.inner != NULL)
2953                 id_conv = OutPoint_clone(&id_conv);
2954         LDKChannelMonitor data_conv;
2955         data_conv.inner = (void*)(data & (~1));
2956         data_conv.is_owned = false;
2957         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2958         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
2959         return (long)ret_conv;
2960 }
2961
2962 uint32_t Persist_1update_1persisted_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
2963         LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
2964         LDKOutPoint id_conv;
2965         id_conv.inner = (void*)(id & (~1));
2966         id_conv.is_owned = (id & 1) || (id == 0);
2967         if (id_conv.inner != NULL)
2968                 id_conv = OutPoint_clone(&id_conv);
2969         LDKChannelMonitorUpdate update_conv;
2970         update_conv.inner = (void*)(update & (~1));
2971         update_conv.is_owned = false;
2972         LDKChannelMonitor data_conv;
2973         data_conv.inner = (void*)(data & (~1));
2974         data_conv.is_owned = false;
2975         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
2976         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
2977         return (long)ret_conv;
2978 }
2979
2980 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
2981         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
2982         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2983         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
2984         return (void*) this_arg;
2985 }
2986 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (void* ctx_TODO, jobject o, jobject MessageSendEventsProvider) {
2987         jclass c = (*env)->GetObjectClass(env, o);
2988         CHECK(c != NULL);
2989         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
2990         atomic_init(&calls->refcnt, 1);
2991         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2992         calls->o = (*env)->NewWeakGlobalRef(env, o);
2993         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
2994         CHECK(calls->handle_open_channel_meth != NULL);
2995         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
2996         CHECK(calls->handle_accept_channel_meth != NULL);
2997         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
2998         CHECK(calls->handle_funding_created_meth != NULL);
2999         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
3000         CHECK(calls->handle_funding_signed_meth != NULL);
3001         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
3002         CHECK(calls->handle_funding_locked_meth != NULL);
3003         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJ)V");
3004         CHECK(calls->handle_shutdown_meth != NULL);
3005         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
3006         CHECK(calls->handle_closing_signed_meth != NULL);
3007         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
3008         CHECK(calls->handle_update_add_htlc_meth != NULL);
3009         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
3010         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
3011         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
3012         CHECK(calls->handle_update_fail_htlc_meth != NULL);
3013         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
3014         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
3015         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
3016         CHECK(calls->handle_commitment_signed_meth != NULL);
3017         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
3018         CHECK(calls->handle_revoke_and_ack_meth != NULL);
3019         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
3020         CHECK(calls->handle_update_fee_meth != NULL);
3021         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
3022         CHECK(calls->handle_announcement_signatures_meth != NULL);
3023         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
3024         CHECK(calls->peer_disconnected_meth != NULL);
3025         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
3026         CHECK(calls->peer_connected_meth != NULL);
3027         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
3028         CHECK(calls->handle_channel_reestablish_meth != NULL);
3029         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
3030         CHECK(calls->handle_error_meth != NULL);
3031
3032         LDKChannelMessageHandler ret = {
3033                 .this_arg = (void*) calls,
3034                 .handle_open_channel = handle_open_channel_jcall,
3035                 .handle_accept_channel = handle_accept_channel_jcall,
3036                 .handle_funding_created = handle_funding_created_jcall,
3037                 .handle_funding_signed = handle_funding_signed_jcall,
3038                 .handle_funding_locked = handle_funding_locked_jcall,
3039                 .handle_shutdown = handle_shutdown_jcall,
3040                 .handle_closing_signed = handle_closing_signed_jcall,
3041                 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3042                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3043                 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3044                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3045                 .handle_commitment_signed = handle_commitment_signed_jcall,
3046                 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3047                 .handle_update_fee = handle_update_fee_jcall,
3048                 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3049                 .peer_disconnected = peer_disconnected_jcall,
3050                 .peer_connected = peer_connected_jcall,
3051                 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3052                 .handle_error = handle_error_jcall,
3053                 .free = LDKChannelMessageHandler_JCalls_free,
3054                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
3055         };
3056         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3057         return ret;
3058 }
3059 long LDKChannelMessageHandler_1new (void* ctx_TODO, jobject o, jobject MessageSendEventsProvider) {
3060         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3061         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
3062         return (long)res_ptr;
3063 }
3064 jobject LDKChannelMessageHandler_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
3065         jobject ret = (*env)->NewLocalRef(env, ((LDKChannelMessageHandler_JCalls*)val)->o);
3066         CHECK(ret != NULL);
3067         return ret;
3068 }
3069 void ChannelMessageHandler_1handle_1open_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
3070         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3071         LDKPublicKey their_node_id_ref;
3072         CHECK(their_node_id.len == 33);
3073         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3074         LDKInitFeatures their_features_conv;
3075         their_features_conv.inner = (void*)(their_features & (~1));
3076         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3077         // Warning: we may need a move here but can't clone!
3078         LDKOpenChannel msg_conv;
3079         msg_conv.inner = (void*)(msg & (~1));
3080         msg_conv.is_owned = false;
3081         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3082 }
3083
3084 void ChannelMessageHandler_1handle_1accept_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
3085         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3086         LDKPublicKey their_node_id_ref;
3087         CHECK(their_node_id.len == 33);
3088         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3089         LDKInitFeatures their_features_conv;
3090         their_features_conv.inner = (void*)(their_features & (~1));
3091         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3092         // Warning: we may need a move here but can't clone!
3093         LDKAcceptChannel msg_conv;
3094         msg_conv.inner = (void*)(msg & (~1));
3095         msg_conv.is_owned = false;
3096         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3097 }
3098
3099 void ChannelMessageHandler_1handle_1funding_1created(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3100         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3101         LDKPublicKey their_node_id_ref;
3102         CHECK(their_node_id.len == 33);
3103         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3104         LDKFundingCreated msg_conv;
3105         msg_conv.inner = (void*)(msg & (~1));
3106         msg_conv.is_owned = false;
3107         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3108 }
3109
3110 void ChannelMessageHandler_1handle_1funding_1signed(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3111         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3112         LDKPublicKey their_node_id_ref;
3113         CHECK(their_node_id.len == 33);
3114         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3115         LDKFundingSigned msg_conv;
3116         msg_conv.inner = (void*)(msg & (~1));
3117         msg_conv.is_owned = false;
3118         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3119 }
3120
3121 void ChannelMessageHandler_1handle_1funding_1locked(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3122         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3123         LDKPublicKey their_node_id_ref;
3124         CHECK(their_node_id.len == 33);
3125         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3126         LDKFundingLocked msg_conv;
3127         msg_conv.inner = (void*)(msg & (~1));
3128         msg_conv.is_owned = false;
3129         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3130 }
3131
3132 void ChannelMessageHandler_1handle_1shutdown(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3133         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3134         LDKPublicKey their_node_id_ref;
3135         CHECK(their_node_id.len == 33);
3136         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3137         LDKShutdown msg_conv;
3138         msg_conv.inner = (void*)(msg & (~1));
3139         msg_conv.is_owned = false;
3140         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3141 }
3142
3143 void ChannelMessageHandler_1handle_1closing_1signed(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3144         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3145         LDKPublicKey their_node_id_ref;
3146         CHECK(their_node_id.len == 33);
3147         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3148         LDKClosingSigned msg_conv;
3149         msg_conv.inner = (void*)(msg & (~1));
3150         msg_conv.is_owned = false;
3151         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3152 }
3153
3154 void ChannelMessageHandler_1handle_1update_1add_1htlc(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3155         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3156         LDKPublicKey their_node_id_ref;
3157         CHECK(their_node_id.len == 33);
3158         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3159         LDKUpdateAddHTLC msg_conv;
3160         msg_conv.inner = (void*)(msg & (~1));
3161         msg_conv.is_owned = false;
3162         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3163 }
3164
3165 void ChannelMessageHandler_1handle_1update_1fulfill_1htlc(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3166         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3167         LDKPublicKey their_node_id_ref;
3168         CHECK(their_node_id.len == 33);
3169         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3170         LDKUpdateFulfillHTLC msg_conv;
3171         msg_conv.inner = (void*)(msg & (~1));
3172         msg_conv.is_owned = false;
3173         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3174 }
3175
3176 void ChannelMessageHandler_1handle_1update_1fail_1htlc(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3177         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3178         LDKPublicKey their_node_id_ref;
3179         CHECK(their_node_id.len == 33);
3180         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3181         LDKUpdateFailHTLC msg_conv;
3182         msg_conv.inner = (void*)(msg & (~1));
3183         msg_conv.is_owned = false;
3184         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3185 }
3186
3187 void ChannelMessageHandler_1handle_1update_1fail_1malformed_1htlc(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3188         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3189         LDKPublicKey their_node_id_ref;
3190         CHECK(their_node_id.len == 33);
3191         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3192         LDKUpdateFailMalformedHTLC msg_conv;
3193         msg_conv.inner = (void*)(msg & (~1));
3194         msg_conv.is_owned = false;
3195         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3196 }
3197
3198 void ChannelMessageHandler_1handle_1commitment_1signed(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3199         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3200         LDKPublicKey their_node_id_ref;
3201         CHECK(their_node_id.len == 33);
3202         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3203         LDKCommitmentSigned msg_conv;
3204         msg_conv.inner = (void*)(msg & (~1));
3205         msg_conv.is_owned = false;
3206         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3207 }
3208
3209 void ChannelMessageHandler_1handle_1revoke_1and_1ack(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3210         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3211         LDKPublicKey their_node_id_ref;
3212         CHECK(their_node_id.len == 33);
3213         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3214         LDKRevokeAndACK msg_conv;
3215         msg_conv.inner = (void*)(msg & (~1));
3216         msg_conv.is_owned = false;
3217         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3218 }
3219
3220 void ChannelMessageHandler_1handle_1update_1fee(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3221         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3222         LDKPublicKey their_node_id_ref;
3223         CHECK(their_node_id.len == 33);
3224         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3225         LDKUpdateFee msg_conv;
3226         msg_conv.inner = (void*)(msg & (~1));
3227         msg_conv.is_owned = false;
3228         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3229 }
3230
3231 void ChannelMessageHandler_1handle_1announcement_1signatures(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3232         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3233         LDKPublicKey their_node_id_ref;
3234         CHECK(their_node_id.len == 33);
3235         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3236         LDKAnnouncementSignatures msg_conv;
3237         msg_conv.inner = (void*)(msg & (~1));
3238         msg_conv.is_owned = false;
3239         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3240 }
3241
3242 void ChannelMessageHandler_1peer_1disconnected(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
3243         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3244         LDKPublicKey their_node_id_ref;
3245         CHECK(their_node_id.len == 33);
3246         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3247         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
3248 }
3249
3250 void ChannelMessageHandler_1peer_1connected(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3251         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3252         LDKPublicKey their_node_id_ref;
3253         CHECK(their_node_id.len == 33);
3254         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3255         LDKInit msg_conv;
3256         msg_conv.inner = (void*)(msg & (~1));
3257         msg_conv.is_owned = false;
3258         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3259 }
3260
3261 void ChannelMessageHandler_1handle_1channel_1reestablish(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3262         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3263         LDKPublicKey their_node_id_ref;
3264         CHECK(their_node_id.len == 33);
3265         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3266         LDKChannelReestablish msg_conv;
3267         msg_conv.inner = (void*)(msg & (~1));
3268         msg_conv.is_owned = false;
3269         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3270 }
3271
3272 void ChannelMessageHandler_1handle_1error(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3273         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3274         LDKPublicKey their_node_id_ref;
3275         CHECK(their_node_id.len == 33);
3276         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3277         LDKErrorMessage msg_conv;
3278         msg_conv.inner = (void*)(msg & (~1));
3279         msg_conv.is_owned = false;
3280         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3281 }
3282
3283 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
3284         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
3285         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3286         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
3287         return (void*) this_arg;
3288 }
3289 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (void* ctx_TODO, jobject o, jobject MessageSendEventsProvider) {
3290         jclass c = (*env)->GetObjectClass(env, o);
3291         CHECK(c != NULL);
3292         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
3293         atomic_init(&calls->refcnt, 1);
3294         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3295         calls->o = (*env)->NewWeakGlobalRef(env, o);
3296         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
3297         CHECK(calls->handle_node_announcement_meth != NULL);
3298         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
3299         CHECK(calls->handle_channel_announcement_meth != NULL);
3300         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
3301         CHECK(calls->handle_channel_update_meth != NULL);
3302         calls->handle_htlc_fail_channel_update_meth = (*env)->GetMethodID(env, c, "handle_htlc_fail_channel_update", "(J)V");
3303         CHECK(calls->handle_htlc_fail_channel_update_meth != NULL);
3304         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
3305         CHECK(calls->get_next_channel_announcements_meth != NULL);
3306         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
3307         CHECK(calls->get_next_node_announcements_meth != NULL);
3308         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
3309         CHECK(calls->sync_routing_table_meth != NULL);
3310         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
3311         CHECK(calls->handle_reply_channel_range_meth != NULL);
3312         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
3313         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
3314         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
3315         CHECK(calls->handle_query_channel_range_meth != NULL);
3316         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
3317         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
3318
3319         LDKRoutingMessageHandler ret = {
3320                 .this_arg = (void*) calls,
3321                 .handle_node_announcement = handle_node_announcement_jcall,
3322                 .handle_channel_announcement = handle_channel_announcement_jcall,
3323                 .handle_channel_update = handle_channel_update_jcall,
3324                 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
3325                 .get_next_channel_announcements = get_next_channel_announcements_jcall,
3326                 .get_next_node_announcements = get_next_node_announcements_jcall,
3327                 .sync_routing_table = sync_routing_table_jcall,
3328                 .handle_reply_channel_range = handle_reply_channel_range_jcall,
3329                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
3330                 .handle_query_channel_range = handle_query_channel_range_jcall,
3331                 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
3332                 .free = LDKRoutingMessageHandler_JCalls_free,
3333                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
3334         };
3335         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3336         return ret;
3337 }
3338 long LDKRoutingMessageHandler_1new (void* ctx_TODO, jobject o, jobject MessageSendEventsProvider) {
3339         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
3340         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
3341         return (long)res_ptr;
3342 }
3343 jobject LDKRoutingMessageHandler_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
3344         jobject ret = (*env)->NewLocalRef(env, ((LDKRoutingMessageHandler_JCalls*)val)->o);
3345         CHECK(ret != NULL);
3346         return ret;
3347 }
3348 uint32_t RoutingMessageHandler_1handle_1node_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
3349         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3350         LDKNodeAnnouncement msg_conv;
3351         msg_conv.inner = (void*)(msg & (~1));
3352         msg_conv.is_owned = false;
3353         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3354         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
3355         return (long)ret_conv;
3356 }
3357
3358 uint32_t RoutingMessageHandler_1handle_1channel_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
3359         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3360         LDKChannelAnnouncement msg_conv;
3361         msg_conv.inner = (void*)(msg & (~1));
3362         msg_conv.is_owned = false;
3363         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3364         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3365         return (long)ret_conv;
3366 }
3367
3368 uint32_t RoutingMessageHandler_1handle_1channel_1update(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
3369         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3370         LDKChannelUpdate msg_conv;
3371         msg_conv.inner = (void*)(msg & (~1));
3372         msg_conv.is_owned = false;
3373         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
3374         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
3375         return (long)ret_conv;
3376 }
3377
3378 void RoutingMessageHandler_1handle_1htlc_1fail_1channel_1update(void* ctx_TODO, uint32_t this_arg, uint32_t update) {
3379         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3380         LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
3381         (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
3382 }
3383
3384 uint32_tArray RoutingMessageHandler_1get_1next_1channel_1announcements(void* ctx_TODO, uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
3385         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3386         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
3387         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
3388         uint32_t *ret_arr_ptr = ret_arr.ptr;
3389         for (size_t l = 0; l < ret_var.datalen; l++) {
3390                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arr_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
3391                 *arr_conv_63_ref = ret_var.data[l];
3392                 arr_conv_63_ref->a = ChannelAnnouncement_clone(&arr_conv_63_ref->a);
3393                 arr_conv_63_ref->b = ChannelUpdate_clone(&arr_conv_63_ref->b);
3394                 arr_conv_63_ref->c = ChannelUpdate_clone(&arr_conv_63_ref->c);
3395                 ret_arr_ptr[l] = (long)arr_conv_63_ref;
3396         }
3397         FREE(ret_var.data);
3398         return ret_arr;
3399 }
3400
3401 uint32_tArray RoutingMessageHandler_1get_1next_1node_1announcements(void* ctx_TODO, uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
3402         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3403         LDKPublicKey starting_point_ref;
3404         CHECK(starting_point.len == 33);
3405         memcpy(starting_point_ref.compressed_form, starting_point.ptr, 33);
3406         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
3407         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
3408         uint32_t *ret_arr_ptr = ret_arr.ptr;
3409         for (size_t s = 0; s < ret_var.datalen; s++) {
3410                 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
3411                 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3412                 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3413                 long arr_conv_18_ref = (long)arr_conv_18_var.inner;
3414                 if (arr_conv_18_var.is_owned) {
3415                         arr_conv_18_ref |= 1;
3416                 }
3417                 ret_arr_ptr[s] = arr_conv_18_ref;
3418         }
3419         FREE(ret_var.data);
3420         return ret_arr;
3421 }
3422
3423 void RoutingMessageHandler_1sync_1routing_1table(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
3424         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3425         LDKPublicKey their_node_id_ref;
3426         CHECK(their_node_id.len == 33);
3427         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3428         LDKInit init_conv;
3429         init_conv.inner = (void*)(init & (~1));
3430         init_conv.is_owned = false;
3431         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
3432 }
3433
3434 uint32_t RoutingMessageHandler_1handle_1reply_1channel_1range(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3435         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3436         LDKPublicKey their_node_id_ref;
3437         CHECK(their_node_id.len == 33);
3438         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3439         LDKReplyChannelRange msg_conv;
3440         msg_conv.inner = (void*)(msg & (~1));
3441         msg_conv.is_owned = (msg & 1) || (msg == 0);
3442         if (msg_conv.inner != NULL)
3443                 msg_conv = ReplyChannelRange_clone(&msg_conv);
3444         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
3445         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
3446         return (long)ret_conv;
3447 }
3448
3449 uint32_t RoutingMessageHandler_1handle_1reply_1short_1channel_1ids_1end(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3450         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3451         LDKPublicKey their_node_id_ref;
3452         CHECK(their_node_id.len == 33);
3453         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3454         LDKReplyShortChannelIdsEnd msg_conv;
3455         msg_conv.inner = (void*)(msg & (~1));
3456         msg_conv.is_owned = (msg & 1) || (msg == 0);
3457         if (msg_conv.inner != NULL)
3458                 msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
3459         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
3460         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
3461         return (long)ret_conv;
3462 }
3463
3464 uint32_t RoutingMessageHandler_1handle_1query_1channel_1range(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3465         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3466         LDKPublicKey their_node_id_ref;
3467         CHECK(their_node_id.len == 33);
3468         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3469         LDKQueryChannelRange msg_conv;
3470         msg_conv.inner = (void*)(msg & (~1));
3471         msg_conv.is_owned = (msg & 1) || (msg == 0);
3472         if (msg_conv.inner != NULL)
3473                 msg_conv = QueryChannelRange_clone(&msg_conv);
3474         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
3475         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
3476         return (long)ret_conv;
3477 }
3478
3479 uint32_t RoutingMessageHandler_1handle_1query_1short_1channel_1ids(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3480         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
3481         LDKPublicKey their_node_id_ref;
3482         CHECK(their_node_id.len == 33);
3483         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
3484         LDKQueryShortChannelIds msg_conv;
3485         msg_conv.inner = (void*)(msg & (~1));
3486         msg_conv.is_owned = (msg & 1) || (msg == 0);
3487         if (msg_conv.inner != NULL)
3488                 msg_conv = QueryShortChannelIds_clone(&msg_conv);
3489         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
3490         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
3491         return (long)ret_conv;
3492 }
3493
3494 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
3495         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
3496         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3497         return (void*) this_arg;
3498 }
3499 static inline LDKSocketDescriptor LDKSocketDescriptor_init (void* ctx_TODO, jobject o) {
3500         jclass c = (*env)->GetObjectClass(env, o);
3501         CHECK(c != NULL);
3502         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
3503         atomic_init(&calls->refcnt, 1);
3504         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3505         calls->o = (*env)->NewWeakGlobalRef(env, o);
3506         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
3507         CHECK(calls->send_data_meth != NULL);
3508         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
3509         CHECK(calls->disconnect_socket_meth != NULL);
3510         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
3511         CHECK(calls->eq_meth != NULL);
3512         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
3513         CHECK(calls->hash_meth != NULL);
3514
3515         LDKSocketDescriptor ret = {
3516                 .this_arg = (void*) calls,
3517                 .send_data = send_data_jcall,
3518                 .disconnect_socket = disconnect_socket_jcall,
3519                 .eq = eq_jcall,
3520                 .hash = hash_jcall,
3521                 .clone = LDKSocketDescriptor_JCalls_clone,
3522                 .free = LDKSocketDescriptor_JCalls_free,
3523         };
3524         return ret;
3525 }
3526 long LDKSocketDescriptor_1new (void* ctx_TODO, jobject o) {
3527         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
3528         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
3529         return (long)res_ptr;
3530 }
3531 jobject LDKSocketDescriptor_1get_1obj_1from_1jcalls (void* ctx_TODO, uint32_t val) {
3532         jobject ret = (*env)->NewLocalRef(env, ((LDKSocketDescriptor_JCalls*)val)->o);
3533         CHECK(ret != NULL);
3534         return ret;
3535 }
3536 int64_t SocketDescriptor_1send_1data(void* ctx_TODO, uint32_t this_arg, int8_tArray data, jboolean resume_read) {
3537         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
3538         LDKu8slice data_ref;
3539         data_ref.datalen = data.len;
3540         data_ref.data = data.ptr;
3541         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
3542         return ret_val;
3543 }
3544
3545 void SocketDescriptor_1disconnect_1socket(void* ctx_TODO, uint32_t this_arg) {
3546         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
3547         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
3548 }
3549
3550 int64_t SocketDescriptor_1hash(void* ctx_TODO, uint32_t this_arg) {
3551         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
3552         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
3553         return ret_val;
3554 }
3555
3556 void Transaction_1free(void* ctx_TODO, int8_tArray _res) {
3557         LDKTransaction _res_ref;
3558         _res_ref.datalen = _res.len;
3559         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
3560         memcpy(_res_ref.data, _res.ptr, _res_ref.datalen);
3561         _res_ref.data_is_owned = true;
3562         Transaction_free(_res_ref);
3563 }
3564
3565 void TxOut_1free(void* ctx_TODO, uint32_t _res) {
3566         LDKTxOut _res_conv = *(LDKTxOut*)_res;
3567         FREE((void*)_res);
3568         TxOut_free(_res_conv);
3569 }
3570
3571 void CVec_1SpendableOutputDescriptorZ_1free(void* ctx_TODO, uint32_tArray _res) {
3572         LDKCVec_SpendableOutputDescriptorZ _res_constr;
3573         _res_constr.datalen = _res.len;
3574         if (_res_constr.datalen > 0)
3575                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
3576         else
3577                 _res_constr.data = NULL;
3578         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3579         for (size_t b = 0; b < _res_constr.datalen; b++) {
3580                 uint32_t arr_conv_27 = _res_vals[b];
3581                 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)arr_conv_27;
3582                 FREE((void*)arr_conv_27);
3583                 _res_constr.data[b] = arr_conv_27_conv;
3584         }
3585         CVec_SpendableOutputDescriptorZ_free(_res_constr);
3586 }
3587
3588 void CVec_1MessageSendEventZ_1free(void* ctx_TODO, uint32_tArray _res) {
3589         LDKCVec_MessageSendEventZ _res_constr;
3590         _res_constr.datalen = _res.len;
3591         if (_res_constr.datalen > 0)
3592                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
3593         else
3594                 _res_constr.data = NULL;
3595         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3596         for (size_t s = 0; s < _res_constr.datalen; s++) {
3597                 uint32_t arr_conv_18 = _res_vals[s];
3598                 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
3599                 FREE((void*)arr_conv_18);
3600                 _res_constr.data[s] = arr_conv_18_conv;
3601         }
3602         CVec_MessageSendEventZ_free(_res_constr);
3603 }
3604
3605 void CVec_1EventZ_1free(void* ctx_TODO, uint32_tArray _res) {
3606         LDKCVec_EventZ _res_constr;
3607         _res_constr.datalen = _res.len;
3608         if (_res_constr.datalen > 0)
3609                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
3610         else
3611                 _res_constr.data = NULL;
3612         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3613         for (size_t h = 0; h < _res_constr.datalen; h++) {
3614                 uint32_t arr_conv_7 = _res_vals[h];
3615                 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
3616                 FREE((void*)arr_conv_7);
3617                 _res_constr.data[h] = arr_conv_7_conv;
3618         }
3619         CVec_EventZ_free(_res_constr);
3620 }
3621
3622 void C2Tuple_1usizeTransactionZ_1free(void* ctx_TODO, uint32_t _res) {
3623         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)_res;
3624         FREE((void*)_res);
3625         C2Tuple_usizeTransactionZ_free(_res_conv);
3626 }
3627
3628 uint32_t C2Tuple_1usizeTransactionZ_1new(void* ctx_TODO, int64_t a, int8_tArray b) {
3629         LDKTransaction b_ref;
3630         b_ref.datalen = b.len;
3631         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
3632         memcpy(b_ref.data, b.ptr, b_ref.datalen);
3633         b_ref.data_is_owned = true;
3634         LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
3635         *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
3636         // XXX: We likely need to clone here, but no _clone fn is available for byte[]
3637         return (long)ret_ref;
3638 }
3639
3640 void CVec_1C2Tuple_1usizeTransactionZZ_1free(void* ctx_TODO, uint32_tArray _res) {
3641         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
3642         _res_constr.datalen = _res.len;
3643         if (_res_constr.datalen > 0)
3644                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
3645         else
3646                 _res_constr.data = NULL;
3647         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3648         for (size_t y = 0; y < _res_constr.datalen; y++) {
3649                 uint32_t arr_conv_24 = _res_vals[y];
3650                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_24;
3651                 FREE((void*)arr_conv_24);
3652                 _res_constr.data[y] = arr_conv_24_conv;
3653         }
3654         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
3655 }
3656
3657 uint32_t CResult_1NoneChannelMonitorUpdateErrZ_1ok(void* ctx_TODO) {
3658         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3659         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
3660         return (long)ret_conv;
3661 }
3662
3663 uint32_t CResult_1NoneChannelMonitorUpdateErrZ_1err(void* ctx_TODO, uint32_t e) {
3664         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
3665         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3666         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
3667         return (long)ret_conv;
3668 }
3669
3670 void CResult_1NoneChannelMonitorUpdateErrZ_1free(void* ctx_TODO, uint32_t _res) {
3671         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)_res;
3672         FREE((void*)_res);
3673         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
3674 }
3675
3676 void CVec_1MonitorEventZ_1free(void* ctx_TODO, uint32_tArray _res) {
3677         LDKCVec_MonitorEventZ _res_constr;
3678         _res_constr.datalen = _res.len;
3679         if (_res_constr.datalen > 0)
3680                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
3681         else
3682                 _res_constr.data = NULL;
3683         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3684         for (size_t o = 0; o < _res_constr.datalen; o++) {
3685                 uint32_t arr_conv_14 = _res_vals[o];
3686                 LDKMonitorEvent arr_conv_14_conv;
3687                 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
3688                 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
3689                 _res_constr.data[o] = arr_conv_14_conv;
3690         }
3691         CVec_MonitorEventZ_free(_res_constr);
3692 }
3693
3694 uint32_t CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3695         LDKChannelMonitorUpdate o_conv;
3696         o_conv.inner = (void*)(o & (~1));
3697         o_conv.is_owned = (o & 1) || (o == 0);
3698         if (o_conv.inner != NULL)
3699                 o_conv = ChannelMonitorUpdate_clone(&o_conv);
3700         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
3701         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
3702         return (long)ret_conv;
3703 }
3704
3705 uint32_t CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3706         LDKDecodeError e_conv;
3707         e_conv.inner = (void*)(e & (~1));
3708         e_conv.is_owned = (e & 1) || (e == 0);
3709         // Warning: we may need a move here but can't clone!
3710         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
3711         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
3712         return (long)ret_conv;
3713 }
3714
3715 void CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3716         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)_res;
3717         FREE((void*)_res);
3718         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
3719 }
3720
3721 uint32_t CResult_1NoneMonitorUpdateErrorZ_1ok(void* ctx_TODO) {
3722         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
3723         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
3724         return (long)ret_conv;
3725 }
3726
3727 uint32_t CResult_1NoneMonitorUpdateErrorZ_1err(void* ctx_TODO, uint32_t e) {
3728         LDKMonitorUpdateError e_conv;
3729         e_conv.inner = (void*)(e & (~1));
3730         e_conv.is_owned = (e & 1) || (e == 0);
3731         // Warning: we may need a move here but can't clone!
3732         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
3733         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
3734         return (long)ret_conv;
3735 }
3736
3737 void CResult_1NoneMonitorUpdateErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3738         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)_res;
3739         FREE((void*)_res);
3740         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
3741 }
3742
3743 void C2Tuple_1OutPointScriptZ_1free(void* ctx_TODO, uint32_t _res) {
3744         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)_res;
3745         FREE((void*)_res);
3746         C2Tuple_OutPointScriptZ_free(_res_conv);
3747 }
3748
3749 uint32_t C2Tuple_1OutPointScriptZ_1new(void* ctx_TODO, uint32_t a, int8_tArray b) {
3750         LDKOutPoint a_conv;
3751         a_conv.inner = (void*)(a & (~1));
3752         a_conv.is_owned = (a & 1) || (a == 0);
3753         if (a_conv.inner != NULL)
3754                 a_conv = OutPoint_clone(&a_conv);
3755         LDKCVec_u8Z b_ref;
3756         b_ref.datalen = b.len;
3757         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
3758         memcpy(b_ref.data, b.ptr, b_ref.datalen);
3759         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
3760         *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
3761         ret_ref->a = OutPoint_clone(&ret_ref->a);
3762         ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
3763         return (long)ret_ref;
3764 }
3765
3766 void CVec_1TransactionZ_1free(void* ctx_TODO, uint32_tArray _res) {
3767         LDKCVec_TransactionZ _res_constr;
3768         _res_constr.datalen = _res.len;
3769         if (_res_constr.datalen > 0)
3770                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
3771         else
3772                 _res_constr.data = NULL;
3773         int8_tArray* _res_vals = (int8_tArray*) _res.ptr;
3774         for (size_t i = 0; i < _res_constr.datalen; i++) {
3775                 int8_tArray arr_conv_8 = _res_vals[i];
3776                 LDKTransaction arr_conv_8_ref;
3777                 arr_conv_8_ref.datalen = arr_conv_8.len;
3778                 arr_conv_8_ref.data = MALLOC(arr_conv_8_ref.datalen, "LDKTransaction Bytes");
3779                 memcpy(arr_conv_8_ref.data, arr_conv_8.ptr, arr_conv_8_ref.datalen);
3780                 arr_conv_8_ref.data_is_owned = true;
3781                 _res_constr.data[i] = arr_conv_8_ref;
3782         }
3783         CVec_TransactionZ_free(_res_constr);
3784 }
3785
3786 void C2Tuple_1u32TxOutZ_1free(void* ctx_TODO, uint32_t _res) {
3787         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)_res;
3788         FREE((void*)_res);
3789         C2Tuple_u32TxOutZ_free(_res_conv);
3790 }
3791
3792 uint32_t C2Tuple_1u32TxOutZ_1new(void* ctx_TODO, int32_t a, uint32_t b) {
3793         LDKTxOut b_conv = *(LDKTxOut*)b;
3794         FREE((void*)b);
3795         LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
3796         *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
3797         // XXX: We likely need to clone here, but no _clone fn is available for TxOut
3798         return (long)ret_ref;
3799 }
3800
3801 void CVec_1C2Tuple_1u32TxOutZZ_1free(void* ctx_TODO, uint32_tArray _res) {
3802         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
3803         _res_constr.datalen = _res.len;
3804         if (_res_constr.datalen > 0)
3805                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3806         else
3807                 _res_constr.data = NULL;
3808         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3809         for (size_t a = 0; a < _res_constr.datalen; a++) {
3810                 uint32_t arr_conv_26 = _res_vals[a];
3811                 LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_26;
3812                 FREE((void*)arr_conv_26);
3813                 _res_constr.data[a] = arr_conv_26_conv;
3814         }
3815         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
3816 }
3817
3818 void C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(void* ctx_TODO, uint32_t _res) {
3819         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)_res;
3820         FREE((void*)_res);
3821         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
3822 }
3823
3824 uint32_t C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(void* ctx_TODO, int8_tArray a, uint32_tArray b) {
3825         LDKThirtyTwoBytes a_ref;
3826         CHECK(a.len == 32);
3827         memcpy(a_ref.data, a.ptr, 32);
3828         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
3829         b_constr.datalen = b.len;
3830         if (b_constr.datalen > 0)
3831                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
3832         else
3833                 b_constr.data = NULL;
3834         uint32_t* b_vals = (uint32_t*) b.ptr;
3835         for (size_t a = 0; a < b_constr.datalen; a++) {
3836                 uint32_t arr_conv_26 = b_vals[a];
3837                 LDKC2Tuple_u32TxOutZ arr_conv_26_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_26;
3838                 FREE((void*)arr_conv_26);
3839                 b_constr.data[a] = arr_conv_26_conv;
3840         }
3841         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
3842         *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
3843         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
3844         // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Integer, TxOut>[]
3845         return (long)ret_ref;
3846 }
3847
3848 void CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(void* ctx_TODO, uint32_tArray _res) {
3849         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
3850         _res_constr.datalen = _res.len;
3851         if (_res_constr.datalen > 0)
3852                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
3853         else
3854                 _res_constr.data = NULL;
3855         uint32_t* _res_vals = (uint32_t*) _res.ptr;
3856         for (size_t u = 0; u < _res_constr.datalen; u++) {
3857                 uint32_t arr_conv_46 = _res_vals[u];
3858                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_conv_46_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)arr_conv_46;
3859                 FREE((void*)arr_conv_46);
3860                 _res_constr.data[u] = arr_conv_46_conv;
3861         }
3862         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
3863 }
3864
3865 void C2Tuple_1BlockHashChannelMonitorZ_1free(void* ctx_TODO, uint32_t _res) {
3866         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)_res;
3867         FREE((void*)_res);
3868         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
3869 }
3870
3871 uint32_t C2Tuple_1BlockHashChannelMonitorZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) {
3872         LDKThirtyTwoBytes a_ref;
3873         CHECK(a.len == 32);
3874         memcpy(a_ref.data, a.ptr, 32);
3875         LDKChannelMonitor b_conv;
3876         b_conv.inner = (void*)(b & (~1));
3877         b_conv.is_owned = (b & 1) || (b == 0);
3878         // Warning: we may need a move here but can't clone!
3879         LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3880         *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
3881         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
3882         // XXX: We likely need to clone here, but no _clone fn is available for ChannelMonitor
3883         return (long)ret_ref;
3884 }
3885
3886 uint32_t CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3887         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)o;
3888         FREE((void*)o);
3889         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
3890         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
3891         return (long)ret_conv;
3892 }
3893
3894 uint32_t CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3895         LDKDecodeError e_conv;
3896         e_conv.inner = (void*)(e & (~1));
3897         e_conv.is_owned = (e & 1) || (e == 0);
3898         // Warning: we may need a move here but can't clone!
3899         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
3900         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
3901         return (long)ret_conv;
3902 }
3903
3904 void CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3905         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)_res;
3906         FREE((void*)_res);
3907         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
3908 }
3909
3910 void C2Tuple_1u64u64Z_1free(void* ctx_TODO, uint32_t _res) {
3911         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)_res;
3912         FREE((void*)_res);
3913         C2Tuple_u64u64Z_free(_res_conv);
3914 }
3915
3916 uint32_t C2Tuple_1u64u64Z_1new(void* ctx_TODO, int64_t a, int64_t b) {
3917         LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
3918         *ret_ref = C2Tuple_u64u64Z_new(a, b);
3919         return (long)ret_ref;
3920 }
3921
3922 uint32_t CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
3923         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)o;
3924         FREE((void*)o);
3925         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
3926         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
3927         return (long)ret_conv;
3928 }
3929
3930 uint32_t CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
3931         LDKDecodeError e_conv;
3932         e_conv.inner = (void*)(e & (~1));
3933         e_conv.is_owned = (e & 1) || (e == 0);
3934         // Warning: we may need a move here but can't clone!
3935         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
3936         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
3937         return (long)ret_conv;
3938 }
3939
3940 void CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
3941         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)_res;
3942         FREE((void*)_res);
3943         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
3944 }
3945
3946 void CVec_1SignatureZ_1free(void* ctx_TODO, uint32_tArray _res) {
3947         LDKCVec_SignatureZ _res_constr;
3948         _res_constr.datalen = _res.len;
3949         if (_res_constr.datalen > 0)
3950                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
3951         else
3952                 _res_constr.data = NULL;
3953         int8_tArray* _res_vals = (int8_tArray*) _res.ptr;
3954         for (size_t i = 0; i < _res_constr.datalen; i++) {
3955                 int8_tArray arr_conv_8 = _res_vals[i];
3956                 LDKSignature arr_conv_8_ref;
3957                 CHECK(arr_conv_8.len == 64);
3958                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
3959                 _res_constr.data[i] = arr_conv_8_ref;
3960         }
3961         CVec_SignatureZ_free(_res_constr);
3962 }
3963
3964 void C2Tuple_1SignatureCVec_1SignatureZZ_1free(void* ctx_TODO, uint32_t _res) {
3965         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)_res;
3966         FREE((void*)_res);
3967         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
3968 }
3969
3970 uint32_t C2Tuple_1SignatureCVec_1SignatureZZ_1new(void* ctx_TODO, int8_tArray a, uint32_tArray b) {
3971         LDKSignature a_ref;
3972         CHECK(a.len == 64);
3973         memcpy(a_ref.compact_form, a.ptr, 64);
3974         LDKCVec_SignatureZ b_constr;
3975         b_constr.datalen = b.len;
3976         if (b_constr.datalen > 0)
3977                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
3978         else
3979                 b_constr.data = NULL;
3980         int8_tArray* b_vals = (int8_tArray*) b.ptr;
3981         for (size_t i = 0; i < b_constr.datalen; i++) {
3982                 int8_tArray arr_conv_8 = b_vals[i];
3983                 LDKSignature arr_conv_8_ref;
3984                 CHECK(arr_conv_8.len == 64);
3985                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
3986                 b_constr.data[i] = arr_conv_8_ref;
3987         }
3988         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
3989         *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
3990         // XXX: We likely need to clone here, but no _clone fn is available for byte[]
3991         // XXX: We likely need to clone here, but no _clone fn is available for byte[][]
3992         return (long)ret_ref;
3993 }
3994
3995 uint32_t CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(void* ctx_TODO, uint32_t o) {
3996         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)o;
3997         FREE((void*)o);
3998         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3999         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
4000         return (long)ret_conv;
4001 }
4002
4003 uint32_t CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(void* ctx_TODO) {
4004         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4005         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
4006         return (long)ret_conv;
4007 }
4008
4009 void CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(void* ctx_TODO, uint32_t _res) {
4010         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)_res;
4011         FREE((void*)_res);
4012         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
4013 }
4014
4015 uint32_t CResult_1SignatureNoneZ_1ok(void* ctx_TODO, int8_tArray o) {
4016         LDKSignature o_ref;
4017         CHECK(o.len == 64);
4018         memcpy(o_ref.compact_form, o.ptr, 64);
4019         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4020         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
4021         return (long)ret_conv;
4022 }
4023
4024 uint32_t CResult_1SignatureNoneZ_1err(void* ctx_TODO) {
4025         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4026         *ret_conv = CResult_SignatureNoneZ_err();
4027         return (long)ret_conv;
4028 }
4029
4030 void CResult_1SignatureNoneZ_1free(void* ctx_TODO, uint32_t _res) {
4031         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)_res;
4032         FREE((void*)_res);
4033         CResult_SignatureNoneZ_free(_res_conv);
4034 }
4035
4036 uint32_t CResult_1CVec_1SignatureZNoneZ_1ok(void* ctx_TODO, uint32_tArray o) {
4037         LDKCVec_SignatureZ o_constr;
4038         o_constr.datalen = o.len;
4039         if (o_constr.datalen > 0)
4040                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4041         else
4042                 o_constr.data = NULL;
4043         int8_tArray* o_vals = (int8_tArray*) o.ptr;
4044         for (size_t i = 0; i < o_constr.datalen; i++) {
4045                 int8_tArray arr_conv_8 = o_vals[i];
4046                 LDKSignature arr_conv_8_ref;
4047                 CHECK(arr_conv_8.len == 64);
4048                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
4049                 o_constr.data[i] = arr_conv_8_ref;
4050         }
4051         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4052         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
4053         return (long)ret_conv;
4054 }
4055
4056 uint32_t CResult_1CVec_1SignatureZNoneZ_1err(void* ctx_TODO) {
4057         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4058         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
4059         return (long)ret_conv;
4060 }
4061
4062 void CResult_1CVec_1SignatureZNoneZ_1free(void* ctx_TODO, uint32_t _res) {
4063         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)_res;
4064         FREE((void*)_res);
4065         CResult_CVec_SignatureZNoneZ_free(_res_conv);
4066 }
4067
4068 uint32_t CResult_1ChanKeySignerDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4069         LDKChannelKeys o_conv = *(LDKChannelKeys*)o;
4070         if (o_conv.free == LDKChannelKeys_JCalls_free) {
4071                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4072                 LDKChannelKeys_JCalls_clone(o_conv.this_arg);
4073         }
4074         LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
4075         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_ok(o_conv);
4076         return (long)ret_conv;
4077 }
4078
4079 uint32_t CResult_1ChanKeySignerDecodeErrorZ_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_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
4085         *ret_conv = CResult_ChanKeySignerDecodeErrorZ_err(e_conv);
4086         return (long)ret_conv;
4087 }
4088
4089 void CResult_1ChanKeySignerDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4090         LDKCResult_ChanKeySignerDecodeErrorZ _res_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)_res;
4091         FREE((void*)_res);
4092         CResult_ChanKeySignerDecodeErrorZ_free(_res_conv);
4093 }
4094
4095 uint32_t CResult_1InMemoryChannelKeysDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4096         LDKInMemoryChannelKeys 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 = InMemoryChannelKeys_clone(&o_conv);
4101         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
4102         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_ok(o_conv);
4103         return (long)ret_conv;
4104 }
4105
4106 uint32_t CResult_1InMemoryChannelKeysDecodeErrorZ_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_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
4112         *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_err(e_conv);
4113         return (long)ret_conv;
4114 }
4115
4116 void CResult_1InMemoryChannelKeysDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4117         LDKCResult_InMemoryChannelKeysDecodeErrorZ _res_conv = *(LDKCResult_InMemoryChannelKeysDecodeErrorZ*)_res;
4118         FREE((void*)_res);
4119         CResult_InMemoryChannelKeysDecodeErrorZ_free(_res_conv);
4120 }
4121
4122 uint32_t CResult_1TxOutAccessErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4123         LDKTxOut o_conv = *(LDKTxOut*)o;
4124         FREE((void*)o);
4125         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4126         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
4127         return (long)ret_conv;
4128 }
4129
4130 uint32_t CResult_1TxOutAccessErrorZ_1err(void* ctx_TODO, uint32_t e) {
4131         LDKAccessError e_conv = LDKAccessError_from_js(e);
4132         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4133         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
4134         return (long)ret_conv;
4135 }
4136
4137 void CResult_1TxOutAccessErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4138         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)_res;
4139         FREE((void*)_res);
4140         CResult_TxOutAccessErrorZ_free(_res_conv);
4141 }
4142
4143 uint32_t CResult_1NoneAPIErrorZ_1ok(void* ctx_TODO) {
4144         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4145         *ret_conv = CResult_NoneAPIErrorZ_ok();
4146         return (long)ret_conv;
4147 }
4148
4149 uint32_t CResult_1NoneAPIErrorZ_1err(void* ctx_TODO, uint32_t e) {
4150         LDKAPIError e_conv = *(LDKAPIError*)e;
4151         FREE((void*)e);
4152         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
4153         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
4154         return (long)ret_conv;
4155 }
4156
4157 void CResult_1NoneAPIErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4158         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)_res;
4159         FREE((void*)_res);
4160         CResult_NoneAPIErrorZ_free(_res_conv);
4161 }
4162
4163 void CVec_1ChannelDetailsZ_1free(void* ctx_TODO, uint32_tArray _res) {
4164         LDKCVec_ChannelDetailsZ _res_constr;
4165         _res_constr.datalen = _res.len;
4166         if (_res_constr.datalen > 0)
4167                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
4168         else
4169                 _res_constr.data = NULL;
4170         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4171         for (size_t q = 0; q < _res_constr.datalen; q++) {
4172                 uint32_t arr_conv_16 = _res_vals[q];
4173                 LDKChannelDetails arr_conv_16_conv;
4174                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4175                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4176                 _res_constr.data[q] = arr_conv_16_conv;
4177         }
4178         CVec_ChannelDetailsZ_free(_res_constr);
4179 }
4180
4181 uint32_t CResult_1NonePaymentSendFailureZ_1ok(void* ctx_TODO) {
4182         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4183         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
4184         return (long)ret_conv;
4185 }
4186
4187 uint32_t CResult_1NonePaymentSendFailureZ_1err(void* ctx_TODO, uint32_t e) {
4188         LDKPaymentSendFailure 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_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
4193         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
4194         return (long)ret_conv;
4195 }
4196
4197 void CResult_1NonePaymentSendFailureZ_1free(void* ctx_TODO, uint32_t _res) {
4198         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)_res;
4199         FREE((void*)_res);
4200         CResult_NonePaymentSendFailureZ_free(_res_conv);
4201 }
4202
4203 void CVec_1NetAddressZ_1free(void* ctx_TODO, uint32_tArray _res) {
4204         LDKCVec_NetAddressZ _res_constr;
4205         _res_constr.datalen = _res.len;
4206         if (_res_constr.datalen > 0)
4207                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
4208         else
4209                 _res_constr.data = NULL;
4210         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4211         for (size_t m = 0; m < _res_constr.datalen; m++) {
4212                 uint32_t arr_conv_12 = _res_vals[m];
4213                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
4214                 FREE((void*)arr_conv_12);
4215                 _res_constr.data[m] = arr_conv_12_conv;
4216         }
4217         CVec_NetAddressZ_free(_res_constr);
4218 }
4219
4220 void CVec_1ChannelMonitorZ_1free(void* ctx_TODO, uint32_tArray _res) {
4221         LDKCVec_ChannelMonitorZ _res_constr;
4222         _res_constr.datalen = _res.len;
4223         if (_res_constr.datalen > 0)
4224                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
4225         else
4226                 _res_constr.data = NULL;
4227         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4228         for (size_t q = 0; q < _res_constr.datalen; q++) {
4229                 uint32_t arr_conv_16 = _res_vals[q];
4230                 LDKChannelMonitor arr_conv_16_conv;
4231                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4232                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4233                 _res_constr.data[q] = arr_conv_16_conv;
4234         }
4235         CVec_ChannelMonitorZ_free(_res_constr);
4236 }
4237
4238 void C2Tuple_1BlockHashChannelManagerZ_1free(void* ctx_TODO, uint32_t _res) {
4239         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)_res;
4240         FREE((void*)_res);
4241         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
4242 }
4243
4244 uint32_t C2Tuple_1BlockHashChannelManagerZ_1new(void* ctx_TODO, int8_tArray a, uint32_t b) {
4245         LDKThirtyTwoBytes a_ref;
4246         CHECK(a.len == 32);
4247         memcpy(a_ref.data, a.ptr, 32);
4248         LDKChannelManager b_conv;
4249         b_conv.inner = (void*)(b & (~1));
4250         b_conv.is_owned = (b & 1) || (b == 0);
4251         // Warning: we may need a move here but can't clone!
4252         LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
4253         *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
4254         ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
4255         // XXX: We likely need to clone here, but no _clone fn is available for ChannelManager
4256         return (long)ret_ref;
4257 }
4258
4259 uint32_t CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4260         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)o;
4261         FREE((void*)o);
4262         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
4263         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
4264         return (long)ret_conv;
4265 }
4266
4267 uint32_t CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4268         LDKDecodeError e_conv;
4269         e_conv.inner = (void*)(e & (~1));
4270         e_conv.is_owned = (e & 1) || (e == 0);
4271         // Warning: we may need a move here but can't clone!
4272         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
4273         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
4274         return (long)ret_conv;
4275 }
4276
4277 void CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4278         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)_res;
4279         FREE((void*)_res);
4280         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
4281 }
4282
4283 uint32_t CResult_1NetAddressu8Z_1ok(void* ctx_TODO, uint32_t o) {
4284         LDKNetAddress o_conv = *(LDKNetAddress*)o;
4285         FREE((void*)o);
4286         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
4287         *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
4288         return (long)ret_conv;
4289 }
4290
4291 uint32_t CResult_1NetAddressu8Z_1err(void* ctx_TODO, int8_t e) {
4292         LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
4293         *ret_conv = CResult_NetAddressu8Z_err(e);
4294         return (long)ret_conv;
4295 }
4296
4297 void CResult_1NetAddressu8Z_1free(void* ctx_TODO, uint32_t _res) {
4298         LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)_res;
4299         FREE((void*)_res);
4300         CResult_NetAddressu8Z_free(_res_conv);
4301 }
4302
4303 uint32_t CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4304         LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)o;
4305         FREE((void*)o);
4306         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
4307         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
4308         return (long)ret_conv;
4309 }
4310
4311 uint32_t CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4312         LDKDecodeError e_conv;
4313         e_conv.inner = (void*)(e & (~1));
4314         e_conv.is_owned = (e & 1) || (e == 0);
4315         // Warning: we may need a move here but can't clone!
4316         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
4317         *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
4318         return (long)ret_conv;
4319 }
4320
4321 void CResult_1CResult_1NetAddressu8ZDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4322         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)_res;
4323         FREE((void*)_res);
4324         CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
4325 }
4326
4327 void CVec_1u64Z_1free(void* ctx_TODO, int64_tArray _res) {
4328         LDKCVec_u64Z _res_constr;
4329         _res_constr.datalen = _res.len;
4330         if (_res_constr.datalen > 0)
4331                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
4332         else
4333                 _res_constr.data = NULL;
4334         int64_t* _res_vals = (int64_t*) _res.ptr;
4335         for (size_t g = 0; g < _res_constr.datalen; g++) {
4336                 int64_t arr_conv_6 = _res_vals[g];
4337                 _res_constr.data[g] = arr_conv_6;
4338         }
4339         CVec_u64Z_free(_res_constr);
4340 }
4341
4342 void CVec_1UpdateAddHTLCZ_1free(void* ctx_TODO, uint32_tArray _res) {
4343         LDKCVec_UpdateAddHTLCZ _res_constr;
4344         _res_constr.datalen = _res.len;
4345         if (_res_constr.datalen > 0)
4346                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
4347         else
4348                 _res_constr.data = NULL;
4349         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4350         for (size_t p = 0; p < _res_constr.datalen; p++) {
4351                 uint32_t arr_conv_15 = _res_vals[p];
4352                 LDKUpdateAddHTLC arr_conv_15_conv;
4353                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
4354                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
4355                 _res_constr.data[p] = arr_conv_15_conv;
4356         }
4357         CVec_UpdateAddHTLCZ_free(_res_constr);
4358 }
4359
4360 void CVec_1UpdateFulfillHTLCZ_1free(void* ctx_TODO, uint32_tArray _res) {
4361         LDKCVec_UpdateFulfillHTLCZ _res_constr;
4362         _res_constr.datalen = _res.len;
4363         if (_res_constr.datalen > 0)
4364                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
4365         else
4366                 _res_constr.data = NULL;
4367         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4368         for (size_t t = 0; t < _res_constr.datalen; t++) {
4369                 uint32_t arr_conv_19 = _res_vals[t];
4370                 LDKUpdateFulfillHTLC arr_conv_19_conv;
4371                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
4372                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
4373                 _res_constr.data[t] = arr_conv_19_conv;
4374         }
4375         CVec_UpdateFulfillHTLCZ_free(_res_constr);
4376 }
4377
4378 void CVec_1UpdateFailHTLCZ_1free(void* ctx_TODO, uint32_tArray _res) {
4379         LDKCVec_UpdateFailHTLCZ _res_constr;
4380         _res_constr.datalen = _res.len;
4381         if (_res_constr.datalen > 0)
4382                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
4383         else
4384                 _res_constr.data = NULL;
4385         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4386         for (size_t q = 0; q < _res_constr.datalen; q++) {
4387                 uint32_t arr_conv_16 = _res_vals[q];
4388                 LDKUpdateFailHTLC arr_conv_16_conv;
4389                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
4390                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
4391                 _res_constr.data[q] = arr_conv_16_conv;
4392         }
4393         CVec_UpdateFailHTLCZ_free(_res_constr);
4394 }
4395
4396 void CVec_1UpdateFailMalformedHTLCZ_1free(void* ctx_TODO, uint32_tArray _res) {
4397         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
4398         _res_constr.datalen = _res.len;
4399         if (_res_constr.datalen > 0)
4400                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
4401         else
4402                 _res_constr.data = NULL;
4403         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4404         for (size_t z = 0; z < _res_constr.datalen; z++) {
4405                 uint32_t arr_conv_25 = _res_vals[z];
4406                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
4407                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
4408                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
4409                 _res_constr.data[z] = arr_conv_25_conv;
4410         }
4411         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
4412 }
4413
4414 uint32_t CResult_1boolLightningErrorZ_1ok(void* ctx_TODO, jboolean o) {
4415         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4416         *ret_conv = CResult_boolLightningErrorZ_ok(o);
4417         return (long)ret_conv;
4418 }
4419
4420 uint32_t CResult_1boolLightningErrorZ_1err(void* ctx_TODO, uint32_t e) {
4421         LDKLightningError e_conv;
4422         e_conv.inner = (void*)(e & (~1));
4423         e_conv.is_owned = (e & 1) || (e == 0);
4424         // Warning: we may need a move here but can't clone!
4425         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4426         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
4427         return (long)ret_conv;
4428 }
4429
4430 void CResult_1boolLightningErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4431         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)_res;
4432         FREE((void*)_res);
4433         CResult_boolLightningErrorZ_free(_res_conv);
4434 }
4435
4436 void C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(void* ctx_TODO, uint32_t _res) {
4437         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)_res;
4438         FREE((void*)_res);
4439         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
4440 }
4441
4442 uint32_t C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1new(void* ctx_TODO, uint32_t a, uint32_t b, uint32_t c) {
4443         LDKChannelAnnouncement a_conv;
4444         a_conv.inner = (void*)(a & (~1));
4445         a_conv.is_owned = (a & 1) || (a == 0);
4446         if (a_conv.inner != NULL)
4447                 a_conv = ChannelAnnouncement_clone(&a_conv);
4448         LDKChannelUpdate b_conv;
4449         b_conv.inner = (void*)(b & (~1));
4450         b_conv.is_owned = (b & 1) || (b == 0);
4451         if (b_conv.inner != NULL)
4452                 b_conv = ChannelUpdate_clone(&b_conv);
4453         LDKChannelUpdate c_conv;
4454         c_conv.inner = (void*)(c & (~1));
4455         c_conv.is_owned = (c & 1) || (c == 0);
4456         if (c_conv.inner != NULL)
4457                 c_conv = ChannelUpdate_clone(&c_conv);
4458         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4459         *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
4460         ret_ref->a = ChannelAnnouncement_clone(&ret_ref->a);
4461         ret_ref->b = ChannelUpdate_clone(&ret_ref->b);
4462         ret_ref->c = ChannelUpdate_clone(&ret_ref->c);
4463         return (long)ret_ref;
4464 }
4465
4466 void CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(void* ctx_TODO, uint32_tArray _res) {
4467         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
4468         _res_constr.datalen = _res.len;
4469         if (_res_constr.datalen > 0)
4470                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
4471         else
4472                 _res_constr.data = NULL;
4473         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4474         for (size_t l = 0; l < _res_constr.datalen; l++) {
4475                 uint32_t arr_conv_63 = _res_vals[l];
4476                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
4477                 FREE((void*)arr_conv_63);
4478                 _res_constr.data[l] = arr_conv_63_conv;
4479         }
4480         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
4481 }
4482
4483 void CVec_1NodeAnnouncementZ_1free(void* ctx_TODO, uint32_tArray _res) {
4484         LDKCVec_NodeAnnouncementZ _res_constr;
4485         _res_constr.datalen = _res.len;
4486         if (_res_constr.datalen > 0)
4487                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
4488         else
4489                 _res_constr.data = NULL;
4490         uint32_t* _res_vals = (uint32_t*) _res.ptr;
4491         for (size_t s = 0; s < _res_constr.datalen; s++) {
4492                 uint32_t arr_conv_18 = _res_vals[s];
4493                 LDKNodeAnnouncement arr_conv_18_conv;
4494                 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
4495                 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
4496                 _res_constr.data[s] = arr_conv_18_conv;
4497         }
4498         CVec_NodeAnnouncementZ_free(_res_constr);
4499 }
4500
4501 uint32_t CResult_1NoneLightningErrorZ_1ok(void* ctx_TODO) {
4502         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4503         *ret_conv = CResult_NoneLightningErrorZ_ok();
4504         return (long)ret_conv;
4505 }
4506
4507 uint32_t CResult_1NoneLightningErrorZ_1err(void* ctx_TODO, uint32_t e) {
4508         LDKLightningError e_conv;
4509         e_conv.inner = (void*)(e & (~1));
4510         e_conv.is_owned = (e & 1) || (e == 0);
4511         // Warning: we may need a move here but can't clone!
4512         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4513         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
4514         return (long)ret_conv;
4515 }
4516
4517 void CResult_1NoneLightningErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4518         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)_res;
4519         FREE((void*)_res);
4520         CResult_NoneLightningErrorZ_free(_res_conv);
4521 }
4522
4523 uint32_t CResult_1ChannelReestablishDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4524         LDKChannelReestablish o_conv;
4525         o_conv.inner = (void*)(o & (~1));
4526         o_conv.is_owned = (o & 1) || (o == 0);
4527         if (o_conv.inner != NULL)
4528                 o_conv = ChannelReestablish_clone(&o_conv);
4529         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
4530         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
4531         return (long)ret_conv;
4532 }
4533
4534 uint32_t CResult_1ChannelReestablishDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4535         LDKDecodeError e_conv;
4536         e_conv.inner = (void*)(e & (~1));
4537         e_conv.is_owned = (e & 1) || (e == 0);
4538         // Warning: we may need a move here but can't clone!
4539         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
4540         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
4541         return (long)ret_conv;
4542 }
4543
4544 void CResult_1ChannelReestablishDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4545         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)_res;
4546         FREE((void*)_res);
4547         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
4548 }
4549
4550 uint32_t CResult_1InitDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4551         LDKInit o_conv;
4552         o_conv.inner = (void*)(o & (~1));
4553         o_conv.is_owned = (o & 1) || (o == 0);
4554         if (o_conv.inner != NULL)
4555                 o_conv = Init_clone(&o_conv);
4556         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
4557         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
4558         return (long)ret_conv;
4559 }
4560
4561 uint32_t CResult_1InitDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4562         LDKDecodeError e_conv;
4563         e_conv.inner = (void*)(e & (~1));
4564         e_conv.is_owned = (e & 1) || (e == 0);
4565         // Warning: we may need a move here but can't clone!
4566         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
4567         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
4568         return (long)ret_conv;
4569 }
4570
4571 void CResult_1InitDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4572         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)_res;
4573         FREE((void*)_res);
4574         CResult_InitDecodeErrorZ_free(_res_conv);
4575 }
4576
4577 uint32_t CResult_1PingDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4578         LDKPing o_conv;
4579         o_conv.inner = (void*)(o & (~1));
4580         o_conv.is_owned = (o & 1) || (o == 0);
4581         if (o_conv.inner != NULL)
4582                 o_conv = Ping_clone(&o_conv);
4583         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
4584         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
4585         return (long)ret_conv;
4586 }
4587
4588 uint32_t CResult_1PingDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4589         LDKDecodeError e_conv;
4590         e_conv.inner = (void*)(e & (~1));
4591         e_conv.is_owned = (e & 1) || (e == 0);
4592         // Warning: we may need a move here but can't clone!
4593         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
4594         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
4595         return (long)ret_conv;
4596 }
4597
4598 void CResult_1PingDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4599         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)_res;
4600         FREE((void*)_res);
4601         CResult_PingDecodeErrorZ_free(_res_conv);
4602 }
4603
4604 uint32_t CResult_1PongDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4605         LDKPong o_conv;
4606         o_conv.inner = (void*)(o & (~1));
4607         o_conv.is_owned = (o & 1) || (o == 0);
4608         if (o_conv.inner != NULL)
4609                 o_conv = Pong_clone(&o_conv);
4610         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
4611         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
4612         return (long)ret_conv;
4613 }
4614
4615 uint32_t CResult_1PongDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4616         LDKDecodeError e_conv;
4617         e_conv.inner = (void*)(e & (~1));
4618         e_conv.is_owned = (e & 1) || (e == 0);
4619         // Warning: we may need a move here but can't clone!
4620         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
4621         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
4622         return (long)ret_conv;
4623 }
4624
4625 void CResult_1PongDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4626         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)_res;
4627         FREE((void*)_res);
4628         CResult_PongDecodeErrorZ_free(_res_conv);
4629 }
4630
4631 uint32_t CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4632         LDKUnsignedChannelAnnouncement o_conv;
4633         o_conv.inner = (void*)(o & (~1));
4634         o_conv.is_owned = (o & 1) || (o == 0);
4635         if (o_conv.inner != NULL)
4636                 o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
4637         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
4638         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
4639         return (long)ret_conv;
4640 }
4641
4642 uint32_t CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4643         LDKDecodeError e_conv;
4644         e_conv.inner = (void*)(e & (~1));
4645         e_conv.is_owned = (e & 1) || (e == 0);
4646         // Warning: we may need a move here but can't clone!
4647         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
4648         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
4649         return (long)ret_conv;
4650 }
4651
4652 void CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4653         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)_res;
4654         FREE((void*)_res);
4655         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
4656 }
4657
4658 uint32_t CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4659         LDKUnsignedChannelUpdate o_conv;
4660         o_conv.inner = (void*)(o & (~1));
4661         o_conv.is_owned = (o & 1) || (o == 0);
4662         if (o_conv.inner != NULL)
4663                 o_conv = UnsignedChannelUpdate_clone(&o_conv);
4664         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
4665         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
4666         return (long)ret_conv;
4667 }
4668
4669 uint32_t CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4670         LDKDecodeError e_conv;
4671         e_conv.inner = (void*)(e & (~1));
4672         e_conv.is_owned = (e & 1) || (e == 0);
4673         // Warning: we may need a move here but can't clone!
4674         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
4675         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
4676         return (long)ret_conv;
4677 }
4678
4679 void CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4680         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)_res;
4681         FREE((void*)_res);
4682         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
4683 }
4684
4685 uint32_t CResult_1ErrorMessageDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4686         LDKErrorMessage o_conv;
4687         o_conv.inner = (void*)(o & (~1));
4688         o_conv.is_owned = (o & 1) || (o == 0);
4689         if (o_conv.inner != NULL)
4690                 o_conv = ErrorMessage_clone(&o_conv);
4691         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
4692         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
4693         return (long)ret_conv;
4694 }
4695
4696 uint32_t CResult_1ErrorMessageDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4697         LDKDecodeError e_conv;
4698         e_conv.inner = (void*)(e & (~1));
4699         e_conv.is_owned = (e & 1) || (e == 0);
4700         // Warning: we may need a move here but can't clone!
4701         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
4702         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
4703         return (long)ret_conv;
4704 }
4705
4706 void CResult_1ErrorMessageDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4707         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)_res;
4708         FREE((void*)_res);
4709         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
4710 }
4711
4712 uint32_t CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4713         LDKUnsignedNodeAnnouncement o_conv;
4714         o_conv.inner = (void*)(o & (~1));
4715         o_conv.is_owned = (o & 1) || (o == 0);
4716         if (o_conv.inner != NULL)
4717                 o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
4718         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
4719         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
4720         return (long)ret_conv;
4721 }
4722
4723 uint32_t CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4724         LDKDecodeError e_conv;
4725         e_conv.inner = (void*)(e & (~1));
4726         e_conv.is_owned = (e & 1) || (e == 0);
4727         // Warning: we may need a move here but can't clone!
4728         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
4729         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
4730         return (long)ret_conv;
4731 }
4732
4733 void CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4734         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)_res;
4735         FREE((void*)_res);
4736         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
4737 }
4738
4739 uint32_t CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4740         LDKQueryShortChannelIds o_conv;
4741         o_conv.inner = (void*)(o & (~1));
4742         o_conv.is_owned = (o & 1) || (o == 0);
4743         if (o_conv.inner != NULL)
4744                 o_conv = QueryShortChannelIds_clone(&o_conv);
4745         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
4746         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
4747         return (long)ret_conv;
4748 }
4749
4750 uint32_t CResult_1QueryShortChannelIdsDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4751         LDKDecodeError e_conv;
4752         e_conv.inner = (void*)(e & (~1));
4753         e_conv.is_owned = (e & 1) || (e == 0);
4754         // Warning: we may need a move here but can't clone!
4755         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
4756         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
4757         return (long)ret_conv;
4758 }
4759
4760 void CResult_1QueryShortChannelIdsDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4761         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)_res;
4762         FREE((void*)_res);
4763         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
4764 }
4765
4766 uint32_t CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4767         LDKReplyShortChannelIdsEnd o_conv;
4768         o_conv.inner = (void*)(o & (~1));
4769         o_conv.is_owned = (o & 1) || (o == 0);
4770         if (o_conv.inner != NULL)
4771                 o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
4772         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
4773         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
4774         return (long)ret_conv;
4775 }
4776
4777 uint32_t CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4778         LDKDecodeError e_conv;
4779         e_conv.inner = (void*)(e & (~1));
4780         e_conv.is_owned = (e & 1) || (e == 0);
4781         // Warning: we may need a move here but can't clone!
4782         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
4783         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
4784         return (long)ret_conv;
4785 }
4786
4787 void CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4788         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)_res;
4789         FREE((void*)_res);
4790         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
4791 }
4792
4793 uint32_t CResult_1QueryChannelRangeDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4794         LDKQueryChannelRange o_conv;
4795         o_conv.inner = (void*)(o & (~1));
4796         o_conv.is_owned = (o & 1) || (o == 0);
4797         if (o_conv.inner != NULL)
4798                 o_conv = QueryChannelRange_clone(&o_conv);
4799         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
4800         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
4801         return (long)ret_conv;
4802 }
4803
4804 uint32_t CResult_1QueryChannelRangeDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4805         LDKDecodeError e_conv;
4806         e_conv.inner = (void*)(e & (~1));
4807         e_conv.is_owned = (e & 1) || (e == 0);
4808         // Warning: we may need a move here but can't clone!
4809         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
4810         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
4811         return (long)ret_conv;
4812 }
4813
4814 void CResult_1QueryChannelRangeDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4815         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)_res;
4816         FREE((void*)_res);
4817         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
4818 }
4819
4820 uint32_t CResult_1ReplyChannelRangeDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4821         LDKReplyChannelRange o_conv;
4822         o_conv.inner = (void*)(o & (~1));
4823         o_conv.is_owned = (o & 1) || (o == 0);
4824         if (o_conv.inner != NULL)
4825                 o_conv = ReplyChannelRange_clone(&o_conv);
4826         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
4827         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
4828         return (long)ret_conv;
4829 }
4830
4831 uint32_t CResult_1ReplyChannelRangeDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4832         LDKDecodeError e_conv;
4833         e_conv.inner = (void*)(e & (~1));
4834         e_conv.is_owned = (e & 1) || (e == 0);
4835         // Warning: we may need a move here but can't clone!
4836         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
4837         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
4838         return (long)ret_conv;
4839 }
4840
4841 void CResult_1ReplyChannelRangeDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4842         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)_res;
4843         FREE((void*)_res);
4844         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
4845 }
4846
4847 uint32_t CResult_1GossipTimestampFilterDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
4848         LDKGossipTimestampFilter o_conv;
4849         o_conv.inner = (void*)(o & (~1));
4850         o_conv.is_owned = (o & 1) || (o == 0);
4851         if (o_conv.inner != NULL)
4852                 o_conv = GossipTimestampFilter_clone(&o_conv);
4853         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
4854         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
4855         return (long)ret_conv;
4856 }
4857
4858 uint32_t CResult_1GossipTimestampFilterDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
4859         LDKDecodeError e_conv;
4860         e_conv.inner = (void*)(e & (~1));
4861         e_conv.is_owned = (e & 1) || (e == 0);
4862         // Warning: we may need a move here but can't clone!
4863         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
4864         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
4865         return (long)ret_conv;
4866 }
4867
4868 void CResult_1GossipTimestampFilterDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4869         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)_res;
4870         FREE((void*)_res);
4871         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
4872 }
4873
4874 void CVec_1PublicKeyZ_1free(void* ctx_TODO, uint32_tArray _res) {
4875         LDKCVec_PublicKeyZ _res_constr;
4876         _res_constr.datalen = _res.len;
4877         if (_res_constr.datalen > 0)
4878                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
4879         else
4880                 _res_constr.data = NULL;
4881         int8_tArray* _res_vals = (int8_tArray*) _res.ptr;
4882         for (size_t i = 0; i < _res_constr.datalen; i++) {
4883                 int8_tArray arr_conv_8 = _res_vals[i];
4884                 LDKPublicKey arr_conv_8_ref;
4885                 CHECK(arr_conv_8.len == 33);
4886                 memcpy(arr_conv_8_ref.compressed_form, arr_conv_8.ptr, 33);
4887                 _res_constr.data[i] = arr_conv_8_ref;
4888         }
4889         CVec_PublicKeyZ_free(_res_constr);
4890 }
4891
4892 void CVec_1u8Z_1free(void* ctx_TODO, int8_tArray _res) {
4893         LDKCVec_u8Z _res_ref;
4894         _res_ref.datalen = _res.len;
4895         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
4896         memcpy(_res_ref.data, _res.ptr, _res_ref.datalen);
4897         CVec_u8Z_free(_res_ref);
4898 }
4899
4900 uint32_t CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(void* ctx_TODO, int8_tArray o) {
4901         LDKCVec_u8Z o_ref;
4902         o_ref.datalen = o.len;
4903         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
4904         memcpy(o_ref.data, o.ptr, o_ref.datalen);
4905         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4906         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
4907         return (long)ret_conv;
4908 }
4909
4910 uint32_t CResult_1CVec_1u8ZPeerHandleErrorZ_1err(void* ctx_TODO, uint32_t e) {
4911         LDKPeerHandleError e_conv;
4912         e_conv.inner = (void*)(e & (~1));
4913         e_conv.is_owned = (e & 1) || (e == 0);
4914         // Warning: we may need a move here but can't clone!
4915         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
4916         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
4917         return (long)ret_conv;
4918 }
4919
4920 void CResult_1CVec_1u8ZPeerHandleErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4921         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)_res;
4922         FREE((void*)_res);
4923         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
4924 }
4925
4926 uint32_t CResult_1NonePeerHandleErrorZ_1ok(void* ctx_TODO) {
4927         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4928         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
4929         return (long)ret_conv;
4930 }
4931
4932 uint32_t CResult_1NonePeerHandleErrorZ_1err(void* ctx_TODO, uint32_t e) {
4933         LDKPeerHandleError e_conv;
4934         e_conv.inner = (void*)(e & (~1));
4935         e_conv.is_owned = (e & 1) || (e == 0);
4936         // Warning: we may need a move here but can't clone!
4937         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
4938         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
4939         return (long)ret_conv;
4940 }
4941
4942 void CResult_1NonePeerHandleErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4943         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)_res;
4944         FREE((void*)_res);
4945         CResult_NonePeerHandleErrorZ_free(_res_conv);
4946 }
4947
4948 uint32_t CResult_1boolPeerHandleErrorZ_1ok(void* ctx_TODO, jboolean o) {
4949         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4950         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
4951         return (long)ret_conv;
4952 }
4953
4954 uint32_t CResult_1boolPeerHandleErrorZ_1err(void* ctx_TODO, uint32_t e) {
4955         LDKPeerHandleError e_conv;
4956         e_conv.inner = (void*)(e & (~1));
4957         e_conv.is_owned = (e & 1) || (e == 0);
4958         // Warning: we may need a move here but can't clone!
4959         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
4960         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
4961         return (long)ret_conv;
4962 }
4963
4964 void CResult_1boolPeerHandleErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4965         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)_res;
4966         FREE((void*)_res);
4967         CResult_boolPeerHandleErrorZ_free(_res_conv);
4968 }
4969
4970 uint32_t CResult_1SecretKeySecpErrorZ_1ok(void* ctx_TODO, int8_tArray o) {
4971         LDKSecretKey o_ref;
4972         CHECK(o.len == 32);
4973         memcpy(o_ref.bytes, o.ptr, 32);
4974         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4975         *ret_conv = CResult_SecretKeySecpErrorZ_ok(o_ref);
4976         return (long)ret_conv;
4977 }
4978
4979 uint32_t CResult_1SecretKeySecpErrorZ_1err(void* ctx_TODO, uint32_t e) {
4980         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
4981         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
4982         *ret_conv = CResult_SecretKeySecpErrorZ_err(e_conv);
4983         return (long)ret_conv;
4984 }
4985
4986 void CResult_1SecretKeySecpErrorZ_1free(void* ctx_TODO, uint32_t _res) {
4987         LDKCResult_SecretKeySecpErrorZ _res_conv = *(LDKCResult_SecretKeySecpErrorZ*)_res;
4988         FREE((void*)_res);
4989         CResult_SecretKeySecpErrorZ_free(_res_conv);
4990 }
4991
4992 uint32_t CResult_1PublicKeySecpErrorZ_1ok(void* ctx_TODO, int8_tArray o) {
4993         LDKPublicKey o_ref;
4994         CHECK(o.len == 33);
4995         memcpy(o_ref.compressed_form, o.ptr, 33);
4996         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
4997         *ret_conv = CResult_PublicKeySecpErrorZ_ok(o_ref);
4998         return (long)ret_conv;
4999 }
5000
5001 uint32_t CResult_1PublicKeySecpErrorZ_1err(void* ctx_TODO, uint32_t e) {
5002         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5003         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
5004         *ret_conv = CResult_PublicKeySecpErrorZ_err(e_conv);
5005         return (long)ret_conv;
5006 }
5007
5008 void CResult_1PublicKeySecpErrorZ_1free(void* ctx_TODO, uint32_t _res) {
5009         LDKCResult_PublicKeySecpErrorZ _res_conv = *(LDKCResult_PublicKeySecpErrorZ*)_res;
5010         FREE((void*)_res);
5011         CResult_PublicKeySecpErrorZ_free(_res_conv);
5012 }
5013
5014 uint32_t CResult_1TxCreationKeysSecpErrorZ_1ok(void* ctx_TODO, uint32_t o) {
5015         LDKTxCreationKeys o_conv;
5016         o_conv.inner = (void*)(o & (~1));
5017         o_conv.is_owned = (o & 1) || (o == 0);
5018         if (o_conv.inner != NULL)
5019                 o_conv = TxCreationKeys_clone(&o_conv);
5020         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
5021         *ret_conv = CResult_TxCreationKeysSecpErrorZ_ok(o_conv);
5022         return (long)ret_conv;
5023 }
5024
5025 uint32_t CResult_1TxCreationKeysSecpErrorZ_1err(void* ctx_TODO, uint32_t e) {
5026         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5027         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
5028         *ret_conv = CResult_TxCreationKeysSecpErrorZ_err(e_conv);
5029         return (long)ret_conv;
5030 }
5031
5032 void CResult_1TxCreationKeysSecpErrorZ_1free(void* ctx_TODO, uint32_t _res) {
5033         LDKCResult_TxCreationKeysSecpErrorZ _res_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)_res;
5034         FREE((void*)_res);
5035         CResult_TxCreationKeysSecpErrorZ_free(_res_conv);
5036 }
5037
5038 uint32_t CResult_1TrustedCommitmentTransactionNoneZ_1ok(void* ctx_TODO, uint32_t o) {
5039         LDKTrustedCommitmentTransaction o_conv;
5040         o_conv.inner = (void*)(o & (~1));
5041         o_conv.is_owned = (o & 1) || (o == 0);
5042         // Warning: we may need a move here but can't clone!
5043         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5044         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
5045         return (long)ret_conv;
5046 }
5047
5048 uint32_t CResult_1TrustedCommitmentTransactionNoneZ_1err(void* ctx_TODO) {
5049         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5050         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
5051         return (long)ret_conv;
5052 }
5053
5054 void CResult_1TrustedCommitmentTransactionNoneZ_1free(void* ctx_TODO, uint32_t _res) {
5055         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)_res;
5056         FREE((void*)_res);
5057         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
5058 }
5059
5060 void CVec_1RouteHopZ_1free(void* ctx_TODO, uint32_tArray _res) {
5061         LDKCVec_RouteHopZ _res_constr;
5062         _res_constr.datalen = _res.len;
5063         if (_res_constr.datalen > 0)
5064                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
5065         else
5066                 _res_constr.data = NULL;
5067         uint32_t* _res_vals = (uint32_t*) _res.ptr;
5068         for (size_t k = 0; k < _res_constr.datalen; k++) {
5069                 uint32_t arr_conv_10 = _res_vals[k];
5070                 LDKRouteHop arr_conv_10_conv;
5071                 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
5072                 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
5073                 _res_constr.data[k] = arr_conv_10_conv;
5074         }
5075         CVec_RouteHopZ_free(_res_constr);
5076 }
5077
5078 void CVec_1CVec_1RouteHopZZ_1free(void* ctx_TODO, uint32_tArray _res) {
5079         LDKCVec_CVec_RouteHopZZ _res_constr;
5080         _res_constr.datalen = _res.len;
5081         if (_res_constr.datalen > 0)
5082                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
5083         else
5084                 _res_constr.data = NULL;
5085         uint32_tArray* _res_vals = (uint32_tArray*) _res.ptr;
5086         for (size_t m = 0; m < _res_constr.datalen; m++) {
5087                 uint32_tArray arr_conv_12 = _res_vals[m];
5088                 LDKCVec_RouteHopZ arr_conv_12_constr;
5089                 arr_conv_12_constr.datalen = arr_conv_12.len;
5090                 if (arr_conv_12_constr.datalen > 0)
5091                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
5092                 else
5093                         arr_conv_12_constr.data = NULL;
5094                 uint32_t* arr_conv_12_vals = (uint32_t*) arr_conv_12.ptr;
5095                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
5096                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
5097                         LDKRouteHop arr_conv_10_conv;
5098                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
5099                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
5100                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
5101                 }
5102                 _res_constr.data[m] = arr_conv_12_constr;
5103         }
5104         CVec_CVec_RouteHopZZ_free(_res_constr);
5105 }
5106
5107 uint32_t CResult_1RouteDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
5108         LDKRoute o_conv;
5109         o_conv.inner = (void*)(o & (~1));
5110         o_conv.is_owned = (o & 1) || (o == 0);
5111         if (o_conv.inner != NULL)
5112                 o_conv = Route_clone(&o_conv);
5113         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
5114         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
5115         return (long)ret_conv;
5116 }
5117
5118 uint32_t CResult_1RouteDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
5119         LDKDecodeError e_conv;
5120         e_conv.inner = (void*)(e & (~1));
5121         e_conv.is_owned = (e & 1) || (e == 0);
5122         // Warning: we may need a move here but can't clone!
5123         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
5124         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
5125         return (long)ret_conv;
5126 }
5127
5128 void CResult_1RouteDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
5129         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)_res;
5130         FREE((void*)_res);
5131         CResult_RouteDecodeErrorZ_free(_res_conv);
5132 }
5133
5134 void CVec_1RouteHintZ_1free(void* ctx_TODO, uint32_tArray _res) {
5135         LDKCVec_RouteHintZ _res_constr;
5136         _res_constr.datalen = _res.len;
5137         if (_res_constr.datalen > 0)
5138                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
5139         else
5140                 _res_constr.data = NULL;
5141         uint32_t* _res_vals = (uint32_t*) _res.ptr;
5142         for (size_t l = 0; l < _res_constr.datalen; l++) {
5143                 uint32_t arr_conv_11 = _res_vals[l];
5144                 LDKRouteHint arr_conv_11_conv;
5145                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
5146                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
5147                 _res_constr.data[l] = arr_conv_11_conv;
5148         }
5149         CVec_RouteHintZ_free(_res_constr);
5150 }
5151
5152 uint32_t CResult_1RouteLightningErrorZ_1ok(void* ctx_TODO, uint32_t o) {
5153         LDKRoute o_conv;
5154         o_conv.inner = (void*)(o & (~1));
5155         o_conv.is_owned = (o & 1) || (o == 0);
5156         if (o_conv.inner != NULL)
5157                 o_conv = Route_clone(&o_conv);
5158         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
5159         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
5160         return (long)ret_conv;
5161 }
5162
5163 uint32_t CResult_1RouteLightningErrorZ_1err(void* ctx_TODO, uint32_t e) {
5164         LDKLightningError e_conv;
5165         e_conv.inner = (void*)(e & (~1));
5166         e_conv.is_owned = (e & 1) || (e == 0);
5167         // Warning: we may need a move here but can't clone!
5168         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
5169         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
5170         return (long)ret_conv;
5171 }
5172
5173 void CResult_1RouteLightningErrorZ_1free(void* ctx_TODO, uint32_t _res) {
5174         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)_res;
5175         FREE((void*)_res);
5176         CResult_RouteLightningErrorZ_free(_res_conv);
5177 }
5178
5179 uint32_t CResult_1RoutingFeesDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
5180         LDKRoutingFees o_conv;
5181         o_conv.inner = (void*)(o & (~1));
5182         o_conv.is_owned = (o & 1) || (o == 0);
5183         if (o_conv.inner != NULL)
5184                 o_conv = RoutingFees_clone(&o_conv);
5185         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
5186         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
5187         return (long)ret_conv;
5188 }
5189
5190 uint32_t CResult_1RoutingFeesDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
5191         LDKDecodeError e_conv;
5192         e_conv.inner = (void*)(e & (~1));
5193         e_conv.is_owned = (e & 1) || (e == 0);
5194         // Warning: we may need a move here but can't clone!
5195         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
5196         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
5197         return (long)ret_conv;
5198 }
5199
5200 void CResult_1RoutingFeesDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
5201         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)_res;
5202         FREE((void*)_res);
5203         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
5204 }
5205
5206 uint32_t CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
5207         LDKNodeAnnouncementInfo o_conv;
5208         o_conv.inner = (void*)(o & (~1));
5209         o_conv.is_owned = (o & 1) || (o == 0);
5210         // Warning: we may need a move here but can't clone!
5211         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
5212         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
5213         return (long)ret_conv;
5214 }
5215
5216 uint32_t CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
5217         LDKDecodeError e_conv;
5218         e_conv.inner = (void*)(e & (~1));
5219         e_conv.is_owned = (e & 1) || (e == 0);
5220         // Warning: we may need a move here but can't clone!
5221         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
5222         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
5223         return (long)ret_conv;
5224 }
5225
5226 void CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
5227         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)_res;
5228         FREE((void*)_res);
5229         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
5230 }
5231
5232 uint32_t CResult_1NodeInfoDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
5233         LDKNodeInfo o_conv;
5234         o_conv.inner = (void*)(o & (~1));
5235         o_conv.is_owned = (o & 1) || (o == 0);
5236         // Warning: we may need a move here but can't clone!
5237         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
5238         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
5239         return (long)ret_conv;
5240 }
5241
5242 uint32_t CResult_1NodeInfoDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
5243         LDKDecodeError e_conv;
5244         e_conv.inner = (void*)(e & (~1));
5245         e_conv.is_owned = (e & 1) || (e == 0);
5246         // Warning: we may need a move here but can't clone!
5247         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
5248         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
5249         return (long)ret_conv;
5250 }
5251
5252 void CResult_1NodeInfoDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
5253         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)_res;
5254         FREE((void*)_res);
5255         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
5256 }
5257
5258 uint32_t CResult_1NetworkGraphDecodeErrorZ_1ok(void* ctx_TODO, uint32_t o) {
5259         LDKNetworkGraph o_conv;
5260         o_conv.inner = (void*)(o & (~1));
5261         o_conv.is_owned = (o & 1) || (o == 0);
5262         // Warning: we may need a move here but can't clone!
5263         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
5264         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
5265         return (long)ret_conv;
5266 }
5267
5268 uint32_t CResult_1NetworkGraphDecodeErrorZ_1err(void* ctx_TODO, uint32_t e) {
5269         LDKDecodeError e_conv;
5270         e_conv.inner = (void*)(e & (~1));
5271         e_conv.is_owned = (e & 1) || (e == 0);
5272         // Warning: we may need a move here but can't clone!
5273         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
5274         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
5275         return (long)ret_conv;
5276 }
5277
5278 void CResult_1NetworkGraphDecodeErrorZ_1free(void* ctx_TODO, uint32_t _res) {
5279         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)_res;
5280         FREE((void*)_res);
5281         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
5282 }
5283
5284 void Event_1free(void* ctx_TODO, uint32_t this_ptr) {
5285         LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
5286         FREE((void*)this_ptr);
5287         Event_free(this_ptr_conv);
5288 }
5289
5290 uint32_t Event_1clone(void* ctx_TODO, uint32_t orig) {
5291         LDKEvent* orig_conv = (LDKEvent*)orig;
5292         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
5293         *ret_copy = Event_clone(orig_conv);
5294         long ret_ref = (long)ret_copy;
5295         return ret_ref;
5296 }
5297
5298 int8_tArray Event_1write(void* ctx_TODO, uint32_t obj) {
5299         LDKEvent* obj_conv = (LDKEvent*)obj;
5300         LDKCVec_u8Z arg_var = Event_write(obj_conv);
5301         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
5302         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
5303         CVec_u8Z_free(arg_var);
5304         return arg_arr;
5305 }
5306
5307 void MessageSendEvent_1free(void* ctx_TODO, uint32_t this_ptr) {
5308         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
5309         FREE((void*)this_ptr);
5310         MessageSendEvent_free(this_ptr_conv);
5311 }
5312
5313 uint32_t MessageSendEvent_1clone(void* ctx_TODO, uint32_t orig) {
5314         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
5315         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
5316         *ret_copy = MessageSendEvent_clone(orig_conv);
5317         long ret_ref = (long)ret_copy;
5318         return ret_ref;
5319 }
5320
5321 void MessageSendEventsProvider_1free(void* ctx_TODO, uint32_t this_ptr) {
5322         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
5323         FREE((void*)this_ptr);
5324         MessageSendEventsProvider_free(this_ptr_conv);
5325 }
5326
5327 void EventsProvider_1free(void* ctx_TODO, uint32_t this_ptr) {
5328         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
5329         FREE((void*)this_ptr);
5330         EventsProvider_free(this_ptr_conv);
5331 }
5332
5333 void APIError_1free(void* ctx_TODO, uint32_t this_ptr) {
5334         LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
5335         FREE((void*)this_ptr);
5336         APIError_free(this_ptr_conv);
5337 }
5338
5339 uint32_t APIError_1clone(void* ctx_TODO, uint32_t orig) {
5340         LDKAPIError* orig_conv = (LDKAPIError*)orig;
5341         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
5342         *ret_copy = APIError_clone(orig_conv);
5343         long ret_ref = (long)ret_copy;
5344         return ret_ref;
5345 }
5346
5347 uint32_t Level_1clone(void* ctx_TODO, uint32_t orig) {
5348         LDKLevel* orig_conv = (LDKLevel*)orig;
5349         uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
5350         return ret_conv;
5351 }
5352
5353 uint32_t Level_1max(void* ctx_TODO) {
5354         uint32_t ret_conv = LDKLevel_to_js(Level_max());
5355         return ret_conv;
5356 }
5357
5358 void Logger_1free(void* ctx_TODO, uint32_t this_ptr) {
5359         LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
5360         FREE((void*)this_ptr);
5361         Logger_free(this_ptr_conv);
5362 }
5363
5364 void ChannelHandshakeConfig_1free(void* ctx_TODO, uint32_t this_ptr) {
5365         LDKChannelHandshakeConfig this_ptr_conv;
5366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5367         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5368         ChannelHandshakeConfig_free(this_ptr_conv);
5369 }
5370
5371 uint32_t ChannelHandshakeConfig_1clone(void* ctx_TODO, uint32_t orig) {
5372         LDKChannelHandshakeConfig orig_conv;
5373         orig_conv.inner = (void*)(orig & (~1));
5374         orig_conv.is_owned = false;
5375         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
5376         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5377         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5378         long ret_ref = (long)ret_var.inner;
5379         if (ret_var.is_owned) {
5380                 ret_ref |= 1;
5381         }
5382         return ret_ref;
5383 }
5384
5385 int32_t ChannelHandshakeConfig_1get_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr) {
5386         LDKChannelHandshakeConfig this_ptr_conv;
5387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5388         this_ptr_conv.is_owned = false;
5389         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
5390         return ret_val;
5391 }
5392
5393 void ChannelHandshakeConfig_1set_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
5394         LDKChannelHandshakeConfig this_ptr_conv;
5395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5396         this_ptr_conv.is_owned = false;
5397         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
5398 }
5399
5400 jshort ChannelHandshakeConfig_1get_1our_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr) {
5401         LDKChannelHandshakeConfig this_ptr_conv;
5402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5403         this_ptr_conv.is_owned = false;
5404         jshort ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
5405         return ret_val;
5406 }
5407
5408 void ChannelHandshakeConfig_1set_1our_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
5409         LDKChannelHandshakeConfig this_ptr_conv;
5410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5411         this_ptr_conv.is_owned = false;
5412         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
5413 }
5414
5415 int64_t ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
5416         LDKChannelHandshakeConfig this_ptr_conv;
5417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5418         this_ptr_conv.is_owned = false;
5419         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
5420         return ret_val;
5421 }
5422
5423 void ChannelHandshakeConfig_1set_1our_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
5424         LDKChannelHandshakeConfig this_ptr_conv;
5425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5426         this_ptr_conv.is_owned = false;
5427         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
5428 }
5429
5430 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) {
5431         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
5432         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5433         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5434         long ret_ref = (long)ret_var.inner;
5435         if (ret_var.is_owned) {
5436                 ret_ref |= 1;
5437         }
5438         return ret_ref;
5439 }
5440
5441 uint32_t ChannelHandshakeConfig_1default(void* ctx_TODO) {
5442         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
5443         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5444         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5445         long ret_ref = (long)ret_var.inner;
5446         if (ret_var.is_owned) {
5447                 ret_ref |= 1;
5448         }
5449         return ret_ref;
5450 }
5451
5452 void ChannelHandshakeLimits_1free(void* ctx_TODO, uint32_t this_ptr) {
5453         LDKChannelHandshakeLimits this_ptr_conv;
5454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5455         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5456         ChannelHandshakeLimits_free(this_ptr_conv);
5457 }
5458
5459 uint32_t ChannelHandshakeLimits_1clone(void* ctx_TODO, uint32_t orig) {
5460         LDKChannelHandshakeLimits orig_conv;
5461         orig_conv.inner = (void*)(orig & (~1));
5462         orig_conv.is_owned = false;
5463         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
5464         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5465         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5466         long ret_ref = (long)ret_var.inner;
5467         if (ret_var.is_owned) {
5468                 ret_ref |= 1;
5469         }
5470         return ret_ref;
5471 }
5472
5473 int64_t ChannelHandshakeLimits_1get_1min_1funding_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
5474         LDKChannelHandshakeLimits this_ptr_conv;
5475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5476         this_ptr_conv.is_owned = false;
5477         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
5478         return ret_val;
5479 }
5480
5481 void ChannelHandshakeLimits_1set_1min_1funding_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
5482         LDKChannelHandshakeLimits this_ptr_conv;
5483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5484         this_ptr_conv.is_owned = false;
5485         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
5486 }
5487
5488 int64_t ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
5489         LDKChannelHandshakeLimits this_ptr_conv;
5490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5491         this_ptr_conv.is_owned = false;
5492         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
5493         return ret_val;
5494 }
5495
5496 void ChannelHandshakeLimits_1set_1max_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
5497         LDKChannelHandshakeLimits this_ptr_conv;
5498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5499         this_ptr_conv.is_owned = false;
5500         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
5501 }
5502
5503 int64_t ChannelHandshakeLimits_1get_1min_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr) {
5504         LDKChannelHandshakeLimits this_ptr_conv;
5505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5506         this_ptr_conv.is_owned = false;
5507         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
5508         return ret_val;
5509 }
5510
5511 void ChannelHandshakeLimits_1set_1min_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
5512         LDKChannelHandshakeLimits this_ptr_conv;
5513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5514         this_ptr_conv.is_owned = false;
5515         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
5516 }
5517
5518 int64_t ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
5519         LDKChannelHandshakeLimits this_ptr_conv;
5520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5521         this_ptr_conv.is_owned = false;
5522         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
5523         return ret_val;
5524 }
5525
5526 void ChannelHandshakeLimits_1set_1max_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
5527         LDKChannelHandshakeLimits this_ptr_conv;
5528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5529         this_ptr_conv.is_owned = false;
5530         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
5531 }
5532
5533 jshort ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr) {
5534         LDKChannelHandshakeLimits this_ptr_conv;
5535         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5536         this_ptr_conv.is_owned = false;
5537         jshort ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
5538         return ret_val;
5539 }
5540
5541 void ChannelHandshakeLimits_1set_1min_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr, jshort val) {
5542         LDKChannelHandshakeLimits this_ptr_conv;
5543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5544         this_ptr_conv.is_owned = false;
5545         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
5546 }
5547
5548 int64_t ChannelHandshakeLimits_1get_1min_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
5549         LDKChannelHandshakeLimits this_ptr_conv;
5550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5551         this_ptr_conv.is_owned = false;
5552         int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
5553         return ret_val;
5554 }
5555
5556 void ChannelHandshakeLimits_1set_1min_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
5557         LDKChannelHandshakeLimits this_ptr_conv;
5558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5559         this_ptr_conv.is_owned = false;
5560         ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
5561 }
5562
5563 int64_t ChannelHandshakeLimits_1get_1max_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
5564         LDKChannelHandshakeLimits this_ptr_conv;
5565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5566         this_ptr_conv.is_owned = false;
5567         int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
5568         return ret_val;
5569 }
5570
5571 void ChannelHandshakeLimits_1set_1max_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
5572         LDKChannelHandshakeLimits this_ptr_conv;
5573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5574         this_ptr_conv.is_owned = false;
5575         ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
5576 }
5577
5578 int32_t ChannelHandshakeLimits_1get_1max_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr) {
5579         LDKChannelHandshakeLimits this_ptr_conv;
5580         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5581         this_ptr_conv.is_owned = false;
5582         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
5583         return ret_val;
5584 }
5585
5586 void ChannelHandshakeLimits_1set_1max_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
5587         LDKChannelHandshakeLimits this_ptr_conv;
5588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5589         this_ptr_conv.is_owned = false;
5590         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
5591 }
5592
5593 jboolean ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(void* ctx_TODO, uint32_t this_ptr) {
5594         LDKChannelHandshakeLimits this_ptr_conv;
5595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5596         this_ptr_conv.is_owned = false;
5597         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
5598         return ret_val;
5599 }
5600
5601 void ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
5602         LDKChannelHandshakeLimits this_ptr_conv;
5603         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5604         this_ptr_conv.is_owned = false;
5605         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
5606 }
5607
5608 jshort ChannelHandshakeLimits_1get_1their_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr) {
5609         LDKChannelHandshakeLimits this_ptr_conv;
5610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5611         this_ptr_conv.is_owned = false;
5612         jshort ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
5613         return ret_val;
5614 }
5615
5616 void ChannelHandshakeLimits_1set_1their_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
5617         LDKChannelHandshakeLimits this_ptr_conv;
5618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5619         this_ptr_conv.is_owned = false;
5620         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
5621 }
5622
5623 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) {
5624         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);
5625         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5626         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5627         long ret_ref = (long)ret_var.inner;
5628         if (ret_var.is_owned) {
5629                 ret_ref |= 1;
5630         }
5631         return ret_ref;
5632 }
5633
5634 uint32_t ChannelHandshakeLimits_1default(void* ctx_TODO) {
5635         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
5636         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5637         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5638         long ret_ref = (long)ret_var.inner;
5639         if (ret_var.is_owned) {
5640                 ret_ref |= 1;
5641         }
5642         return ret_ref;
5643 }
5644
5645 void ChannelConfig_1free(void* ctx_TODO, uint32_t this_ptr) {
5646         LDKChannelConfig this_ptr_conv;
5647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5648         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5649         ChannelConfig_free(this_ptr_conv);
5650 }
5651
5652 uint32_t ChannelConfig_1clone(void* ctx_TODO, uint32_t orig) {
5653         LDKChannelConfig orig_conv;
5654         orig_conv.inner = (void*)(orig & (~1));
5655         orig_conv.is_owned = false;
5656         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
5657         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5658         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5659         long ret_ref = (long)ret_var.inner;
5660         if (ret_var.is_owned) {
5661                 ret_ref |= 1;
5662         }
5663         return ret_ref;
5664 }
5665
5666 int32_t ChannelConfig_1get_1fee_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr) {
5667         LDKChannelConfig this_ptr_conv;
5668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5669         this_ptr_conv.is_owned = false;
5670         int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
5671         return ret_val;
5672 }
5673
5674 void ChannelConfig_1set_1fee_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
5675         LDKChannelConfig this_ptr_conv;
5676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5677         this_ptr_conv.is_owned = false;
5678         ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
5679 }
5680
5681 jboolean ChannelConfig_1get_1announced_1channel(void* ctx_TODO, uint32_t this_ptr) {
5682         LDKChannelConfig this_ptr_conv;
5683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5684         this_ptr_conv.is_owned = false;
5685         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
5686         return ret_val;
5687 }
5688
5689 void ChannelConfig_1set_1announced_1channel(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
5690         LDKChannelConfig this_ptr_conv;
5691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5692         this_ptr_conv.is_owned = false;
5693         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
5694 }
5695
5696 jboolean ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
5697         LDKChannelConfig this_ptr_conv;
5698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5699         this_ptr_conv.is_owned = false;
5700         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
5701         return ret_val;
5702 }
5703
5704 void ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
5705         LDKChannelConfig this_ptr_conv;
5706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5707         this_ptr_conv.is_owned = false;
5708         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
5709 }
5710
5711 uint32_t ChannelConfig_1new(void* ctx_TODO, int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
5712         LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
5713         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5714         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5715         long ret_ref = (long)ret_var.inner;
5716         if (ret_var.is_owned) {
5717                 ret_ref |= 1;
5718         }
5719         return ret_ref;
5720 }
5721
5722 uint32_t ChannelConfig_1default(void* ctx_TODO) {
5723         LDKChannelConfig ret_var = ChannelConfig_default();
5724         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5725         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5726         long ret_ref = (long)ret_var.inner;
5727         if (ret_var.is_owned) {
5728                 ret_ref |= 1;
5729         }
5730         return ret_ref;
5731 }
5732
5733 int8_tArray ChannelConfig_1write(void* ctx_TODO, uint32_t obj) {
5734         LDKChannelConfig obj_conv;
5735         obj_conv.inner = (void*)(obj & (~1));
5736         obj_conv.is_owned = false;
5737         LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
5738         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
5739         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
5740         CVec_u8Z_free(arg_var);
5741         return arg_arr;
5742 }
5743
5744 uint32_t ChannelConfig_1read(void* ctx_TODO, int8_tArray ser) {
5745         LDKu8slice ser_ref;
5746         ser_ref.datalen = ser.len;
5747         ser_ref.data = ser.ptr;
5748         LDKChannelConfig ret_var = ChannelConfig_read(ser_ref);
5749         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5750         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5751         long ret_ref = (long)ret_var.inner;
5752         if (ret_var.is_owned) {
5753                 ret_ref |= 1;
5754         }
5755         return ret_ref;
5756 }
5757
5758 void UserConfig_1free(void* ctx_TODO, uint32_t this_ptr) {
5759         LDKUserConfig this_ptr_conv;
5760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5761         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5762         UserConfig_free(this_ptr_conv);
5763 }
5764
5765 uint32_t UserConfig_1clone(void* ctx_TODO, uint32_t orig) {
5766         LDKUserConfig orig_conv;
5767         orig_conv.inner = (void*)(orig & (~1));
5768         orig_conv.is_owned = false;
5769         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
5770         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5771         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5772         long ret_ref = (long)ret_var.inner;
5773         if (ret_var.is_owned) {
5774                 ret_ref |= 1;
5775         }
5776         return ret_ref;
5777 }
5778
5779 uint32_t UserConfig_1get_1own_1channel_1config(void* ctx_TODO, uint32_t this_ptr) {
5780         LDKUserConfig this_ptr_conv;
5781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5782         this_ptr_conv.is_owned = false;
5783         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
5784         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5785         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5786         long ret_ref = (long)ret_var.inner;
5787         if (ret_var.is_owned) {
5788                 ret_ref |= 1;
5789         }
5790         return ret_ref;
5791 }
5792
5793 void UserConfig_1set_1own_1channel_1config(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
5794         LDKUserConfig this_ptr_conv;
5795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5796         this_ptr_conv.is_owned = false;
5797         LDKChannelHandshakeConfig val_conv;
5798         val_conv.inner = (void*)(val & (~1));
5799         val_conv.is_owned = (val & 1) || (val == 0);
5800         if (val_conv.inner != NULL)
5801                 val_conv = ChannelHandshakeConfig_clone(&val_conv);
5802         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
5803 }
5804
5805 uint32_t UserConfig_1get_1peer_1channel_1config_1limits(void* ctx_TODO, uint32_t this_ptr) {
5806         LDKUserConfig this_ptr_conv;
5807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5808         this_ptr_conv.is_owned = false;
5809         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
5810         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5811         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5812         long ret_ref = (long)ret_var.inner;
5813         if (ret_var.is_owned) {
5814                 ret_ref |= 1;
5815         }
5816         return ret_ref;
5817 }
5818
5819 void UserConfig_1set_1peer_1channel_1config_1limits(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
5820         LDKUserConfig this_ptr_conv;
5821         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5822         this_ptr_conv.is_owned = false;
5823         LDKChannelHandshakeLimits val_conv;
5824         val_conv.inner = (void*)(val & (~1));
5825         val_conv.is_owned = (val & 1) || (val == 0);
5826         if (val_conv.inner != NULL)
5827                 val_conv = ChannelHandshakeLimits_clone(&val_conv);
5828         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
5829 }
5830
5831 uint32_t UserConfig_1get_1channel_1options(void* ctx_TODO, uint32_t this_ptr) {
5832         LDKUserConfig this_ptr_conv;
5833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5834         this_ptr_conv.is_owned = false;
5835         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
5836         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5837         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5838         long ret_ref = (long)ret_var.inner;
5839         if (ret_var.is_owned) {
5840                 ret_ref |= 1;
5841         }
5842         return ret_ref;
5843 }
5844
5845 void UserConfig_1set_1channel_1options(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
5846         LDKUserConfig this_ptr_conv;
5847         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5848         this_ptr_conv.is_owned = false;
5849         LDKChannelConfig val_conv;
5850         val_conv.inner = (void*)(val & (~1));
5851         val_conv.is_owned = (val & 1) || (val == 0);
5852         if (val_conv.inner != NULL)
5853                 val_conv = ChannelConfig_clone(&val_conv);
5854         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
5855 }
5856
5857 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) {
5858         LDKChannelHandshakeConfig own_channel_config_arg_conv;
5859         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
5860         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
5861         if (own_channel_config_arg_conv.inner != NULL)
5862                 own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
5863         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
5864         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
5865         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
5866         if (peer_channel_config_limits_arg_conv.inner != NULL)
5867                 peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
5868         LDKChannelConfig channel_options_arg_conv;
5869         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
5870         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
5871         if (channel_options_arg_conv.inner != NULL)
5872                 channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
5873         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
5874         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5875         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5876         long ret_ref = (long)ret_var.inner;
5877         if (ret_var.is_owned) {
5878                 ret_ref |= 1;
5879         }
5880         return ret_ref;
5881 }
5882
5883 uint32_t UserConfig_1default(void* ctx_TODO) {
5884         LDKUserConfig ret_var = UserConfig_default();
5885         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5886         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5887         long ret_ref = (long)ret_var.inner;
5888         if (ret_var.is_owned) {
5889                 ret_ref |= 1;
5890         }
5891         return ret_ref;
5892 }
5893
5894 uint32_t AccessError_1clone(void* ctx_TODO, uint32_t orig) {
5895         LDKAccessError* orig_conv = (LDKAccessError*)orig;
5896         uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
5897         return ret_conv;
5898 }
5899
5900 void Access_1free(void* ctx_TODO, uint32_t this_ptr) {
5901         LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
5902         FREE((void*)this_ptr);
5903         Access_free(this_ptr_conv);
5904 }
5905
5906 void Watch_1free(void* ctx_TODO, uint32_t this_ptr) {
5907         LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
5908         FREE((void*)this_ptr);
5909         Watch_free(this_ptr_conv);
5910 }
5911
5912 void Filter_1free(void* ctx_TODO, uint32_t this_ptr) {
5913         LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
5914         FREE((void*)this_ptr);
5915         Filter_free(this_ptr_conv);
5916 }
5917
5918 void BroadcasterInterface_1free(void* ctx_TODO, uint32_t this_ptr) {
5919         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
5920         FREE((void*)this_ptr);
5921         BroadcasterInterface_free(this_ptr_conv);
5922 }
5923
5924 uint32_t ConfirmationTarget_1clone(void* ctx_TODO, uint32_t orig) {
5925         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)orig;
5926         uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
5927         return ret_conv;
5928 }
5929
5930 void FeeEstimator_1free(void* ctx_TODO, uint32_t this_ptr) {
5931         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
5932         FREE((void*)this_ptr);
5933         FeeEstimator_free(this_ptr_conv);
5934 }
5935
5936 void ChainMonitor_1free(void* ctx_TODO, uint32_t this_ptr) {
5937         LDKChainMonitor this_ptr_conv;
5938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
5939         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
5940         ChainMonitor_free(this_ptr_conv);
5941 }
5942
5943 void ChainMonitor_1block_1connected(void* ctx_TODO, uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
5944         LDKChainMonitor this_arg_conv;
5945         this_arg_conv.inner = (void*)(this_arg & (~1));
5946         this_arg_conv.is_owned = false;
5947         unsigned char header_arr[80];
5948         CHECK(header.len == 80);
5949         memcpy(header_arr, header.ptr, 80);
5950         unsigned char (*header_ref)[80] = &header_arr;
5951         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
5952         txdata_constr.datalen = txdata.len;
5953         if (txdata_constr.datalen > 0)
5954                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
5955         else
5956                 txdata_constr.data = NULL;
5957         uint32_t* txdata_vals = (uint32_t*) txdata.ptr;
5958         for (size_t y = 0; y < txdata_constr.datalen; y++) {
5959                 uint32_t arr_conv_24 = txdata_vals[y];
5960                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_24;
5961                 FREE((void*)arr_conv_24);
5962                 txdata_constr.data[y] = arr_conv_24_conv;
5963         }
5964         ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
5965 }
5966
5967 void ChainMonitor_1block_1disconnected(void* ctx_TODO, uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
5968         LDKChainMonitor this_arg_conv;
5969         this_arg_conv.inner = (void*)(this_arg & (~1));
5970         this_arg_conv.is_owned = false;
5971         unsigned char header_arr[80];
5972         CHECK(header.len == 80);
5973         memcpy(header_arr, header.ptr, 80);
5974         unsigned char (*header_ref)[80] = &header_arr;
5975         ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
5976 }
5977
5978 uint32_t ChainMonitor_1new(void* ctx_TODO, uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
5979         LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
5980         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
5981         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
5982                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5983                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
5984         }
5985         LDKLogger logger_conv = *(LDKLogger*)logger;
5986         if (logger_conv.free == LDKLogger_JCalls_free) {
5987                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5988                 LDKLogger_JCalls_clone(logger_conv.this_arg);
5989         }
5990         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
5991         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
5992                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5993                 LDKFeeEstimator_JCalls_clone(feeest_conv.this_arg);
5994         }
5995         LDKPersist persister_conv = *(LDKPersist*)persister;
5996         if (persister_conv.free == LDKPersist_JCalls_free) {
5997                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
5998                 LDKPersist_JCalls_clone(persister_conv.this_arg);
5999         }
6000         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
6001         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6002         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6003         long ret_ref = (long)ret_var.inner;
6004         if (ret_var.is_owned) {
6005                 ret_ref |= 1;
6006         }
6007         return ret_ref;
6008 }
6009
6010 uint32_t ChainMonitor_1as_1Watch(void* ctx_TODO, uint32_t this_arg) {
6011         LDKChainMonitor this_arg_conv;
6012         this_arg_conv.inner = (void*)(this_arg & (~1));
6013         this_arg_conv.is_owned = false;
6014         LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
6015         *ret = ChainMonitor_as_Watch(&this_arg_conv);
6016         return (long)ret;
6017 }
6018
6019 uint32_t ChainMonitor_1as_1EventsProvider(void* ctx_TODO, uint32_t this_arg) {
6020         LDKChainMonitor this_arg_conv;
6021         this_arg_conv.inner = (void*)(this_arg & (~1));
6022         this_arg_conv.is_owned = false;
6023         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6024         *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
6025         return (long)ret;
6026 }
6027
6028 void ChannelMonitorUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
6029         LDKChannelMonitorUpdate this_ptr_conv;
6030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6031         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6032         ChannelMonitorUpdate_free(this_ptr_conv);
6033 }
6034
6035 uint32_t ChannelMonitorUpdate_1clone(void* ctx_TODO, uint32_t orig) {
6036         LDKChannelMonitorUpdate orig_conv;
6037         orig_conv.inner = (void*)(orig & (~1));
6038         orig_conv.is_owned = false;
6039         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
6040         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6041         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6042         long ret_ref = (long)ret_var.inner;
6043         if (ret_var.is_owned) {
6044                 ret_ref |= 1;
6045         }
6046         return ret_ref;
6047 }
6048
6049 int64_t ChannelMonitorUpdate_1get_1update_1id(void* ctx_TODO, uint32_t this_ptr) {
6050         LDKChannelMonitorUpdate this_ptr_conv;
6051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6052         this_ptr_conv.is_owned = false;
6053         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
6054         return ret_val;
6055 }
6056
6057 void ChannelMonitorUpdate_1set_1update_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6058         LDKChannelMonitorUpdate this_ptr_conv;
6059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6060         this_ptr_conv.is_owned = false;
6061         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
6062 }
6063
6064 int8_tArray ChannelMonitorUpdate_1write(void* ctx_TODO, uint32_t obj) {
6065         LDKChannelMonitorUpdate obj_conv;
6066         obj_conv.inner = (void*)(obj & (~1));
6067         obj_conv.is_owned = false;
6068         LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
6069         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
6070         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
6071         CVec_u8Z_free(arg_var);
6072         return arg_arr;
6073 }
6074
6075 uint32_t ChannelMonitorUpdate_1read(void* ctx_TODO, int8_tArray ser) {
6076         LDKu8slice ser_ref;
6077         ser_ref.datalen = ser.len;
6078         ser_ref.data = ser.ptr;
6079         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6080         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
6081         return (long)ret_conv;
6082 }
6083
6084 uint32_t ChannelMonitorUpdateErr_1clone(void* ctx_TODO, uint32_t orig) {
6085         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)orig;
6086         uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
6087         return ret_conv;
6088 }
6089
6090 void MonitorUpdateError_1free(void* ctx_TODO, uint32_t this_ptr) {
6091         LDKMonitorUpdateError this_ptr_conv;
6092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6093         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6094         MonitorUpdateError_free(this_ptr_conv);
6095 }
6096
6097 void MonitorEvent_1free(void* ctx_TODO, uint32_t this_ptr) {
6098         LDKMonitorEvent this_ptr_conv;
6099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6100         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6101         MonitorEvent_free(this_ptr_conv);
6102 }
6103
6104 uint32_t MonitorEvent_1clone(void* ctx_TODO, uint32_t orig) {
6105         LDKMonitorEvent orig_conv;
6106         orig_conv.inner = (void*)(orig & (~1));
6107         orig_conv.is_owned = false;
6108         LDKMonitorEvent ret_var = MonitorEvent_clone(&orig_conv);
6109         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6110         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6111         long ret_ref = (long)ret_var.inner;
6112         if (ret_var.is_owned) {
6113                 ret_ref |= 1;
6114         }
6115         return ret_ref;
6116 }
6117
6118 void HTLCUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
6119         LDKHTLCUpdate this_ptr_conv;
6120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6121         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6122         HTLCUpdate_free(this_ptr_conv);
6123 }
6124
6125 uint32_t HTLCUpdate_1clone(void* ctx_TODO, uint32_t orig) {
6126         LDKHTLCUpdate orig_conv;
6127         orig_conv.inner = (void*)(orig & (~1));
6128         orig_conv.is_owned = false;
6129         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
6130         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6131         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6132         long ret_ref = (long)ret_var.inner;
6133         if (ret_var.is_owned) {
6134                 ret_ref |= 1;
6135         }
6136         return ret_ref;
6137 }
6138
6139 int8_tArray HTLCUpdate_1write(void* ctx_TODO, uint32_t obj) {
6140         LDKHTLCUpdate obj_conv;
6141         obj_conv.inner = (void*)(obj & (~1));
6142         obj_conv.is_owned = false;
6143         LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
6144         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
6145         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
6146         CVec_u8Z_free(arg_var);
6147         return arg_arr;
6148 }
6149
6150 uint32_t HTLCUpdate_1read(void* ctx_TODO, int8_tArray ser) {
6151         LDKu8slice ser_ref;
6152         ser_ref.datalen = ser.len;
6153         ser_ref.data = ser.ptr;
6154         LDKHTLCUpdate ret_var = HTLCUpdate_read(ser_ref);
6155         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6156         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6157         long ret_ref = (long)ret_var.inner;
6158         if (ret_var.is_owned) {
6159                 ret_ref |= 1;
6160         }
6161         return ret_ref;
6162 }
6163
6164 void ChannelMonitor_1free(void* ctx_TODO, uint32_t this_ptr) {
6165         LDKChannelMonitor this_ptr_conv;
6166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6167         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6168         ChannelMonitor_free(this_ptr_conv);
6169 }
6170
6171 int8_tArray ChannelMonitor_1write(void* ctx_TODO, uint32_t obj) {
6172         LDKChannelMonitor obj_conv;
6173         obj_conv.inner = (void*)(obj & (~1));
6174         obj_conv.is_owned = false;
6175         LDKCVec_u8Z arg_var = ChannelMonitor_write(&obj_conv);
6176         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
6177         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
6178         CVec_u8Z_free(arg_var);
6179         return arg_arr;
6180 }
6181
6182 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) {
6183         LDKChannelMonitor this_arg_conv;
6184         this_arg_conv.inner = (void*)(this_arg & (~1));
6185         this_arg_conv.is_owned = false;
6186         LDKChannelMonitorUpdate updates_conv;
6187         updates_conv.inner = (void*)(updates & (~1));
6188         updates_conv.is_owned = false;
6189         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
6190         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator;
6191         LDKLogger* logger_conv = (LDKLogger*)logger;
6192         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
6193         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
6194         return (long)ret_conv;
6195 }
6196
6197 int64_t ChannelMonitor_1get_1latest_1update_1id(void* ctx_TODO, uint32_t this_arg) {
6198         LDKChannelMonitor this_arg_conv;
6199         this_arg_conv.inner = (void*)(this_arg & (~1));
6200         this_arg_conv.is_owned = false;
6201         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
6202         return ret_val;
6203 }
6204
6205 uint32_t ChannelMonitor_1get_1funding_1txo(void* ctx_TODO, uint32_t this_arg) {
6206         LDKChannelMonitor this_arg_conv;
6207         this_arg_conv.inner = (void*)(this_arg & (~1));
6208         this_arg_conv.is_owned = false;
6209         LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
6210         *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
6211         ret_ref->a = OutPoint_clone(&ret_ref->a);
6212         ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
6213         return (long)ret_ref;
6214 }
6215
6216 uint32_tArray ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(void* ctx_TODO, uint32_t this_arg) {
6217         LDKChannelMonitor this_arg_conv;
6218         this_arg_conv.inner = (void*)(this_arg & (~1));
6219         this_arg_conv.is_owned = false;
6220         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
6221         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
6222         uint32_t *ret_arr_ptr = ret_arr.ptr;
6223         for (size_t o = 0; o < ret_var.datalen; o++) {
6224                 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
6225                 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6226                 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6227                 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
6228                 if (arr_conv_14_var.is_owned) {
6229                         arr_conv_14_ref |= 1;
6230                 }
6231                 ret_arr_ptr[o] = arr_conv_14_ref;
6232         }
6233         FREE(ret_var.data);
6234         return ret_arr;
6235 }
6236
6237 uint32_tArray ChannelMonitor_1get_1and_1clear_1pending_1events(void* ctx_TODO, uint32_t this_arg) {
6238         LDKChannelMonitor this_arg_conv;
6239         this_arg_conv.inner = (void*)(this_arg & (~1));
6240         this_arg_conv.is_owned = false;
6241         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
6242         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
6243         uint32_t *ret_arr_ptr = ret_arr.ptr;
6244         for (size_t h = 0; h < ret_var.datalen; h++) {
6245                 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6246                 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
6247                 long arr_conv_7_ref = (long)arr_conv_7_copy;
6248                 ret_arr_ptr[h] = arr_conv_7_ref;
6249         }
6250         FREE(ret_var.data);
6251         return ret_arr;
6252 }
6253
6254 uint32_tArray ChannelMonitor_1get_1latest_1holder_1commitment_1txn(void* ctx_TODO, uint32_t this_arg, uint32_t logger) {
6255         LDKChannelMonitor this_arg_conv;
6256         this_arg_conv.inner = (void*)(this_arg & (~1));
6257         this_arg_conv.is_owned = false;
6258         LDKLogger* logger_conv = (LDKLogger*)logger;
6259         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
6260         uint32_tArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6261         for (size_t i = 0; i < ret_var.datalen; i++) {
6262                 LDKTransaction arr_conv_8_var = ret_var.data[i];
6263                 int8_tArray arr_conv_8_arr = { .len = arr_conv_8_var.datalen, .ptr = MALLOC(arr_conv_8_var.datalen, "Native int8_tArray Bytes") };
6264                 memcpy(arr_conv_8_arr.ptr, arr_conv_8_var.data, arr_conv_8_var.datalen);
6265                 Transaction_free(arr_conv_8_var);
6266                 (*env)->SetObjectArrayElement(env, ret_arr, i, arr_conv_8_arr);
6267         }
6268         FREE(ret_var.data);
6269         return ret_arr;
6270 }
6271
6272 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) {
6273         LDKChannelMonitor this_arg_conv;
6274         this_arg_conv.inner = (void*)(this_arg & (~1));
6275         this_arg_conv.is_owned = false;
6276         unsigned char header_arr[80];
6277         CHECK(header.len == 80);
6278         memcpy(header_arr, header.ptr, 80);
6279         unsigned char (*header_ref)[80] = &header_arr;
6280         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6281         txdata_constr.datalen = txdata.len;
6282         if (txdata_constr.datalen > 0)
6283                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6284         else
6285                 txdata_constr.data = NULL;
6286         uint32_t* txdata_vals = (uint32_t*) txdata.ptr;
6287         for (size_t y = 0; y < txdata_constr.datalen; y++) {
6288                 uint32_t arr_conv_24 = txdata_vals[y];
6289                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_24;
6290                 FREE((void*)arr_conv_24);
6291                 txdata_constr.data[y] = arr_conv_24_conv;
6292         }
6293         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6294         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6295                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6296                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
6297         }
6298         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6299         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6300                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6301                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6302         }
6303         LDKLogger logger_conv = *(LDKLogger*)logger;
6304         if (logger_conv.free == LDKLogger_JCalls_free) {
6305                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6306                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6307         }
6308         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);
6309         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
6310         uint32_t *ret_arr_ptr = ret_arr.ptr;
6311         for (size_t u = 0; u < ret_var.datalen; u++) {
6312                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arr_conv_46_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
6313                 *arr_conv_46_ref = ret_var.data[u];
6314                 arr_conv_46_ref->a = ThirtyTwoBytes_clone(&arr_conv_46_ref->a);
6315                 // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Integer, TxOut>[]
6316                 ret_arr_ptr[u] = (long)arr_conv_46_ref;
6317         }
6318         FREE(ret_var.data);
6319         return ret_arr;
6320 }
6321
6322 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) {
6323         LDKChannelMonitor this_arg_conv;
6324         this_arg_conv.inner = (void*)(this_arg & (~1));
6325         this_arg_conv.is_owned = false;
6326         unsigned char header_arr[80];
6327         CHECK(header.len == 80);
6328         memcpy(header_arr, header.ptr, 80);
6329         unsigned char (*header_ref)[80] = &header_arr;
6330         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6331         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
6332                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6333                 LDKBroadcasterInterface_JCalls_clone(broadcaster_conv.this_arg);
6334         }
6335         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
6336         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
6337                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6338                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
6339         }
6340         LDKLogger logger_conv = *(LDKLogger*)logger;
6341         if (logger_conv.free == LDKLogger_JCalls_free) {
6342                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6343                 LDKLogger_JCalls_clone(logger_conv.this_arg);
6344         }
6345         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
6346 }
6347
6348 void Persist_1free(void* ctx_TODO, uint32_t this_ptr) {
6349         LDKPersist this_ptr_conv = *(LDKPersist*)this_ptr;
6350         FREE((void*)this_ptr);
6351         Persist_free(this_ptr_conv);
6352 }
6353
6354 uint32_t C2Tuple_1BlockHashChannelMonitorZ_1read(void* ctx_TODO, int8_tArray ser, uint32_t arg) {
6355         LDKu8slice ser_ref;
6356         ser_ref.datalen = ser.len;
6357         ser_ref.data = ser.ptr;
6358         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
6359         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
6360         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
6361         return (long)ret_conv;
6362 }
6363
6364 void OutPoint_1free(void* ctx_TODO, uint32_t this_ptr) {
6365         LDKOutPoint this_ptr_conv;
6366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6367         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6368         OutPoint_free(this_ptr_conv);
6369 }
6370
6371 uint32_t OutPoint_1clone(void* ctx_TODO, uint32_t orig) {
6372         LDKOutPoint orig_conv;
6373         orig_conv.inner = (void*)(orig & (~1));
6374         orig_conv.is_owned = false;
6375         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
6376         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6377         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6378         long ret_ref = (long)ret_var.inner;
6379         if (ret_var.is_owned) {
6380                 ret_ref |= 1;
6381         }
6382         return ret_ref;
6383 }
6384
6385 int8_tArray OutPoint_1get_1txid(void* ctx_TODO, uint32_t this_ptr) {
6386         LDKOutPoint this_ptr_conv;
6387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6388         this_ptr_conv.is_owned = false;
6389         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6390         memcpy(ret_arr.ptr, *OutPoint_get_txid(&this_ptr_conv), 32);
6391         return ret_arr;
6392 }
6393
6394 void OutPoint_1set_1txid(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6395         LDKOutPoint this_ptr_conv;
6396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6397         this_ptr_conv.is_owned = false;
6398         LDKThirtyTwoBytes val_ref;
6399         CHECK(val.len == 32);
6400         memcpy(val_ref.data, val.ptr, 32);
6401         OutPoint_set_txid(&this_ptr_conv, val_ref);
6402 }
6403
6404 jshort OutPoint_1get_1index(void* ctx_TODO, uint32_t this_ptr) {
6405         LDKOutPoint this_ptr_conv;
6406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6407         this_ptr_conv.is_owned = false;
6408         jshort ret_val = OutPoint_get_index(&this_ptr_conv);
6409         return ret_val;
6410 }
6411
6412 void OutPoint_1set_1index(void* ctx_TODO, uint32_t this_ptr, jshort val) {
6413         LDKOutPoint this_ptr_conv;
6414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6415         this_ptr_conv.is_owned = false;
6416         OutPoint_set_index(&this_ptr_conv, val);
6417 }
6418
6419 uint32_t OutPoint_1new(void* ctx_TODO, int8_tArray txid_arg, jshort index_arg) {
6420         LDKThirtyTwoBytes txid_arg_ref;
6421         CHECK(txid_arg.len == 32);
6422         memcpy(txid_arg_ref.data, txid_arg.ptr, 32);
6423         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
6424         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6425         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6426         long ret_ref = (long)ret_var.inner;
6427         if (ret_var.is_owned) {
6428                 ret_ref |= 1;
6429         }
6430         return ret_ref;
6431 }
6432
6433 int8_tArray OutPoint_1to_1channel_1id(void* ctx_TODO, uint32_t this_arg) {
6434         LDKOutPoint this_arg_conv;
6435         this_arg_conv.inner = (void*)(this_arg & (~1));
6436         this_arg_conv.is_owned = false;
6437         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6438         memcpy(arg_arr.ptr, OutPoint_to_channel_id(&this_arg_conv).data, 32);
6439         return arg_arr;
6440 }
6441
6442 int8_tArray OutPoint_1write(void* ctx_TODO, uint32_t obj) {
6443         LDKOutPoint obj_conv;
6444         obj_conv.inner = (void*)(obj & (~1));
6445         obj_conv.is_owned = false;
6446         LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
6447         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
6448         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
6449         CVec_u8Z_free(arg_var);
6450         return arg_arr;
6451 }
6452
6453 uint32_t OutPoint_1read(void* ctx_TODO, int8_tArray ser) {
6454         LDKu8slice ser_ref;
6455         ser_ref.datalen = ser.len;
6456         ser_ref.data = ser.ptr;
6457         LDKOutPoint ret_var = OutPoint_read(ser_ref);
6458         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6459         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6460         long ret_ref = (long)ret_var.inner;
6461         if (ret_var.is_owned) {
6462                 ret_ref |= 1;
6463         }
6464         return ret_ref;
6465 }
6466
6467 void SpendableOutputDescriptor_1free(void* ctx_TODO, uint32_t this_ptr) {
6468         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
6469         FREE((void*)this_ptr);
6470         SpendableOutputDescriptor_free(this_ptr_conv);
6471 }
6472
6473 uint32_t SpendableOutputDescriptor_1clone(void* ctx_TODO, uint32_t orig) {
6474         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
6475         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
6476         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
6477         long ret_ref = (long)ret_copy;
6478         return ret_ref;
6479 }
6480
6481 int8_tArray SpendableOutputDescriptor_1write(void* ctx_TODO, uint32_t obj) {
6482         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
6483         LDKCVec_u8Z arg_var = SpendableOutputDescriptor_write(obj_conv);
6484         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
6485         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
6486         CVec_u8Z_free(arg_var);
6487         return arg_arr;
6488 }
6489
6490 uint32_t SpendableOutputDescriptor_1read(void* ctx_TODO, int8_tArray ser) {
6491         LDKu8slice ser_ref;
6492         ser_ref.datalen = ser.len;
6493         ser_ref.data = ser.ptr;
6494         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
6495         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
6496         return (long)ret_conv;
6497 }
6498
6499 uint32_t ChannelKeys_1clone(void* ctx_TODO, uint32_t orig) {
6500         LDKChannelKeys* orig_conv = (LDKChannelKeys*)orig;
6501         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
6502         *ret = ChannelKeys_clone(orig_conv);
6503         return (long)ret;
6504 }
6505
6506 void ChannelKeys_1free(void* ctx_TODO, uint32_t this_ptr) {
6507         LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
6508         FREE((void*)this_ptr);
6509         ChannelKeys_free(this_ptr_conv);
6510 }
6511
6512 void KeysInterface_1free(void* ctx_TODO, uint32_t this_ptr) {
6513         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
6514         FREE((void*)this_ptr);
6515         KeysInterface_free(this_ptr_conv);
6516 }
6517
6518 void InMemoryChannelKeys_1free(void* ctx_TODO, uint32_t this_ptr) {
6519         LDKInMemoryChannelKeys this_ptr_conv;
6520         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6521         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6522         InMemoryChannelKeys_free(this_ptr_conv);
6523 }
6524
6525 uint32_t InMemoryChannelKeys_1clone(void* ctx_TODO, uint32_t orig) {
6526         LDKInMemoryChannelKeys orig_conv;
6527         orig_conv.inner = (void*)(orig & (~1));
6528         orig_conv.is_owned = false;
6529         LDKInMemoryChannelKeys ret_var = InMemoryChannelKeys_clone(&orig_conv);
6530         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6531         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6532         long ret_ref = (long)ret_var.inner;
6533         if (ret_var.is_owned) {
6534                 ret_ref |= 1;
6535         }
6536         return ret_ref;
6537 }
6538
6539 int8_tArray InMemoryChannelKeys_1get_1funding_1key(void* ctx_TODO, uint32_t this_ptr) {
6540         LDKInMemoryChannelKeys this_ptr_conv;
6541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6542         this_ptr_conv.is_owned = false;
6543         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6544         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_funding_key(&this_ptr_conv), 32);
6545         return ret_arr;
6546 }
6547
6548 void InMemoryChannelKeys_1set_1funding_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6549         LDKInMemoryChannelKeys this_ptr_conv;
6550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6551         this_ptr_conv.is_owned = false;
6552         LDKSecretKey val_ref;
6553         CHECK(val.len == 32);
6554         memcpy(val_ref.bytes, val.ptr, 32);
6555         InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
6556 }
6557
6558 int8_tArray InMemoryChannelKeys_1get_1revocation_1base_1key(void* ctx_TODO, uint32_t this_ptr) {
6559         LDKInMemoryChannelKeys this_ptr_conv;
6560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6561         this_ptr_conv.is_owned = false;
6562         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6563         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv), 32);
6564         return ret_arr;
6565 }
6566
6567 void InMemoryChannelKeys_1set_1revocation_1base_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6568         LDKInMemoryChannelKeys this_ptr_conv;
6569         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6570         this_ptr_conv.is_owned = false;
6571         LDKSecretKey val_ref;
6572         CHECK(val.len == 32);
6573         memcpy(val_ref.bytes, val.ptr, 32);
6574         InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
6575 }
6576
6577 int8_tArray InMemoryChannelKeys_1get_1payment_1key(void* ctx_TODO, uint32_t this_ptr) {
6578         LDKInMemoryChannelKeys this_ptr_conv;
6579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6580         this_ptr_conv.is_owned = false;
6581         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6582         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_payment_key(&this_ptr_conv), 32);
6583         return ret_arr;
6584 }
6585
6586 void InMemoryChannelKeys_1set_1payment_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6587         LDKInMemoryChannelKeys this_ptr_conv;
6588         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6589         this_ptr_conv.is_owned = false;
6590         LDKSecretKey val_ref;
6591         CHECK(val.len == 32);
6592         memcpy(val_ref.bytes, val.ptr, 32);
6593         InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
6594 }
6595
6596 int8_tArray InMemoryChannelKeys_1get_1delayed_1payment_1base_1key(void* ctx_TODO, uint32_t this_ptr) {
6597         LDKInMemoryChannelKeys this_ptr_conv;
6598         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6599         this_ptr_conv.is_owned = false;
6600         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6601         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv), 32);
6602         return ret_arr;
6603 }
6604
6605 void InMemoryChannelKeys_1set_1delayed_1payment_1base_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6606         LDKInMemoryChannelKeys this_ptr_conv;
6607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6608         this_ptr_conv.is_owned = false;
6609         LDKSecretKey val_ref;
6610         CHECK(val.len == 32);
6611         memcpy(val_ref.bytes, val.ptr, 32);
6612         InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
6613 }
6614
6615 int8_tArray InMemoryChannelKeys_1get_1htlc_1base_1key(void* ctx_TODO, uint32_t this_ptr) {
6616         LDKInMemoryChannelKeys this_ptr_conv;
6617         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6618         this_ptr_conv.is_owned = false;
6619         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6620         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv), 32);
6621         return ret_arr;
6622 }
6623
6624 void InMemoryChannelKeys_1set_1htlc_1base_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6625         LDKInMemoryChannelKeys this_ptr_conv;
6626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6627         this_ptr_conv.is_owned = false;
6628         LDKSecretKey val_ref;
6629         CHECK(val.len == 32);
6630         memcpy(val_ref.bytes, val.ptr, 32);
6631         InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
6632 }
6633
6634 int8_tArray InMemoryChannelKeys_1get_1commitment_1seed(void* ctx_TODO, uint32_t this_ptr) {
6635         LDKInMemoryChannelKeys this_ptr_conv;
6636         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6637         this_ptr_conv.is_owned = false;
6638         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6639         memcpy(ret_arr.ptr, *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv), 32);
6640         return ret_arr;
6641 }
6642
6643 void InMemoryChannelKeys_1set_1commitment_1seed(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6644         LDKInMemoryChannelKeys this_ptr_conv;
6645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6646         this_ptr_conv.is_owned = false;
6647         LDKThirtyTwoBytes val_ref;
6648         CHECK(val.len == 32);
6649         memcpy(val_ref.data, val.ptr, 32);
6650         InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
6651 }
6652
6653 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) {
6654         LDKSecretKey funding_key_ref;
6655         CHECK(funding_key.len == 32);
6656         memcpy(funding_key_ref.bytes, funding_key.ptr, 32);
6657         LDKSecretKey revocation_base_key_ref;
6658         CHECK(revocation_base_key.len == 32);
6659         memcpy(revocation_base_key_ref.bytes, revocation_base_key.ptr, 32);
6660         LDKSecretKey payment_key_ref;
6661         CHECK(payment_key.len == 32);
6662         memcpy(payment_key_ref.bytes, payment_key.ptr, 32);
6663         LDKSecretKey delayed_payment_base_key_ref;
6664         CHECK(delayed_payment_base_key.len == 32);
6665         memcpy(delayed_payment_base_key_ref.bytes, delayed_payment_base_key.ptr, 32);
6666         LDKSecretKey htlc_base_key_ref;
6667         CHECK(htlc_base_key.len == 32);
6668         memcpy(htlc_base_key_ref.bytes, htlc_base_key.ptr, 32);
6669         LDKThirtyTwoBytes commitment_seed_ref;
6670         CHECK(commitment_seed.len == 32);
6671         memcpy(commitment_seed_ref.data, commitment_seed.ptr, 32);
6672         LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
6673         FREE((void*)key_derivation_params);
6674         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);
6675         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6676         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6677         long ret_ref = (long)ret_var.inner;
6678         if (ret_var.is_owned) {
6679                 ret_ref |= 1;
6680         }
6681         return ret_ref;
6682 }
6683
6684 uint32_t InMemoryChannelKeys_1counterparty_1pubkeys(void* ctx_TODO, uint32_t this_arg) {
6685         LDKInMemoryChannelKeys this_arg_conv;
6686         this_arg_conv.inner = (void*)(this_arg & (~1));
6687         this_arg_conv.is_owned = false;
6688         LDKChannelPublicKeys ret_var = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
6689         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6690         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6691         long ret_ref = (long)ret_var.inner;
6692         if (ret_var.is_owned) {
6693                 ret_ref |= 1;
6694         }
6695         return ret_ref;
6696 }
6697
6698 jshort InMemoryChannelKeys_1counterparty_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_arg) {
6699         LDKInMemoryChannelKeys this_arg_conv;
6700         this_arg_conv.inner = (void*)(this_arg & (~1));
6701         this_arg_conv.is_owned = false;
6702         jshort ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
6703         return ret_val;
6704 }
6705
6706 jshort InMemoryChannelKeys_1holder_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_arg) {
6707         LDKInMemoryChannelKeys this_arg_conv;
6708         this_arg_conv.inner = (void*)(this_arg & (~1));
6709         this_arg_conv.is_owned = false;
6710         jshort ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
6711         return ret_val;
6712 }
6713
6714 jboolean InMemoryChannelKeys_1is_1outbound(void* ctx_TODO, uint32_t this_arg) {
6715         LDKInMemoryChannelKeys this_arg_conv;
6716         this_arg_conv.inner = (void*)(this_arg & (~1));
6717         this_arg_conv.is_owned = false;
6718         jboolean ret_val = InMemoryChannelKeys_is_outbound(&this_arg_conv);
6719         return ret_val;
6720 }
6721
6722 uint32_t InMemoryChannelKeys_1funding_1outpoint(void* ctx_TODO, uint32_t this_arg) {
6723         LDKInMemoryChannelKeys this_arg_conv;
6724         this_arg_conv.inner = (void*)(this_arg & (~1));
6725         this_arg_conv.is_owned = false;
6726         LDKOutPoint ret_var = InMemoryChannelKeys_funding_outpoint(&this_arg_conv);
6727         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6728         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6729         long ret_ref = (long)ret_var.inner;
6730         if (ret_var.is_owned) {
6731                 ret_ref |= 1;
6732         }
6733         return ret_ref;
6734 }
6735
6736 uint32_t InMemoryChannelKeys_1get_1channel_1parameters(void* ctx_TODO, uint32_t this_arg) {
6737         LDKInMemoryChannelKeys this_arg_conv;
6738         this_arg_conv.inner = (void*)(this_arg & (~1));
6739         this_arg_conv.is_owned = false;
6740         LDKChannelTransactionParameters ret_var = InMemoryChannelKeys_get_channel_parameters(&this_arg_conv);
6741         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6742         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6743         long ret_ref = (long)ret_var.inner;
6744         if (ret_var.is_owned) {
6745                 ret_ref |= 1;
6746         }
6747         return ret_ref;
6748 }
6749
6750 uint32_t InMemoryChannelKeys_1as_1ChannelKeys(void* ctx_TODO, uint32_t this_arg) {
6751         LDKInMemoryChannelKeys this_arg_conv;
6752         this_arg_conv.inner = (void*)(this_arg & (~1));
6753         this_arg_conv.is_owned = false;
6754         LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
6755         *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
6756         return (long)ret;
6757 }
6758
6759 int8_tArray InMemoryChannelKeys_1write(void* ctx_TODO, uint32_t obj) {
6760         LDKInMemoryChannelKeys obj_conv;
6761         obj_conv.inner = (void*)(obj & (~1));
6762         obj_conv.is_owned = false;
6763         LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
6764         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
6765         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
6766         CVec_u8Z_free(arg_var);
6767         return arg_arr;
6768 }
6769
6770 uint32_t InMemoryChannelKeys_1read(void* ctx_TODO, int8_tArray ser) {
6771         LDKu8slice ser_ref;
6772         ser_ref.datalen = ser.len;
6773         ser_ref.data = ser.ptr;
6774         LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
6775         *ret_conv = InMemoryChannelKeys_read(ser_ref);
6776         return (long)ret_conv;
6777 }
6778
6779 void KeysManager_1free(void* ctx_TODO, uint32_t this_ptr) {
6780         LDKKeysManager this_ptr_conv;
6781         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6782         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6783         KeysManager_free(this_ptr_conv);
6784 }
6785
6786 uint32_t KeysManager_1new(void* ctx_TODO, int8_tArray seed, uint32_t network, int64_t starting_time_secs, int32_t starting_time_nanos) {
6787         unsigned char seed_arr[32];
6788         CHECK(seed.len == 32);
6789         memcpy(seed_arr, seed.ptr, 32);
6790         unsigned char (*seed_ref)[32] = &seed_arr;
6791         LDKNetwork network_conv = LDKNetwork_from_js(network);
6792         LDKKeysManager ret_var = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
6793         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6794         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6795         long ret_ref = (long)ret_var.inner;
6796         if (ret_var.is_owned) {
6797                 ret_ref |= 1;
6798         }
6799         return ret_ref;
6800 }
6801
6802 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) {
6803         LDKKeysManager this_arg_conv;
6804         this_arg_conv.inner = (void*)(this_arg & (~1));
6805         this_arg_conv.is_owned = false;
6806         LDKInMemoryChannelKeys ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
6807         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6808         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6809         long ret_ref = (long)ret_var.inner;
6810         if (ret_var.is_owned) {
6811                 ret_ref |= 1;
6812         }
6813         return ret_ref;
6814 }
6815
6816 uint32_t KeysManager_1as_1KeysInterface(void* ctx_TODO, uint32_t this_arg) {
6817         LDKKeysManager this_arg_conv;
6818         this_arg_conv.inner = (void*)(this_arg & (~1));
6819         this_arg_conv.is_owned = false;
6820         LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
6821         *ret = KeysManager_as_KeysInterface(&this_arg_conv);
6822         return (long)ret;
6823 }
6824
6825 void ChannelManager_1free(void* ctx_TODO, uint32_t this_ptr) {
6826         LDKChannelManager this_ptr_conv;
6827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6828         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6829         ChannelManager_free(this_ptr_conv);
6830 }
6831
6832 void ChannelDetails_1free(void* ctx_TODO, uint32_t this_ptr) {
6833         LDKChannelDetails this_ptr_conv;
6834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6835         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6836         ChannelDetails_free(this_ptr_conv);
6837 }
6838
6839 uint32_t ChannelDetails_1clone(void* ctx_TODO, uint32_t orig) {
6840         LDKChannelDetails orig_conv;
6841         orig_conv.inner = (void*)(orig & (~1));
6842         orig_conv.is_owned = false;
6843         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
6844         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6845         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6846         long ret_ref = (long)ret_var.inner;
6847         if (ret_var.is_owned) {
6848                 ret_ref |= 1;
6849         }
6850         return ret_ref;
6851 }
6852
6853 int8_tArray ChannelDetails_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
6854         LDKChannelDetails this_ptr_conv;
6855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6856         this_ptr_conv.is_owned = false;
6857         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
6858         memcpy(ret_arr.ptr, *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
6859         return ret_arr;
6860 }
6861
6862 void ChannelDetails_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6863         LDKChannelDetails this_ptr_conv;
6864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6865         this_ptr_conv.is_owned = false;
6866         LDKThirtyTwoBytes val_ref;
6867         CHECK(val.len == 32);
6868         memcpy(val_ref.data, val.ptr, 32);
6869         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
6870 }
6871
6872 int8_tArray ChannelDetails_1get_1remote_1network_1id(void* ctx_TODO, uint32_t this_ptr) {
6873         LDKChannelDetails this_ptr_conv;
6874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6875         this_ptr_conv.is_owned = false;
6876         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
6877         memcpy(arg_arr.ptr, ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
6878         return arg_arr;
6879 }
6880
6881 void ChannelDetails_1set_1remote_1network_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
6882         LDKChannelDetails this_ptr_conv;
6883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6884         this_ptr_conv.is_owned = false;
6885         LDKPublicKey val_ref;
6886         CHECK(val.len == 33);
6887         memcpy(val_ref.compressed_form, val.ptr, 33);
6888         ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
6889 }
6890
6891 uint32_t ChannelDetails_1get_1counterparty_1features(void* ctx_TODO, uint32_t this_ptr) {
6892         LDKChannelDetails this_ptr_conv;
6893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6894         this_ptr_conv.is_owned = false;
6895         LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
6896         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6897         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6898         long ret_ref = (long)ret_var.inner;
6899         if (ret_var.is_owned) {
6900                 ret_ref |= 1;
6901         }
6902         return ret_ref;
6903 }
6904
6905 void ChannelDetails_1set_1counterparty_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
6906         LDKChannelDetails this_ptr_conv;
6907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6908         this_ptr_conv.is_owned = false;
6909         LDKInitFeatures val_conv;
6910         val_conv.inner = (void*)(val & (~1));
6911         val_conv.is_owned = (val & 1) || (val == 0);
6912         // Warning: we may need a move here but can't clone!
6913         ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
6914 }
6915
6916 int64_t ChannelDetails_1get_1channel_1value_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
6917         LDKChannelDetails this_ptr_conv;
6918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6919         this_ptr_conv.is_owned = false;
6920         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
6921         return ret_val;
6922 }
6923
6924 void ChannelDetails_1set_1channel_1value_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6925         LDKChannelDetails this_ptr_conv;
6926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6927         this_ptr_conv.is_owned = false;
6928         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
6929 }
6930
6931 int64_t ChannelDetails_1get_1user_1id(void* ctx_TODO, uint32_t this_ptr) {
6932         LDKChannelDetails this_ptr_conv;
6933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6934         this_ptr_conv.is_owned = false;
6935         int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
6936         return ret_val;
6937 }
6938
6939 void ChannelDetails_1set_1user_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6940         LDKChannelDetails this_ptr_conv;
6941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6942         this_ptr_conv.is_owned = false;
6943         ChannelDetails_set_user_id(&this_ptr_conv, val);
6944 }
6945
6946 int64_t ChannelDetails_1get_1outbound_1capacity_1msat(void* ctx_TODO, uint32_t this_ptr) {
6947         LDKChannelDetails this_ptr_conv;
6948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6949         this_ptr_conv.is_owned = false;
6950         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
6951         return ret_val;
6952 }
6953
6954 void ChannelDetails_1set_1outbound_1capacity_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6955         LDKChannelDetails this_ptr_conv;
6956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6957         this_ptr_conv.is_owned = false;
6958         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
6959 }
6960
6961 int64_t ChannelDetails_1get_1inbound_1capacity_1msat(void* ctx_TODO, uint32_t this_ptr) {
6962         LDKChannelDetails this_ptr_conv;
6963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6964         this_ptr_conv.is_owned = false;
6965         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
6966         return ret_val;
6967 }
6968
6969 void ChannelDetails_1set_1inbound_1capacity_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
6970         LDKChannelDetails this_ptr_conv;
6971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6972         this_ptr_conv.is_owned = false;
6973         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
6974 }
6975
6976 jboolean ChannelDetails_1get_1is_1live(void* ctx_TODO, uint32_t this_ptr) {
6977         LDKChannelDetails this_ptr_conv;
6978         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6979         this_ptr_conv.is_owned = false;
6980         jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
6981         return ret_val;
6982 }
6983
6984 void ChannelDetails_1set_1is_1live(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
6985         LDKChannelDetails this_ptr_conv;
6986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6987         this_ptr_conv.is_owned = false;
6988         ChannelDetails_set_is_live(&this_ptr_conv, val);
6989 }
6990
6991 void PaymentSendFailure_1free(void* ctx_TODO, uint32_t this_ptr) {
6992         LDKPaymentSendFailure this_ptr_conv;
6993         this_ptr_conv.inner = (void*)(this_ptr & (~1));
6994         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6995         PaymentSendFailure_free(this_ptr_conv);
6996 }
6997
6998 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) {
6999         LDKNetwork network_conv = LDKNetwork_from_js(network);
7000         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
7001         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
7002                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7003                 LDKFeeEstimator_JCalls_clone(fee_est_conv.this_arg);
7004         }
7005         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
7006         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
7007                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7008                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
7009         }
7010         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
7011         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
7012                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7013                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
7014         }
7015         LDKLogger logger_conv = *(LDKLogger*)logger;
7016         if (logger_conv.free == LDKLogger_JCalls_free) {
7017                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7018                 LDKLogger_JCalls_clone(logger_conv.this_arg);
7019         }
7020         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
7021         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
7022                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7023                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
7024         }
7025         LDKUserConfig config_conv;
7026         config_conv.inner = (void*)(config & (~1));
7027         config_conv.is_owned = (config & 1) || (config == 0);
7028         if (config_conv.inner != NULL)
7029                 config_conv = UserConfig_clone(&config_conv);
7030         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);
7031         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7032         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7033         long ret_ref = (long)ret_var.inner;
7034         if (ret_var.is_owned) {
7035                 ret_ref |= 1;
7036         }
7037         return ret_ref;
7038 }
7039
7040 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) {
7041         LDKChannelManager this_arg_conv;
7042         this_arg_conv.inner = (void*)(this_arg & (~1));
7043         this_arg_conv.is_owned = false;
7044         LDKPublicKey their_network_key_ref;
7045         CHECK(their_network_key.len == 33);
7046         memcpy(their_network_key_ref.compressed_form, their_network_key.ptr, 33);
7047         LDKUserConfig override_config_conv;
7048         override_config_conv.inner = (void*)(override_config & (~1));
7049         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
7050         if (override_config_conv.inner != NULL)
7051                 override_config_conv = UserConfig_clone(&override_config_conv);
7052         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7053         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
7054         return (long)ret_conv;
7055 }
7056
7057 uint32_tArray ChannelManager_1list_1channels(void* ctx_TODO, uint32_t this_arg) {
7058         LDKChannelManager this_arg_conv;
7059         this_arg_conv.inner = (void*)(this_arg & (~1));
7060         this_arg_conv.is_owned = false;
7061         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
7062         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
7063         uint32_t *ret_arr_ptr = ret_arr.ptr;
7064         for (size_t q = 0; q < ret_var.datalen; q++) {
7065                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
7066                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7067                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7068                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
7069                 if (arr_conv_16_var.is_owned) {
7070                         arr_conv_16_ref |= 1;
7071                 }
7072                 ret_arr_ptr[q] = arr_conv_16_ref;
7073         }
7074         FREE(ret_var.data);
7075         return ret_arr;
7076 }
7077
7078 uint32_tArray ChannelManager_1list_1usable_1channels(void* ctx_TODO, uint32_t this_arg) {
7079         LDKChannelManager this_arg_conv;
7080         this_arg_conv.inner = (void*)(this_arg & (~1));
7081         this_arg_conv.is_owned = false;
7082         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
7083         uint32_tArray ret_arr = { .len = ret_var.datalen, .ptr = MALLOC(ret_var.datalen * sizeof(int32_t), "Native uint32_tArray Bytes") };
7084         uint32_t *ret_arr_ptr = ret_arr.ptr;
7085         for (size_t q = 0; q < ret_var.datalen; q++) {
7086                 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
7087                 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7088                 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7089                 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
7090                 if (arr_conv_16_var.is_owned) {
7091                         arr_conv_16_ref |= 1;
7092                 }
7093                 ret_arr_ptr[q] = arr_conv_16_ref;
7094         }
7095         FREE(ret_var.data);
7096         return ret_arr;
7097 }
7098
7099 uint32_t ChannelManager_1close_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray channel_id) {
7100         LDKChannelManager this_arg_conv;
7101         this_arg_conv.inner = (void*)(this_arg & (~1));
7102         this_arg_conv.is_owned = false;
7103         unsigned char channel_id_arr[32];
7104         CHECK(channel_id.len == 32);
7105         memcpy(channel_id_arr, channel_id.ptr, 32);
7106         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
7107         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7108         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
7109         return (long)ret_conv;
7110 }
7111
7112 void ChannelManager_1force_1close_1channel(void* ctx_TODO, uint32_t this_arg, int8_tArray channel_id) {
7113         LDKChannelManager this_arg_conv;
7114         this_arg_conv.inner = (void*)(this_arg & (~1));
7115         this_arg_conv.is_owned = false;
7116         unsigned char channel_id_arr[32];
7117         CHECK(channel_id.len == 32);
7118         memcpy(channel_id_arr, channel_id.ptr, 32);
7119         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
7120         ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
7121 }
7122
7123 void ChannelManager_1force_1close_1all_1channels(void* ctx_TODO, uint32_t this_arg) {
7124         LDKChannelManager this_arg_conv;
7125         this_arg_conv.inner = (void*)(this_arg & (~1));
7126         this_arg_conv.is_owned = false;
7127         ChannelManager_force_close_all_channels(&this_arg_conv);
7128 }
7129
7130 uint32_t ChannelManager_1send_1payment(void* ctx_TODO, uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
7131         LDKChannelManager this_arg_conv;
7132         this_arg_conv.inner = (void*)(this_arg & (~1));
7133         this_arg_conv.is_owned = false;
7134         LDKRoute route_conv;
7135         route_conv.inner = (void*)(route & (~1));
7136         route_conv.is_owned = false;
7137         LDKThirtyTwoBytes payment_hash_ref;
7138         CHECK(payment_hash.len == 32);
7139         memcpy(payment_hash_ref.data, payment_hash.ptr, 32);
7140         LDKThirtyTwoBytes payment_secret_ref;
7141         CHECK(payment_secret.len == 32);
7142         memcpy(payment_secret_ref.data, payment_secret.ptr, 32);
7143         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
7144         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
7145         return (long)ret_conv;
7146 }
7147
7148 void ChannelManager_1funding_1transaction_1generated(void* ctx_TODO, uint32_t this_arg, int8_tArray temporary_channel_id, uint32_t funding_txo) {
7149         LDKChannelManager this_arg_conv;
7150         this_arg_conv.inner = (void*)(this_arg & (~1));
7151         this_arg_conv.is_owned = false;
7152         unsigned char temporary_channel_id_arr[32];
7153         CHECK(temporary_channel_id.len == 32);
7154         memcpy(temporary_channel_id_arr, temporary_channel_id.ptr, 32);
7155         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
7156         LDKOutPoint funding_txo_conv;
7157         funding_txo_conv.inner = (void*)(funding_txo & (~1));
7158         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
7159         if (funding_txo_conv.inner != NULL)
7160                 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7161         ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
7162 }
7163
7164 void ChannelManager_1broadcast_1node_1announcement(void* ctx_TODO, uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
7165         LDKChannelManager this_arg_conv;
7166         this_arg_conv.inner = (void*)(this_arg & (~1));
7167         this_arg_conv.is_owned = false;
7168         LDKThreeBytes rgb_ref;
7169         CHECK(rgb.len == 3);
7170         memcpy(rgb_ref.data, rgb.ptr, 3);
7171         LDKThirtyTwoBytes alias_ref;
7172         CHECK(alias.len == 32);
7173         memcpy(alias_ref.data, alias.ptr, 32);
7174         LDKCVec_NetAddressZ addresses_constr;
7175         addresses_constr.datalen = addresses.len;
7176         if (addresses_constr.datalen > 0)
7177                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
7178         else
7179                 addresses_constr.data = NULL;
7180         uint32_t* addresses_vals = (uint32_t*) addresses.ptr;
7181         for (size_t m = 0; m < addresses_constr.datalen; m++) {
7182                 uint32_t arr_conv_12 = addresses_vals[m];
7183                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
7184                 FREE((void*)arr_conv_12);
7185                 addresses_constr.data[m] = arr_conv_12_conv;
7186         }
7187         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
7188 }
7189
7190 void ChannelManager_1process_1pending_1htlc_1forwards(void* ctx_TODO, uint32_t this_arg) {
7191         LDKChannelManager this_arg_conv;
7192         this_arg_conv.inner = (void*)(this_arg & (~1));
7193         this_arg_conv.is_owned = false;
7194         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
7195 }
7196
7197 void ChannelManager_1timer_1chan_1freshness_1every_1min(void* ctx_TODO, uint32_t this_arg) {
7198         LDKChannelManager this_arg_conv;
7199         this_arg_conv.inner = (void*)(this_arg & (~1));
7200         this_arg_conv.is_owned = false;
7201         ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
7202 }
7203
7204 jboolean ChannelManager_1fail_1htlc_1backwards(void* ctx_TODO, uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
7205         LDKChannelManager this_arg_conv;
7206         this_arg_conv.inner = (void*)(this_arg & (~1));
7207         this_arg_conv.is_owned = false;
7208         unsigned char payment_hash_arr[32];
7209         CHECK(payment_hash.len == 32);
7210         memcpy(payment_hash_arr, payment_hash.ptr, 32);
7211         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
7212         LDKThirtyTwoBytes payment_secret_ref;
7213         CHECK(payment_secret.len == 32);
7214         memcpy(payment_secret_ref.data, payment_secret.ptr, 32);
7215         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
7216         return ret_val;
7217 }
7218
7219 jboolean ChannelManager_1claim_1funds(void* ctx_TODO, uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
7220         LDKChannelManager this_arg_conv;
7221         this_arg_conv.inner = (void*)(this_arg & (~1));
7222         this_arg_conv.is_owned = false;
7223         LDKThirtyTwoBytes payment_preimage_ref;
7224         CHECK(payment_preimage.len == 32);
7225         memcpy(payment_preimage_ref.data, payment_preimage.ptr, 32);
7226         LDKThirtyTwoBytes payment_secret_ref;
7227         CHECK(payment_secret.len == 32);
7228         memcpy(payment_secret_ref.data, payment_secret.ptr, 32);
7229         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
7230         return ret_val;
7231 }
7232
7233 int8_tArray ChannelManager_1get_1our_1node_1id(void* ctx_TODO, uint32_t this_arg) {
7234         LDKChannelManager this_arg_conv;
7235         this_arg_conv.inner = (void*)(this_arg & (~1));
7236         this_arg_conv.is_owned = false;
7237         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7238         memcpy(arg_arr.ptr, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
7239         return arg_arr;
7240 }
7241
7242 void ChannelManager_1channel_1monitor_1updated(void* ctx_TODO, uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
7243         LDKChannelManager this_arg_conv;
7244         this_arg_conv.inner = (void*)(this_arg & (~1));
7245         this_arg_conv.is_owned = false;
7246         LDKOutPoint funding_txo_conv;
7247         funding_txo_conv.inner = (void*)(funding_txo & (~1));
7248         funding_txo_conv.is_owned = false;
7249         ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
7250 }
7251
7252 uint32_t ChannelManager_1as_1MessageSendEventsProvider(void* ctx_TODO, uint32_t this_arg) {
7253         LDKChannelManager this_arg_conv;
7254         this_arg_conv.inner = (void*)(this_arg & (~1));
7255         this_arg_conv.is_owned = false;
7256         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7257         *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
7258         return (long)ret;
7259 }
7260
7261 uint32_t ChannelManager_1as_1EventsProvider(void* ctx_TODO, uint32_t this_arg) {
7262         LDKChannelManager this_arg_conv;
7263         this_arg_conv.inner = (void*)(this_arg & (~1));
7264         this_arg_conv.is_owned = false;
7265         LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7266         *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
7267         return (long)ret;
7268 }
7269
7270 void ChannelManager_1block_1connected(void* ctx_TODO, uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
7271         LDKChannelManager this_arg_conv;
7272         this_arg_conv.inner = (void*)(this_arg & (~1));
7273         this_arg_conv.is_owned = false;
7274         unsigned char header_arr[80];
7275         CHECK(header.len == 80);
7276         memcpy(header_arr, header.ptr, 80);
7277         unsigned char (*header_ref)[80] = &header_arr;
7278         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7279         txdata_constr.datalen = txdata.len;
7280         if (txdata_constr.datalen > 0)
7281                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7282         else
7283                 txdata_constr.data = NULL;
7284         uint32_t* txdata_vals = (uint32_t*) txdata.ptr;
7285         for (size_t y = 0; y < txdata_constr.datalen; y++) {
7286                 uint32_t arr_conv_24 = txdata_vals[y];
7287                 LDKC2Tuple_usizeTransactionZ arr_conv_24_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_24;
7288                 FREE((void*)arr_conv_24);
7289                 txdata_constr.data[y] = arr_conv_24_conv;
7290         }
7291         ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
7292 }
7293
7294 void ChannelManager_1block_1disconnected(void* ctx_TODO, uint32_t this_arg, int8_tArray header) {
7295         LDKChannelManager this_arg_conv;
7296         this_arg_conv.inner = (void*)(this_arg & (~1));
7297         this_arg_conv.is_owned = false;
7298         unsigned char header_arr[80];
7299         CHECK(header.len == 80);
7300         memcpy(header_arr, header.ptr, 80);
7301         unsigned char (*header_ref)[80] = &header_arr;
7302         ChannelManager_block_disconnected(&this_arg_conv, header_ref);
7303 }
7304
7305 uint32_t ChannelManager_1as_1ChannelMessageHandler(void* ctx_TODO, uint32_t this_arg) {
7306         LDKChannelManager this_arg_conv;
7307         this_arg_conv.inner = (void*)(this_arg & (~1));
7308         this_arg_conv.is_owned = false;
7309         LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
7310         *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
7311         return (long)ret;
7312 }
7313
7314 int8_tArray ChannelManager_1write(void* ctx_TODO, uint32_t obj) {
7315         LDKChannelManager obj_conv;
7316         obj_conv.inner = (void*)(obj & (~1));
7317         obj_conv.is_owned = false;
7318         LDKCVec_u8Z arg_var = ChannelManager_write(&obj_conv);
7319         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
7320         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
7321         CVec_u8Z_free(arg_var);
7322         return arg_arr;
7323 }
7324
7325 void ChannelManagerReadArgs_1free(void* ctx_TODO, uint32_t this_ptr) {
7326         LDKChannelManagerReadArgs this_ptr_conv;
7327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7328         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7329         ChannelManagerReadArgs_free(this_ptr_conv);
7330 }
7331
7332 uint32_t ChannelManagerReadArgs_1get_1keys_1manager(void* ctx_TODO, uint32_t this_ptr) {
7333         LDKChannelManagerReadArgs this_ptr_conv;
7334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7335         this_ptr_conv.is_owned = false;
7336         long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
7337         return ret_ret;
7338 }
7339
7340 void ChannelManagerReadArgs_1set_1keys_1manager(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
7341         LDKChannelManagerReadArgs this_ptr_conv;
7342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7343         this_ptr_conv.is_owned = false;
7344         LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
7345         if (val_conv.free == LDKKeysInterface_JCalls_free) {
7346                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7347                 LDKKeysInterface_JCalls_clone(val_conv.this_arg);
7348         }
7349         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
7350 }
7351
7352 uint32_t ChannelManagerReadArgs_1get_1fee_1estimator(void* ctx_TODO, uint32_t this_ptr) {
7353         LDKChannelManagerReadArgs this_ptr_conv;
7354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7355         this_ptr_conv.is_owned = false;
7356         long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
7357         return ret_ret;
7358 }
7359
7360 void ChannelManagerReadArgs_1set_1fee_1estimator(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
7361         LDKChannelManagerReadArgs this_ptr_conv;
7362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7363         this_ptr_conv.is_owned = false;
7364         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
7365         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
7366                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7367                 LDKFeeEstimator_JCalls_clone(val_conv.this_arg);
7368         }
7369         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
7370 }
7371
7372 uint32_t ChannelManagerReadArgs_1get_1chain_1monitor(void* ctx_TODO, uint32_t this_ptr) {
7373         LDKChannelManagerReadArgs this_ptr_conv;
7374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7375         this_ptr_conv.is_owned = false;
7376         long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
7377         return ret_ret;
7378 }
7379
7380 void ChannelManagerReadArgs_1set_1chain_1monitor(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
7381         LDKChannelManagerReadArgs this_ptr_conv;
7382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7383         this_ptr_conv.is_owned = false;
7384         LDKWatch val_conv = *(LDKWatch*)val;
7385         if (val_conv.free == LDKWatch_JCalls_free) {
7386                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7387                 LDKWatch_JCalls_clone(val_conv.this_arg);
7388         }
7389         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
7390 }
7391
7392 uint32_t ChannelManagerReadArgs_1get_1tx_1broadcaster(void* ctx_TODO, uint32_t this_ptr) {
7393         LDKChannelManagerReadArgs this_ptr_conv;
7394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7395         this_ptr_conv.is_owned = false;
7396         long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
7397         return ret_ret;
7398 }
7399
7400 void ChannelManagerReadArgs_1set_1tx_1broadcaster(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
7401         LDKChannelManagerReadArgs this_ptr_conv;
7402         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7403         this_ptr_conv.is_owned = false;
7404         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
7405         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
7406                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7407                 LDKBroadcasterInterface_JCalls_clone(val_conv.this_arg);
7408         }
7409         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
7410 }
7411
7412 uint32_t ChannelManagerReadArgs_1get_1logger(void* ctx_TODO, uint32_t this_ptr) {
7413         LDKChannelManagerReadArgs this_ptr_conv;
7414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7415         this_ptr_conv.is_owned = false;
7416         long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
7417         return ret_ret;
7418 }
7419
7420 void ChannelManagerReadArgs_1set_1logger(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
7421         LDKChannelManagerReadArgs this_ptr_conv;
7422         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7423         this_ptr_conv.is_owned = false;
7424         LDKLogger val_conv = *(LDKLogger*)val;
7425         if (val_conv.free == LDKLogger_JCalls_free) {
7426                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7427                 LDKLogger_JCalls_clone(val_conv.this_arg);
7428         }
7429         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
7430 }
7431
7432 uint32_t ChannelManagerReadArgs_1get_1default_1config(void* ctx_TODO, uint32_t this_ptr) {
7433         LDKChannelManagerReadArgs this_ptr_conv;
7434         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7435         this_ptr_conv.is_owned = false;
7436         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
7437         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7438         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7439         long ret_ref = (long)ret_var.inner;
7440         if (ret_var.is_owned) {
7441                 ret_ref |= 1;
7442         }
7443         return ret_ref;
7444 }
7445
7446 void ChannelManagerReadArgs_1set_1default_1config(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
7447         LDKChannelManagerReadArgs this_ptr_conv;
7448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7449         this_ptr_conv.is_owned = false;
7450         LDKUserConfig val_conv;
7451         val_conv.inner = (void*)(val & (~1));
7452         val_conv.is_owned = (val & 1) || (val == 0);
7453         if (val_conv.inner != NULL)
7454                 val_conv = UserConfig_clone(&val_conv);
7455         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
7456 }
7457
7458 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) {
7459         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
7460         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
7461                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7462                 LDKKeysInterface_JCalls_clone(keys_manager_conv.this_arg);
7463         }
7464         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
7465         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
7466                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7467                 LDKFeeEstimator_JCalls_clone(fee_estimator_conv.this_arg);
7468         }
7469         LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
7470         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
7471                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7472                 LDKWatch_JCalls_clone(chain_monitor_conv.this_arg);
7473         }
7474         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
7475         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
7476                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7477                 LDKBroadcasterInterface_JCalls_clone(tx_broadcaster_conv.this_arg);
7478         }
7479         LDKLogger logger_conv = *(LDKLogger*)logger;
7480         if (logger_conv.free == LDKLogger_JCalls_free) {
7481                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7482                 LDKLogger_JCalls_clone(logger_conv.this_arg);
7483         }
7484         LDKUserConfig default_config_conv;
7485         default_config_conv.inner = (void*)(default_config & (~1));
7486         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
7487         if (default_config_conv.inner != NULL)
7488                 default_config_conv = UserConfig_clone(&default_config_conv);
7489         LDKCVec_ChannelMonitorZ channel_monitors_constr;
7490         channel_monitors_constr.datalen = channel_monitors.len;
7491         if (channel_monitors_constr.datalen > 0)
7492                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
7493         else
7494                 channel_monitors_constr.data = NULL;
7495         uint32_t* channel_monitors_vals = (uint32_t*) channel_monitors.ptr;
7496         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
7497                 uint32_t arr_conv_16 = channel_monitors_vals[q];
7498                 LDKChannelMonitor arr_conv_16_conv;
7499                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
7500                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
7501                 // Warning: we may need a move here but can't clone!
7502                 channel_monitors_constr.data[q] = arr_conv_16_conv;
7503         }
7504         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);
7505         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7506         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7507         long ret_ref = (long)ret_var.inner;
7508         if (ret_var.is_owned) {
7509                 ret_ref |= 1;
7510         }
7511         return ret_ref;
7512 }
7513
7514 uint32_t C2Tuple_1BlockHashChannelManagerZ_1read(void* ctx_TODO, int8_tArray ser, uint32_t arg) {
7515         LDKu8slice ser_ref;
7516         ser_ref.datalen = ser.len;
7517         ser_ref.data = ser.ptr;
7518         LDKChannelManagerReadArgs arg_conv;
7519         arg_conv.inner = (void*)(arg & (~1));
7520         arg_conv.is_owned = (arg & 1) || (arg == 0);
7521         // Warning: we may need a move here but can't clone!
7522         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
7523         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
7524         return (long)ret_conv;
7525 }
7526
7527 void DecodeError_1free(void* ctx_TODO, uint32_t this_ptr) {
7528         LDKDecodeError this_ptr_conv;
7529         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7530         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7531         DecodeError_free(this_ptr_conv);
7532 }
7533
7534 void Init_1free(void* ctx_TODO, uint32_t this_ptr) {
7535         LDKInit this_ptr_conv;
7536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7537         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7538         Init_free(this_ptr_conv);
7539 }
7540
7541 uint32_t Init_1clone(void* ctx_TODO, uint32_t orig) {
7542         LDKInit orig_conv;
7543         orig_conv.inner = (void*)(orig & (~1));
7544         orig_conv.is_owned = false;
7545         LDKInit ret_var = Init_clone(&orig_conv);
7546         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7547         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7548         long ret_ref = (long)ret_var.inner;
7549         if (ret_var.is_owned) {
7550                 ret_ref |= 1;
7551         }
7552         return ret_ref;
7553 }
7554
7555 void ErrorMessage_1free(void* ctx_TODO, uint32_t this_ptr) {
7556         LDKErrorMessage this_ptr_conv;
7557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7558         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7559         ErrorMessage_free(this_ptr_conv);
7560 }
7561
7562 uint32_t ErrorMessage_1clone(void* ctx_TODO, uint32_t orig) {
7563         LDKErrorMessage orig_conv;
7564         orig_conv.inner = (void*)(orig & (~1));
7565         orig_conv.is_owned = false;
7566         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
7567         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7568         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7569         long ret_ref = (long)ret_var.inner;
7570         if (ret_var.is_owned) {
7571                 ret_ref |= 1;
7572         }
7573         return ret_ref;
7574 }
7575
7576 int8_tArray ErrorMessage_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
7577         LDKErrorMessage this_ptr_conv;
7578         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7579         this_ptr_conv.is_owned = false;
7580         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7581         memcpy(ret_arr.ptr, *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
7582         return ret_arr;
7583 }
7584
7585 void ErrorMessage_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7586         LDKErrorMessage this_ptr_conv;
7587         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7588         this_ptr_conv.is_owned = false;
7589         LDKThirtyTwoBytes val_ref;
7590         CHECK(val.len == 32);
7591         memcpy(val_ref.data, val.ptr, 32);
7592         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
7593 }
7594
7595 jstring ErrorMessage_1get_1data(void* ctx_TODO, uint32_t this_ptr) {
7596         LDKErrorMessage this_ptr_conv;
7597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7598         this_ptr_conv.is_owned = false;
7599         LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
7600         char* _buf = MALLOC(_str.len + 1, "str conv buf");
7601         memcpy(_buf, _str.chars, _str.len);
7602         _buf[_str.len] = 0;
7603         jstring _conv = (*env)->NewStringUTF(env, _str.chars);
7604         FREE(_buf);
7605         return _conv;
7606 }
7607
7608 void ErrorMessage_1set_1data(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7609         LDKErrorMessage this_ptr_conv;
7610         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7611         this_ptr_conv.is_owned = false;
7612         LDKCVec_u8Z val_ref;
7613         val_ref.datalen = val.len;
7614         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
7615         memcpy(val_ref.data, val.ptr, val_ref.datalen);
7616         ErrorMessage_set_data(&this_ptr_conv, val_ref);
7617 }
7618
7619 uint32_t ErrorMessage_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray data_arg) {
7620         LDKThirtyTwoBytes channel_id_arg_ref;
7621         CHECK(channel_id_arg.len == 32);
7622         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
7623         LDKCVec_u8Z data_arg_ref;
7624         data_arg_ref.datalen = data_arg.len;
7625         data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
7626         memcpy(data_arg_ref.data, data_arg.ptr, data_arg_ref.datalen);
7627         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
7628         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7629         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7630         long ret_ref = (long)ret_var.inner;
7631         if (ret_var.is_owned) {
7632                 ret_ref |= 1;
7633         }
7634         return ret_ref;
7635 }
7636
7637 void Ping_1free(void* ctx_TODO, uint32_t this_ptr) {
7638         LDKPing this_ptr_conv;
7639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7640         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7641         Ping_free(this_ptr_conv);
7642 }
7643
7644 uint32_t Ping_1clone(void* ctx_TODO, uint32_t orig) {
7645         LDKPing orig_conv;
7646         orig_conv.inner = (void*)(orig & (~1));
7647         orig_conv.is_owned = false;
7648         LDKPing ret_var = Ping_clone(&orig_conv);
7649         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7650         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7651         long ret_ref = (long)ret_var.inner;
7652         if (ret_var.is_owned) {
7653                 ret_ref |= 1;
7654         }
7655         return ret_ref;
7656 }
7657
7658 jshort Ping_1get_1ponglen(void* ctx_TODO, uint32_t this_ptr) {
7659         LDKPing this_ptr_conv;
7660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7661         this_ptr_conv.is_owned = false;
7662         jshort ret_val = Ping_get_ponglen(&this_ptr_conv);
7663         return ret_val;
7664 }
7665
7666 void Ping_1set_1ponglen(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7667         LDKPing this_ptr_conv;
7668         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7669         this_ptr_conv.is_owned = false;
7670         Ping_set_ponglen(&this_ptr_conv, val);
7671 }
7672
7673 jshort Ping_1get_1byteslen(void* ctx_TODO, uint32_t this_ptr) {
7674         LDKPing this_ptr_conv;
7675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7676         this_ptr_conv.is_owned = false;
7677         jshort ret_val = Ping_get_byteslen(&this_ptr_conv);
7678         return ret_val;
7679 }
7680
7681 void Ping_1set_1byteslen(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7682         LDKPing this_ptr_conv;
7683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7684         this_ptr_conv.is_owned = false;
7685         Ping_set_byteslen(&this_ptr_conv, val);
7686 }
7687
7688 uint32_t Ping_1new(void* ctx_TODO, jshort ponglen_arg, jshort byteslen_arg) {
7689         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
7690         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7691         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7692         long ret_ref = (long)ret_var.inner;
7693         if (ret_var.is_owned) {
7694                 ret_ref |= 1;
7695         }
7696         return ret_ref;
7697 }
7698
7699 void Pong_1free(void* ctx_TODO, uint32_t this_ptr) {
7700         LDKPong this_ptr_conv;
7701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7702         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7703         Pong_free(this_ptr_conv);
7704 }
7705
7706 uint32_t Pong_1clone(void* ctx_TODO, uint32_t orig) {
7707         LDKPong orig_conv;
7708         orig_conv.inner = (void*)(orig & (~1));
7709         orig_conv.is_owned = false;
7710         LDKPong ret_var = Pong_clone(&orig_conv);
7711         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7712         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7713         long ret_ref = (long)ret_var.inner;
7714         if (ret_var.is_owned) {
7715                 ret_ref |= 1;
7716         }
7717         return ret_ref;
7718 }
7719
7720 jshort Pong_1get_1byteslen(void* ctx_TODO, uint32_t this_ptr) {
7721         LDKPong this_ptr_conv;
7722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7723         this_ptr_conv.is_owned = false;
7724         jshort ret_val = Pong_get_byteslen(&this_ptr_conv);
7725         return ret_val;
7726 }
7727
7728 void Pong_1set_1byteslen(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7729         LDKPong this_ptr_conv;
7730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7731         this_ptr_conv.is_owned = false;
7732         Pong_set_byteslen(&this_ptr_conv, val);
7733 }
7734
7735 uint32_t Pong_1new(void* ctx_TODO, jshort byteslen_arg) {
7736         LDKPong ret_var = Pong_new(byteslen_arg);
7737         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7738         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7739         long ret_ref = (long)ret_var.inner;
7740         if (ret_var.is_owned) {
7741                 ret_ref |= 1;
7742         }
7743         return ret_ref;
7744 }
7745
7746 void OpenChannel_1free(void* ctx_TODO, uint32_t this_ptr) {
7747         LDKOpenChannel this_ptr_conv;
7748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7749         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7750         OpenChannel_free(this_ptr_conv);
7751 }
7752
7753 uint32_t OpenChannel_1clone(void* ctx_TODO, uint32_t orig) {
7754         LDKOpenChannel orig_conv;
7755         orig_conv.inner = (void*)(orig & (~1));
7756         orig_conv.is_owned = false;
7757         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
7758         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7759         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7760         long ret_ref = (long)ret_var.inner;
7761         if (ret_var.is_owned) {
7762                 ret_ref |= 1;
7763         }
7764         return ret_ref;
7765 }
7766
7767 int8_tArray OpenChannel_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
7768         LDKOpenChannel this_ptr_conv;
7769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7770         this_ptr_conv.is_owned = false;
7771         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7772         memcpy(ret_arr.ptr, *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
7773         return ret_arr;
7774 }
7775
7776 void OpenChannel_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7777         LDKOpenChannel this_ptr_conv;
7778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7779         this_ptr_conv.is_owned = false;
7780         LDKThirtyTwoBytes val_ref;
7781         CHECK(val.len == 32);
7782         memcpy(val_ref.data, val.ptr, 32);
7783         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
7784 }
7785
7786 int8_tArray OpenChannel_1get_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
7787         LDKOpenChannel this_ptr_conv;
7788         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7789         this_ptr_conv.is_owned = false;
7790         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
7791         memcpy(ret_arr.ptr, *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
7792         return ret_arr;
7793 }
7794
7795 void OpenChannel_1set_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7796         LDKOpenChannel this_ptr_conv;
7797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7798         this_ptr_conv.is_owned = false;
7799         LDKThirtyTwoBytes val_ref;
7800         CHECK(val.len == 32);
7801         memcpy(val_ref.data, val.ptr, 32);
7802         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
7803 }
7804
7805 int64_t OpenChannel_1get_1funding_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
7806         LDKOpenChannel this_ptr_conv;
7807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7808         this_ptr_conv.is_owned = false;
7809         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
7810         return ret_val;
7811 }
7812
7813 void OpenChannel_1set_1funding_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7814         LDKOpenChannel this_ptr_conv;
7815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7816         this_ptr_conv.is_owned = false;
7817         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
7818 }
7819
7820 int64_t OpenChannel_1get_1push_1msat(void* ctx_TODO, uint32_t this_ptr) {
7821         LDKOpenChannel this_ptr_conv;
7822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7823         this_ptr_conv.is_owned = false;
7824         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
7825         return ret_val;
7826 }
7827
7828 void OpenChannel_1set_1push_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7829         LDKOpenChannel this_ptr_conv;
7830         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7831         this_ptr_conv.is_owned = false;
7832         OpenChannel_set_push_msat(&this_ptr_conv, val);
7833 }
7834
7835 int64_t OpenChannel_1get_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
7836         LDKOpenChannel this_ptr_conv;
7837         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7838         this_ptr_conv.is_owned = false;
7839         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
7840         return ret_val;
7841 }
7842
7843 void OpenChannel_1set_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7844         LDKOpenChannel this_ptr_conv;
7845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7846         this_ptr_conv.is_owned = false;
7847         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
7848 }
7849
7850 int64_t OpenChannel_1get_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr) {
7851         LDKOpenChannel this_ptr_conv;
7852         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7853         this_ptr_conv.is_owned = false;
7854         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
7855         return ret_val;
7856 }
7857
7858 void OpenChannel_1set_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7859         LDKOpenChannel this_ptr_conv;
7860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7861         this_ptr_conv.is_owned = false;
7862         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
7863 }
7864
7865 int64_t OpenChannel_1get_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
7866         LDKOpenChannel this_ptr_conv;
7867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7868         this_ptr_conv.is_owned = false;
7869         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
7870         return ret_val;
7871 }
7872
7873 void OpenChannel_1set_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7874         LDKOpenChannel this_ptr_conv;
7875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7876         this_ptr_conv.is_owned = false;
7877         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
7878 }
7879
7880 int64_t OpenChannel_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
7881         LDKOpenChannel this_ptr_conv;
7882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7883         this_ptr_conv.is_owned = false;
7884         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
7885         return ret_val;
7886 }
7887
7888 void OpenChannel_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
7889         LDKOpenChannel this_ptr_conv;
7890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7891         this_ptr_conv.is_owned = false;
7892         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
7893 }
7894
7895 int32_t OpenChannel_1get_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_ptr) {
7896         LDKOpenChannel this_ptr_conv;
7897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7898         this_ptr_conv.is_owned = false;
7899         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
7900         return ret_val;
7901 }
7902
7903 void OpenChannel_1set_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
7904         LDKOpenChannel this_ptr_conv;
7905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7906         this_ptr_conv.is_owned = false;
7907         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
7908 }
7909
7910 jshort OpenChannel_1get_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr) {
7911         LDKOpenChannel this_ptr_conv;
7912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7913         this_ptr_conv.is_owned = false;
7914         jshort ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
7915         return ret_val;
7916 }
7917
7918 void OpenChannel_1set_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7919         LDKOpenChannel this_ptr_conv;
7920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7921         this_ptr_conv.is_owned = false;
7922         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
7923 }
7924
7925 jshort OpenChannel_1get_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr) {
7926         LDKOpenChannel this_ptr_conv;
7927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7928         this_ptr_conv.is_owned = false;
7929         jshort ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
7930         return ret_val;
7931 }
7932
7933 void OpenChannel_1set_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr, jshort val) {
7934         LDKOpenChannel this_ptr_conv;
7935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7936         this_ptr_conv.is_owned = false;
7937         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
7938 }
7939
7940 int8_tArray OpenChannel_1get_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
7941         LDKOpenChannel 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, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
7946         return arg_arr;
7947 }
7948
7949 void OpenChannel_1set_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7950         LDKOpenChannel 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         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
7957 }
7958
7959 int8_tArray OpenChannel_1get_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
7960         LDKOpenChannel this_ptr_conv;
7961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7962         this_ptr_conv.is_owned = false;
7963         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7964         memcpy(arg_arr.ptr, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
7965         return arg_arr;
7966 }
7967
7968 void OpenChannel_1set_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7969         LDKOpenChannel this_ptr_conv;
7970         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7971         this_ptr_conv.is_owned = false;
7972         LDKPublicKey val_ref;
7973         CHECK(val.len == 33);
7974         memcpy(val_ref.compressed_form, val.ptr, 33);
7975         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
7976 }
7977
7978 int8_tArray OpenChannel_1get_1payment_1point(void* ctx_TODO, uint32_t this_ptr) {
7979         LDKOpenChannel this_ptr_conv;
7980         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7981         this_ptr_conv.is_owned = false;
7982         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
7983         memcpy(arg_arr.ptr, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
7984         return arg_arr;
7985 }
7986
7987 void OpenChannel_1set_1payment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
7988         LDKOpenChannel this_ptr_conv;
7989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
7990         this_ptr_conv.is_owned = false;
7991         LDKPublicKey val_ref;
7992         CHECK(val.len == 33);
7993         memcpy(val_ref.compressed_form, val.ptr, 33);
7994         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
7995 }
7996
7997 int8_tArray OpenChannel_1get_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
7998         LDKOpenChannel this_ptr_conv;
7999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8000         this_ptr_conv.is_owned = false;
8001         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8002         memcpy(arg_arr.ptr, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
8003         return arg_arr;
8004 }
8005
8006 void OpenChannel_1set_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8007         LDKOpenChannel this_ptr_conv;
8008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8009         this_ptr_conv.is_owned = false;
8010         LDKPublicKey val_ref;
8011         CHECK(val.len == 33);
8012         memcpy(val_ref.compressed_form, val.ptr, 33);
8013         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
8014 }
8015
8016 int8_tArray OpenChannel_1get_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
8017         LDKOpenChannel this_ptr_conv;
8018         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8019         this_ptr_conv.is_owned = false;
8020         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8021         memcpy(arg_arr.ptr, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
8022         return arg_arr;
8023 }
8024
8025 void OpenChannel_1set_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8026         LDKOpenChannel this_ptr_conv;
8027         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8028         this_ptr_conv.is_owned = false;
8029         LDKPublicKey val_ref;
8030         CHECK(val.len == 33);
8031         memcpy(val_ref.compressed_form, val.ptr, 33);
8032         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
8033 }
8034
8035 int8_tArray OpenChannel_1get_1first_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
8036         LDKOpenChannel this_ptr_conv;
8037         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8038         this_ptr_conv.is_owned = false;
8039         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8040         memcpy(arg_arr.ptr, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
8041         return arg_arr;
8042 }
8043
8044 void OpenChannel_1set_1first_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8045         LDKOpenChannel this_ptr_conv;
8046         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8047         this_ptr_conv.is_owned = false;
8048         LDKPublicKey val_ref;
8049         CHECK(val.len == 33);
8050         memcpy(val_ref.compressed_form, val.ptr, 33);
8051         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
8052 }
8053
8054 int8_t OpenChannel_1get_1channel_1flags(void* ctx_TODO, uint32_t this_ptr) {
8055         LDKOpenChannel this_ptr_conv;
8056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8057         this_ptr_conv.is_owned = false;
8058         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
8059         return ret_val;
8060 }
8061
8062 void OpenChannel_1set_1channel_1flags(void* ctx_TODO, uint32_t this_ptr, int8_t val) {
8063         LDKOpenChannel this_ptr_conv;
8064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8065         this_ptr_conv.is_owned = false;
8066         OpenChannel_set_channel_flags(&this_ptr_conv, val);
8067 }
8068
8069 void AcceptChannel_1free(void* ctx_TODO, uint32_t this_ptr) {
8070         LDKAcceptChannel this_ptr_conv;
8071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8072         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8073         AcceptChannel_free(this_ptr_conv);
8074 }
8075
8076 uint32_t AcceptChannel_1clone(void* ctx_TODO, uint32_t orig) {
8077         LDKAcceptChannel orig_conv;
8078         orig_conv.inner = (void*)(orig & (~1));
8079         orig_conv.is_owned = false;
8080         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
8081         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8082         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8083         long ret_ref = (long)ret_var.inner;
8084         if (ret_var.is_owned) {
8085                 ret_ref |= 1;
8086         }
8087         return ret_ref;
8088 }
8089
8090 int8_tArray AcceptChannel_1get_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8091         LDKAcceptChannel this_ptr_conv;
8092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8093         this_ptr_conv.is_owned = false;
8094         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8095         memcpy(ret_arr.ptr, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
8096         return ret_arr;
8097 }
8098
8099 void AcceptChannel_1set_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8100         LDKAcceptChannel this_ptr_conv;
8101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8102         this_ptr_conv.is_owned = false;
8103         LDKThirtyTwoBytes val_ref;
8104         CHECK(val.len == 32);
8105         memcpy(val_ref.data, val.ptr, 32);
8106         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
8107 }
8108
8109 int64_t AcceptChannel_1get_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
8110         LDKAcceptChannel this_ptr_conv;
8111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8112         this_ptr_conv.is_owned = false;
8113         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
8114         return ret_val;
8115 }
8116
8117 void AcceptChannel_1set_1dust_1limit_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8118         LDKAcceptChannel this_ptr_conv;
8119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8120         this_ptr_conv.is_owned = false;
8121         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
8122 }
8123
8124 int64_t AcceptChannel_1get_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr) {
8125         LDKAcceptChannel this_ptr_conv;
8126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8127         this_ptr_conv.is_owned = false;
8128         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
8129         return ret_val;
8130 }
8131
8132 void AcceptChannel_1set_1max_1htlc_1value_1in_1flight_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8133         LDKAcceptChannel this_ptr_conv;
8134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8135         this_ptr_conv.is_owned = false;
8136         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
8137 }
8138
8139 int64_t AcceptChannel_1get_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
8140         LDKAcceptChannel this_ptr_conv;
8141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8142         this_ptr_conv.is_owned = false;
8143         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
8144         return ret_val;
8145 }
8146
8147 void AcceptChannel_1set_1channel_1reserve_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8148         LDKAcceptChannel this_ptr_conv;
8149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8150         this_ptr_conv.is_owned = false;
8151         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
8152 }
8153
8154 int64_t AcceptChannel_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
8155         LDKAcceptChannel this_ptr_conv;
8156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8157         this_ptr_conv.is_owned = false;
8158         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
8159         return ret_val;
8160 }
8161
8162 void AcceptChannel_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8163         LDKAcceptChannel this_ptr_conv;
8164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8165         this_ptr_conv.is_owned = false;
8166         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
8167 }
8168
8169 int32_t AcceptChannel_1get_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr) {
8170         LDKAcceptChannel this_ptr_conv;
8171         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8172         this_ptr_conv.is_owned = false;
8173         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
8174         return ret_val;
8175 }
8176
8177 void AcceptChannel_1set_1minimum_1depth(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
8178         LDKAcceptChannel this_ptr_conv;
8179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8180         this_ptr_conv.is_owned = false;
8181         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
8182 }
8183
8184 jshort AcceptChannel_1get_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr) {
8185         LDKAcceptChannel this_ptr_conv;
8186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8187         this_ptr_conv.is_owned = false;
8188         jshort ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
8189         return ret_val;
8190 }
8191
8192 void AcceptChannel_1set_1to_1self_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
8193         LDKAcceptChannel this_ptr_conv;
8194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8195         this_ptr_conv.is_owned = false;
8196         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
8197 }
8198
8199 jshort AcceptChannel_1get_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr) {
8200         LDKAcceptChannel this_ptr_conv;
8201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8202         this_ptr_conv.is_owned = false;
8203         jshort ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
8204         return ret_val;
8205 }
8206
8207 void AcceptChannel_1set_1max_1accepted_1htlcs(void* ctx_TODO, uint32_t this_ptr, jshort val) {
8208         LDKAcceptChannel this_ptr_conv;
8209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8210         this_ptr_conv.is_owned = false;
8211         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
8212 }
8213
8214 int8_tArray AcceptChannel_1get_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
8215         LDKAcceptChannel this_ptr_conv;
8216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8217         this_ptr_conv.is_owned = false;
8218         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8219         memcpy(arg_arr.ptr, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
8220         return arg_arr;
8221 }
8222
8223 void AcceptChannel_1set_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8224         LDKAcceptChannel this_ptr_conv;
8225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8226         this_ptr_conv.is_owned = false;
8227         LDKPublicKey val_ref;
8228         CHECK(val.len == 33);
8229         memcpy(val_ref.compressed_form, val.ptr, 33);
8230         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
8231 }
8232
8233 int8_tArray AcceptChannel_1get_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
8234         LDKAcceptChannel this_ptr_conv;
8235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8236         this_ptr_conv.is_owned = false;
8237         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8238         memcpy(arg_arr.ptr, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
8239         return arg_arr;
8240 }
8241
8242 void AcceptChannel_1set_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8243         LDKAcceptChannel this_ptr_conv;
8244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8245         this_ptr_conv.is_owned = false;
8246         LDKPublicKey val_ref;
8247         CHECK(val.len == 33);
8248         memcpy(val_ref.compressed_form, val.ptr, 33);
8249         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
8250 }
8251
8252 int8_tArray AcceptChannel_1get_1payment_1point(void* ctx_TODO, uint32_t this_ptr) {
8253         LDKAcceptChannel this_ptr_conv;
8254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8255         this_ptr_conv.is_owned = false;
8256         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8257         memcpy(arg_arr.ptr, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
8258         return arg_arr;
8259 }
8260
8261 void AcceptChannel_1set_1payment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8262         LDKAcceptChannel this_ptr_conv;
8263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8264         this_ptr_conv.is_owned = false;
8265         LDKPublicKey val_ref;
8266         CHECK(val.len == 33);
8267         memcpy(val_ref.compressed_form, val.ptr, 33);
8268         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
8269 }
8270
8271 int8_tArray AcceptChannel_1get_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
8272         LDKAcceptChannel this_ptr_conv;
8273         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8274         this_ptr_conv.is_owned = false;
8275         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8276         memcpy(arg_arr.ptr, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
8277         return arg_arr;
8278 }
8279
8280 void AcceptChannel_1set_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8281         LDKAcceptChannel this_ptr_conv;
8282         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8283         this_ptr_conv.is_owned = false;
8284         LDKPublicKey val_ref;
8285         CHECK(val.len == 33);
8286         memcpy(val_ref.compressed_form, val.ptr, 33);
8287         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
8288 }
8289
8290 int8_tArray AcceptChannel_1get_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
8291         LDKAcceptChannel this_ptr_conv;
8292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8293         this_ptr_conv.is_owned = false;
8294         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8295         memcpy(arg_arr.ptr, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
8296         return arg_arr;
8297 }
8298
8299 void AcceptChannel_1set_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8300         LDKAcceptChannel this_ptr_conv;
8301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8302         this_ptr_conv.is_owned = false;
8303         LDKPublicKey val_ref;
8304         CHECK(val.len == 33);
8305         memcpy(val_ref.compressed_form, val.ptr, 33);
8306         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
8307 }
8308
8309 int8_tArray AcceptChannel_1get_1first_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
8310         LDKAcceptChannel this_ptr_conv;
8311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8312         this_ptr_conv.is_owned = false;
8313         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8314         memcpy(arg_arr.ptr, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
8315         return arg_arr;
8316 }
8317
8318 void AcceptChannel_1set_1first_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8319         LDKAcceptChannel this_ptr_conv;
8320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8321         this_ptr_conv.is_owned = false;
8322         LDKPublicKey val_ref;
8323         CHECK(val.len == 33);
8324         memcpy(val_ref.compressed_form, val.ptr, 33);
8325         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
8326 }
8327
8328 void FundingCreated_1free(void* ctx_TODO, uint32_t this_ptr) {
8329         LDKFundingCreated this_ptr_conv;
8330         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8331         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8332         FundingCreated_free(this_ptr_conv);
8333 }
8334
8335 uint32_t FundingCreated_1clone(void* ctx_TODO, uint32_t orig) {
8336         LDKFundingCreated orig_conv;
8337         orig_conv.inner = (void*)(orig & (~1));
8338         orig_conv.is_owned = false;
8339         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
8340         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8341         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8342         long ret_ref = (long)ret_var.inner;
8343         if (ret_var.is_owned) {
8344                 ret_ref |= 1;
8345         }
8346         return ret_ref;
8347 }
8348
8349 int8_tArray FundingCreated_1get_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8350         LDKFundingCreated this_ptr_conv;
8351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8352         this_ptr_conv.is_owned = false;
8353         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8354         memcpy(ret_arr.ptr, *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
8355         return ret_arr;
8356 }
8357
8358 void FundingCreated_1set_1temporary_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8359         LDKFundingCreated this_ptr_conv;
8360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8361         this_ptr_conv.is_owned = false;
8362         LDKThirtyTwoBytes val_ref;
8363         CHECK(val.len == 32);
8364         memcpy(val_ref.data, val.ptr, 32);
8365         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
8366 }
8367
8368 int8_tArray FundingCreated_1get_1funding_1txid(void* ctx_TODO, uint32_t this_ptr) {
8369         LDKFundingCreated this_ptr_conv;
8370         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8371         this_ptr_conv.is_owned = false;
8372         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8373         memcpy(ret_arr.ptr, *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
8374         return ret_arr;
8375 }
8376
8377 void FundingCreated_1set_1funding_1txid(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8378         LDKFundingCreated this_ptr_conv;
8379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8380         this_ptr_conv.is_owned = false;
8381         LDKThirtyTwoBytes val_ref;
8382         CHECK(val.len == 32);
8383         memcpy(val_ref.data, val.ptr, 32);
8384         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
8385 }
8386
8387 jshort FundingCreated_1get_1funding_1output_1index(void* ctx_TODO, uint32_t this_ptr) {
8388         LDKFundingCreated this_ptr_conv;
8389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8390         this_ptr_conv.is_owned = false;
8391         jshort ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
8392         return ret_val;
8393 }
8394
8395 void FundingCreated_1set_1funding_1output_1index(void* ctx_TODO, uint32_t this_ptr, jshort val) {
8396         LDKFundingCreated this_ptr_conv;
8397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8398         this_ptr_conv.is_owned = false;
8399         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
8400 }
8401
8402 int8_tArray FundingCreated_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
8403         LDKFundingCreated this_ptr_conv;
8404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8405         this_ptr_conv.is_owned = false;
8406         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
8407         memcpy(arg_arr.ptr, FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
8408         return arg_arr;
8409 }
8410
8411 void FundingCreated_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8412         LDKFundingCreated this_ptr_conv;
8413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8414         this_ptr_conv.is_owned = false;
8415         LDKSignature val_ref;
8416         CHECK(val.len == 64);
8417         memcpy(val_ref.compact_form, val.ptr, 64);
8418         FundingCreated_set_signature(&this_ptr_conv, val_ref);
8419 }
8420
8421 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) {
8422         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
8423         CHECK(temporary_channel_id_arg.len == 32);
8424         memcpy(temporary_channel_id_arg_ref.data, temporary_channel_id_arg.ptr, 32);
8425         LDKThirtyTwoBytes funding_txid_arg_ref;
8426         CHECK(funding_txid_arg.len == 32);
8427         memcpy(funding_txid_arg_ref.data, funding_txid_arg.ptr, 32);
8428         LDKSignature signature_arg_ref;
8429         CHECK(signature_arg.len == 64);
8430         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
8431         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
8432         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8433         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8434         long ret_ref = (long)ret_var.inner;
8435         if (ret_var.is_owned) {
8436                 ret_ref |= 1;
8437         }
8438         return ret_ref;
8439 }
8440
8441 void FundingSigned_1free(void* ctx_TODO, uint32_t this_ptr) {
8442         LDKFundingSigned this_ptr_conv;
8443         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8444         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8445         FundingSigned_free(this_ptr_conv);
8446 }
8447
8448 uint32_t FundingSigned_1clone(void* ctx_TODO, uint32_t orig) {
8449         LDKFundingSigned orig_conv;
8450         orig_conv.inner = (void*)(orig & (~1));
8451         orig_conv.is_owned = false;
8452         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
8453         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8454         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8455         long ret_ref = (long)ret_var.inner;
8456         if (ret_var.is_owned) {
8457                 ret_ref |= 1;
8458         }
8459         return ret_ref;
8460 }
8461
8462 int8_tArray FundingSigned_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8463         LDKFundingSigned this_ptr_conv;
8464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8465         this_ptr_conv.is_owned = false;
8466         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8467         memcpy(ret_arr.ptr, *FundingSigned_get_channel_id(&this_ptr_conv), 32);
8468         return ret_arr;
8469 }
8470
8471 void FundingSigned_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8472         LDKFundingSigned this_ptr_conv;
8473         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8474         this_ptr_conv.is_owned = false;
8475         LDKThirtyTwoBytes val_ref;
8476         CHECK(val.len == 32);
8477         memcpy(val_ref.data, val.ptr, 32);
8478         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
8479 }
8480
8481 int8_tArray FundingSigned_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
8482         LDKFundingSigned this_ptr_conv;
8483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8484         this_ptr_conv.is_owned = false;
8485         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
8486         memcpy(arg_arr.ptr, FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
8487         return arg_arr;
8488 }
8489
8490 void FundingSigned_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8491         LDKFundingSigned this_ptr_conv;
8492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8493         this_ptr_conv.is_owned = false;
8494         LDKSignature val_ref;
8495         CHECK(val.len == 64);
8496         memcpy(val_ref.compact_form, val.ptr, 64);
8497         FundingSigned_set_signature(&this_ptr_conv, val_ref);
8498 }
8499
8500 uint32_t FundingSigned_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray signature_arg) {
8501         LDKThirtyTwoBytes channel_id_arg_ref;
8502         CHECK(channel_id_arg.len == 32);
8503         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8504         LDKSignature signature_arg_ref;
8505         CHECK(signature_arg.len == 64);
8506         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
8507         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
8508         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8509         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8510         long ret_ref = (long)ret_var.inner;
8511         if (ret_var.is_owned) {
8512                 ret_ref |= 1;
8513         }
8514         return ret_ref;
8515 }
8516
8517 void FundingLocked_1free(void* ctx_TODO, uint32_t this_ptr) {
8518         LDKFundingLocked this_ptr_conv;
8519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8520         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8521         FundingLocked_free(this_ptr_conv);
8522 }
8523
8524 uint32_t FundingLocked_1clone(void* ctx_TODO, uint32_t orig) {
8525         LDKFundingLocked orig_conv;
8526         orig_conv.inner = (void*)(orig & (~1));
8527         orig_conv.is_owned = false;
8528         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
8529         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8530         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8531         long ret_ref = (long)ret_var.inner;
8532         if (ret_var.is_owned) {
8533                 ret_ref |= 1;
8534         }
8535         return ret_ref;
8536 }
8537
8538 int8_tArray FundingLocked_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8539         LDKFundingLocked this_ptr_conv;
8540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8541         this_ptr_conv.is_owned = false;
8542         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8543         memcpy(ret_arr.ptr, *FundingLocked_get_channel_id(&this_ptr_conv), 32);
8544         return ret_arr;
8545 }
8546
8547 void FundingLocked_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8548         LDKFundingLocked this_ptr_conv;
8549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8550         this_ptr_conv.is_owned = false;
8551         LDKThirtyTwoBytes val_ref;
8552         CHECK(val.len == 32);
8553         memcpy(val_ref.data, val.ptr, 32);
8554         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
8555 }
8556
8557 int8_tArray FundingLocked_1get_1next_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
8558         LDKFundingLocked this_ptr_conv;
8559         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8560         this_ptr_conv.is_owned = false;
8561         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
8562         memcpy(arg_arr.ptr, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
8563         return arg_arr;
8564 }
8565
8566 void FundingLocked_1set_1next_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8567         LDKFundingLocked this_ptr_conv;
8568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8569         this_ptr_conv.is_owned = false;
8570         LDKPublicKey val_ref;
8571         CHECK(val.len == 33);
8572         memcpy(val_ref.compressed_form, val.ptr, 33);
8573         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
8574 }
8575
8576 uint32_t FundingLocked_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
8577         LDKThirtyTwoBytes channel_id_arg_ref;
8578         CHECK(channel_id_arg.len == 32);
8579         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8580         LDKPublicKey next_per_commitment_point_arg_ref;
8581         CHECK(next_per_commitment_point_arg.len == 33);
8582         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg.ptr, 33);
8583         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
8584         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8585         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8586         long ret_ref = (long)ret_var.inner;
8587         if (ret_var.is_owned) {
8588                 ret_ref |= 1;
8589         }
8590         return ret_ref;
8591 }
8592
8593 void Shutdown_1free(void* ctx_TODO, uint32_t this_ptr) {
8594         LDKShutdown this_ptr_conv;
8595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8596         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8597         Shutdown_free(this_ptr_conv);
8598 }
8599
8600 uint32_t Shutdown_1clone(void* ctx_TODO, uint32_t orig) {
8601         LDKShutdown orig_conv;
8602         orig_conv.inner = (void*)(orig & (~1));
8603         orig_conv.is_owned = false;
8604         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
8605         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8606         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8607         long ret_ref = (long)ret_var.inner;
8608         if (ret_var.is_owned) {
8609                 ret_ref |= 1;
8610         }
8611         return ret_ref;
8612 }
8613
8614 int8_tArray Shutdown_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8615         LDKShutdown this_ptr_conv;
8616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8617         this_ptr_conv.is_owned = false;
8618         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8619         memcpy(ret_arr.ptr, *Shutdown_get_channel_id(&this_ptr_conv), 32);
8620         return ret_arr;
8621 }
8622
8623 void Shutdown_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8624         LDKShutdown this_ptr_conv;
8625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8626         this_ptr_conv.is_owned = false;
8627         LDKThirtyTwoBytes val_ref;
8628         CHECK(val.len == 32);
8629         memcpy(val_ref.data, val.ptr, 32);
8630         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
8631 }
8632
8633 int8_tArray Shutdown_1get_1scriptpubkey(void* ctx_TODO, uint32_t this_ptr) {
8634         LDKShutdown this_ptr_conv;
8635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8636         this_ptr_conv.is_owned = false;
8637         LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
8638         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
8639         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
8640         return arg_arr;
8641 }
8642
8643 void Shutdown_1set_1scriptpubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8644         LDKShutdown this_ptr_conv;
8645         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8646         this_ptr_conv.is_owned = false;
8647         LDKCVec_u8Z val_ref;
8648         val_ref.datalen = val.len;
8649         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
8650         memcpy(val_ref.data, val.ptr, val_ref.datalen);
8651         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
8652 }
8653
8654 uint32_t Shutdown_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
8655         LDKThirtyTwoBytes channel_id_arg_ref;
8656         CHECK(channel_id_arg.len == 32);
8657         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8658         LDKCVec_u8Z scriptpubkey_arg_ref;
8659         scriptpubkey_arg_ref.datalen = scriptpubkey_arg.len;
8660         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
8661         memcpy(scriptpubkey_arg_ref.data, scriptpubkey_arg.ptr, scriptpubkey_arg_ref.datalen);
8662         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
8663         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8664         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8665         long ret_ref = (long)ret_var.inner;
8666         if (ret_var.is_owned) {
8667                 ret_ref |= 1;
8668         }
8669         return ret_ref;
8670 }
8671
8672 void ClosingSigned_1free(void* ctx_TODO, uint32_t this_ptr) {
8673         LDKClosingSigned this_ptr_conv;
8674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8675         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8676         ClosingSigned_free(this_ptr_conv);
8677 }
8678
8679 uint32_t ClosingSigned_1clone(void* ctx_TODO, uint32_t orig) {
8680         LDKClosingSigned orig_conv;
8681         orig_conv.inner = (void*)(orig & (~1));
8682         orig_conv.is_owned = false;
8683         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
8684         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8685         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8686         long ret_ref = (long)ret_var.inner;
8687         if (ret_var.is_owned) {
8688                 ret_ref |= 1;
8689         }
8690         return ret_ref;
8691 }
8692
8693 int8_tArray ClosingSigned_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8694         LDKClosingSigned this_ptr_conv;
8695         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8696         this_ptr_conv.is_owned = false;
8697         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8698         memcpy(ret_arr.ptr, *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
8699         return ret_arr;
8700 }
8701
8702 void ClosingSigned_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8703         LDKClosingSigned this_ptr_conv;
8704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8705         this_ptr_conv.is_owned = false;
8706         LDKThirtyTwoBytes val_ref;
8707         CHECK(val.len == 32);
8708         memcpy(val_ref.data, val.ptr, 32);
8709         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
8710 }
8711
8712 int64_t ClosingSigned_1get_1fee_1satoshis(void* ctx_TODO, uint32_t this_ptr) {
8713         LDKClosingSigned this_ptr_conv;
8714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8715         this_ptr_conv.is_owned = false;
8716         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
8717         return ret_val;
8718 }
8719
8720 void ClosingSigned_1set_1fee_1satoshis(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8721         LDKClosingSigned this_ptr_conv;
8722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8723         this_ptr_conv.is_owned = false;
8724         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
8725 }
8726
8727 int8_tArray ClosingSigned_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
8728         LDKClosingSigned this_ptr_conv;
8729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8730         this_ptr_conv.is_owned = false;
8731         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
8732         memcpy(arg_arr.ptr, ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
8733         return arg_arr;
8734 }
8735
8736 void ClosingSigned_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8737         LDKClosingSigned this_ptr_conv;
8738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8739         this_ptr_conv.is_owned = false;
8740         LDKSignature val_ref;
8741         CHECK(val.len == 64);
8742         memcpy(val_ref.compact_form, val.ptr, 64);
8743         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
8744 }
8745
8746 uint32_t ClosingSigned_1new(void* ctx_TODO, int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
8747         LDKThirtyTwoBytes channel_id_arg_ref;
8748         CHECK(channel_id_arg.len == 32);
8749         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8750         LDKSignature signature_arg_ref;
8751         CHECK(signature_arg.len == 64);
8752         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
8753         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
8754         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8755         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8756         long ret_ref = (long)ret_var.inner;
8757         if (ret_var.is_owned) {
8758                 ret_ref |= 1;
8759         }
8760         return ret_ref;
8761 }
8762
8763 void UpdateAddHTLC_1free(void* ctx_TODO, uint32_t this_ptr) {
8764         LDKUpdateAddHTLC this_ptr_conv;
8765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8766         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8767         UpdateAddHTLC_free(this_ptr_conv);
8768 }
8769
8770 uint32_t UpdateAddHTLC_1clone(void* ctx_TODO, uint32_t orig) {
8771         LDKUpdateAddHTLC orig_conv;
8772         orig_conv.inner = (void*)(orig & (~1));
8773         orig_conv.is_owned = false;
8774         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
8775         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8776         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8777         long ret_ref = (long)ret_var.inner;
8778         if (ret_var.is_owned) {
8779                 ret_ref |= 1;
8780         }
8781         return ret_ref;
8782 }
8783
8784 int8_tArray UpdateAddHTLC_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8785         LDKUpdateAddHTLC this_ptr_conv;
8786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8787         this_ptr_conv.is_owned = false;
8788         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8789         memcpy(ret_arr.ptr, *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
8790         return ret_arr;
8791 }
8792
8793 void UpdateAddHTLC_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8794         LDKUpdateAddHTLC this_ptr_conv;
8795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8796         this_ptr_conv.is_owned = false;
8797         LDKThirtyTwoBytes val_ref;
8798         CHECK(val.len == 32);
8799         memcpy(val_ref.data, val.ptr, 32);
8800         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
8801 }
8802
8803 int64_t UpdateAddHTLC_1get_1htlc_1id(void* ctx_TODO, uint32_t this_ptr) {
8804         LDKUpdateAddHTLC this_ptr_conv;
8805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8806         this_ptr_conv.is_owned = false;
8807         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
8808         return ret_val;
8809 }
8810
8811 void UpdateAddHTLC_1set_1htlc_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8812         LDKUpdateAddHTLC this_ptr_conv;
8813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8814         this_ptr_conv.is_owned = false;
8815         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
8816 }
8817
8818 int64_t UpdateAddHTLC_1get_1amount_1msat(void* ctx_TODO, uint32_t this_ptr) {
8819         LDKUpdateAddHTLC this_ptr_conv;
8820         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8821         this_ptr_conv.is_owned = false;
8822         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
8823         return ret_val;
8824 }
8825
8826 void UpdateAddHTLC_1set_1amount_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8827         LDKUpdateAddHTLC this_ptr_conv;
8828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8829         this_ptr_conv.is_owned = false;
8830         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
8831 }
8832
8833 int8_tArray UpdateAddHTLC_1get_1payment_1hash(void* ctx_TODO, uint32_t this_ptr) {
8834         LDKUpdateAddHTLC this_ptr_conv;
8835         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8836         this_ptr_conv.is_owned = false;
8837         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8838         memcpy(ret_arr.ptr, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
8839         return ret_arr;
8840 }
8841
8842 void UpdateAddHTLC_1set_1payment_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8843         LDKUpdateAddHTLC this_ptr_conv;
8844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8845         this_ptr_conv.is_owned = false;
8846         LDKThirtyTwoBytes val_ref;
8847         CHECK(val.len == 32);
8848         memcpy(val_ref.data, val.ptr, 32);
8849         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
8850 }
8851
8852 int32_t UpdateAddHTLC_1get_1cltv_1expiry(void* ctx_TODO, uint32_t this_ptr) {
8853         LDKUpdateAddHTLC this_ptr_conv;
8854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8855         this_ptr_conv.is_owned = false;
8856         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
8857         return ret_val;
8858 }
8859
8860 void UpdateAddHTLC_1set_1cltv_1expiry(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
8861         LDKUpdateAddHTLC this_ptr_conv;
8862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8863         this_ptr_conv.is_owned = false;
8864         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
8865 }
8866
8867 void UpdateFulfillHTLC_1free(void* ctx_TODO, uint32_t this_ptr) {
8868         LDKUpdateFulfillHTLC this_ptr_conv;
8869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8870         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8871         UpdateFulfillHTLC_free(this_ptr_conv);
8872 }
8873
8874 uint32_t UpdateFulfillHTLC_1clone(void* ctx_TODO, uint32_t orig) {
8875         LDKUpdateFulfillHTLC orig_conv;
8876         orig_conv.inner = (void*)(orig & (~1));
8877         orig_conv.is_owned = false;
8878         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
8879         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8880         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8881         long ret_ref = (long)ret_var.inner;
8882         if (ret_var.is_owned) {
8883                 ret_ref |= 1;
8884         }
8885         return ret_ref;
8886 }
8887
8888 int8_tArray UpdateFulfillHTLC_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8889         LDKUpdateFulfillHTLC this_ptr_conv;
8890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8891         this_ptr_conv.is_owned = false;
8892         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8893         memcpy(ret_arr.ptr, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
8894         return ret_arr;
8895 }
8896
8897 void UpdateFulfillHTLC_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8898         LDKUpdateFulfillHTLC this_ptr_conv;
8899         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8900         this_ptr_conv.is_owned = false;
8901         LDKThirtyTwoBytes val_ref;
8902         CHECK(val.len == 32);
8903         memcpy(val_ref.data, val.ptr, 32);
8904         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
8905 }
8906
8907 int64_t UpdateFulfillHTLC_1get_1htlc_1id(void* ctx_TODO, uint32_t this_ptr) {
8908         LDKUpdateFulfillHTLC this_ptr_conv;
8909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8910         this_ptr_conv.is_owned = false;
8911         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
8912         return ret_val;
8913 }
8914
8915 void UpdateFulfillHTLC_1set_1htlc_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
8916         LDKUpdateFulfillHTLC this_ptr_conv;
8917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8918         this_ptr_conv.is_owned = false;
8919         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
8920 }
8921
8922 int8_tArray UpdateFulfillHTLC_1get_1payment_1preimage(void* ctx_TODO, uint32_t this_ptr) {
8923         LDKUpdateFulfillHTLC this_ptr_conv;
8924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8925         this_ptr_conv.is_owned = false;
8926         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8927         memcpy(ret_arr.ptr, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
8928         return ret_arr;
8929 }
8930
8931 void UpdateFulfillHTLC_1set_1payment_1preimage(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8932         LDKUpdateFulfillHTLC this_ptr_conv;
8933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8934         this_ptr_conv.is_owned = false;
8935         LDKThirtyTwoBytes val_ref;
8936         CHECK(val.len == 32);
8937         memcpy(val_ref.data, val.ptr, 32);
8938         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
8939 }
8940
8941 uint32_t UpdateFulfillHTLC_1new(void* ctx_TODO, int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
8942         LDKThirtyTwoBytes channel_id_arg_ref;
8943         CHECK(channel_id_arg.len == 32);
8944         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
8945         LDKThirtyTwoBytes payment_preimage_arg_ref;
8946         CHECK(payment_preimage_arg.len == 32);
8947         memcpy(payment_preimage_arg_ref.data, payment_preimage_arg.ptr, 32);
8948         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
8949         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8950         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8951         long ret_ref = (long)ret_var.inner;
8952         if (ret_var.is_owned) {
8953                 ret_ref |= 1;
8954         }
8955         return ret_ref;
8956 }
8957
8958 void UpdateFailHTLC_1free(void* ctx_TODO, uint32_t this_ptr) {
8959         LDKUpdateFailHTLC this_ptr_conv;
8960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8961         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8962         UpdateFailHTLC_free(this_ptr_conv);
8963 }
8964
8965 uint32_t UpdateFailHTLC_1clone(void* ctx_TODO, uint32_t orig) {
8966         LDKUpdateFailHTLC orig_conv;
8967         orig_conv.inner = (void*)(orig & (~1));
8968         orig_conv.is_owned = false;
8969         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
8970         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8971         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8972         long ret_ref = (long)ret_var.inner;
8973         if (ret_var.is_owned) {
8974                 ret_ref |= 1;
8975         }
8976         return ret_ref;
8977 }
8978
8979 int8_tArray UpdateFailHTLC_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
8980         LDKUpdateFailHTLC this_ptr_conv;
8981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8982         this_ptr_conv.is_owned = false;
8983         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
8984         memcpy(ret_arr.ptr, *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
8985         return ret_arr;
8986 }
8987
8988 void UpdateFailHTLC_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
8989         LDKUpdateFailHTLC this_ptr_conv;
8990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
8991         this_ptr_conv.is_owned = false;
8992         LDKThirtyTwoBytes val_ref;
8993         CHECK(val.len == 32);
8994         memcpy(val_ref.data, val.ptr, 32);
8995         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
8996 }
8997
8998 int64_t UpdateFailHTLC_1get_1htlc_1id(void* ctx_TODO, uint32_t this_ptr) {
8999         LDKUpdateFailHTLC this_ptr_conv;
9000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9001         this_ptr_conv.is_owned = false;
9002         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
9003         return ret_val;
9004 }
9005
9006 void UpdateFailHTLC_1set_1htlc_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9007         LDKUpdateFailHTLC this_ptr_conv;
9008         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9009         this_ptr_conv.is_owned = false;
9010         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
9011 }
9012
9013 void UpdateFailMalformedHTLC_1free(void* ctx_TODO, uint32_t this_ptr) {
9014         LDKUpdateFailMalformedHTLC this_ptr_conv;
9015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9016         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9017         UpdateFailMalformedHTLC_free(this_ptr_conv);
9018 }
9019
9020 uint32_t UpdateFailMalformedHTLC_1clone(void* ctx_TODO, uint32_t orig) {
9021         LDKUpdateFailMalformedHTLC orig_conv;
9022         orig_conv.inner = (void*)(orig & (~1));
9023         orig_conv.is_owned = false;
9024         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
9025         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9026         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9027         long ret_ref = (long)ret_var.inner;
9028         if (ret_var.is_owned) {
9029                 ret_ref |= 1;
9030         }
9031         return ret_ref;
9032 }
9033
9034 int8_tArray UpdateFailMalformedHTLC_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9035         LDKUpdateFailMalformedHTLC this_ptr_conv;
9036         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9037         this_ptr_conv.is_owned = false;
9038         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9039         memcpy(ret_arr.ptr, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
9040         return ret_arr;
9041 }
9042
9043 void UpdateFailMalformedHTLC_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9044         LDKUpdateFailMalformedHTLC this_ptr_conv;
9045         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9046         this_ptr_conv.is_owned = false;
9047         LDKThirtyTwoBytes val_ref;
9048         CHECK(val.len == 32);
9049         memcpy(val_ref.data, val.ptr, 32);
9050         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
9051 }
9052
9053 int64_t UpdateFailMalformedHTLC_1get_1htlc_1id(void* ctx_TODO, uint32_t this_ptr) {
9054         LDKUpdateFailMalformedHTLC this_ptr_conv;
9055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9056         this_ptr_conv.is_owned = false;
9057         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
9058         return ret_val;
9059 }
9060
9061 void UpdateFailMalformedHTLC_1set_1htlc_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9062         LDKUpdateFailMalformedHTLC this_ptr_conv;
9063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9064         this_ptr_conv.is_owned = false;
9065         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
9066 }
9067
9068 jshort UpdateFailMalformedHTLC_1get_1failure_1code(void* ctx_TODO, uint32_t this_ptr) {
9069         LDKUpdateFailMalformedHTLC this_ptr_conv;
9070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9071         this_ptr_conv.is_owned = false;
9072         jshort ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
9073         return ret_val;
9074 }
9075
9076 void UpdateFailMalformedHTLC_1set_1failure_1code(void* ctx_TODO, uint32_t this_ptr, jshort val) {
9077         LDKUpdateFailMalformedHTLC this_ptr_conv;
9078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9079         this_ptr_conv.is_owned = false;
9080         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
9081 }
9082
9083 void CommitmentSigned_1free(void* ctx_TODO, uint32_t this_ptr) {
9084         LDKCommitmentSigned this_ptr_conv;
9085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9086         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9087         CommitmentSigned_free(this_ptr_conv);
9088 }
9089
9090 uint32_t CommitmentSigned_1clone(void* ctx_TODO, uint32_t orig) {
9091         LDKCommitmentSigned orig_conv;
9092         orig_conv.inner = (void*)(orig & (~1));
9093         orig_conv.is_owned = false;
9094         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
9095         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9096         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9097         long ret_ref = (long)ret_var.inner;
9098         if (ret_var.is_owned) {
9099                 ret_ref |= 1;
9100         }
9101         return ret_ref;
9102 }
9103
9104 int8_tArray CommitmentSigned_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9105         LDKCommitmentSigned this_ptr_conv;
9106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9107         this_ptr_conv.is_owned = false;
9108         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9109         memcpy(ret_arr.ptr, *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
9110         return ret_arr;
9111 }
9112
9113 void CommitmentSigned_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9114         LDKCommitmentSigned this_ptr_conv;
9115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9116         this_ptr_conv.is_owned = false;
9117         LDKThirtyTwoBytes val_ref;
9118         CHECK(val.len == 32);
9119         memcpy(val_ref.data, val.ptr, 32);
9120         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
9121 }
9122
9123 int8_tArray CommitmentSigned_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
9124         LDKCommitmentSigned this_ptr_conv;
9125         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9126         this_ptr_conv.is_owned = false;
9127         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9128         memcpy(arg_arr.ptr, CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
9129         return arg_arr;
9130 }
9131
9132 void CommitmentSigned_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9133         LDKCommitmentSigned this_ptr_conv;
9134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9135         this_ptr_conv.is_owned = false;
9136         LDKSignature val_ref;
9137         CHECK(val.len == 64);
9138         memcpy(val_ref.compact_form, val.ptr, 64);
9139         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
9140 }
9141
9142 void CommitmentSigned_1set_1htlc_1signatures(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
9143         LDKCommitmentSigned this_ptr_conv;
9144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9145         this_ptr_conv.is_owned = false;
9146         LDKCVec_SignatureZ val_constr;
9147         val_constr.datalen = val.len;
9148         if (val_constr.datalen > 0)
9149                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9150         else
9151                 val_constr.data = NULL;
9152         int8_tArray* val_vals = (int8_tArray*) val.ptr;
9153         for (size_t i = 0; i < val_constr.datalen; i++) {
9154                 int8_tArray arr_conv_8 = val_vals[i];
9155                 LDKSignature arr_conv_8_ref;
9156                 CHECK(arr_conv_8.len == 64);
9157                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
9158                 val_constr.data[i] = arr_conv_8_ref;
9159         }
9160         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
9161 }
9162
9163 uint32_t CommitmentSigned_1new(void* ctx_TODO, int8_tArray channel_id_arg, int8_tArray signature_arg, uint32_tArray htlc_signatures_arg) {
9164         LDKThirtyTwoBytes channel_id_arg_ref;
9165         CHECK(channel_id_arg.len == 32);
9166         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
9167         LDKSignature signature_arg_ref;
9168         CHECK(signature_arg.len == 64);
9169         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
9170         LDKCVec_SignatureZ htlc_signatures_arg_constr;
9171         htlc_signatures_arg_constr.datalen = htlc_signatures_arg.len;
9172         if (htlc_signatures_arg_constr.datalen > 0)
9173                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9174         else
9175                 htlc_signatures_arg_constr.data = NULL;
9176         int8_tArray* htlc_signatures_arg_vals = (int8_tArray*) htlc_signatures_arg.ptr;
9177         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
9178                 int8_tArray arr_conv_8 = htlc_signatures_arg_vals[i];
9179                 LDKSignature arr_conv_8_ref;
9180                 CHECK(arr_conv_8.len == 64);
9181                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
9182                 htlc_signatures_arg_constr.data[i] = arr_conv_8_ref;
9183         }
9184         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
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 void RevokeAndACK_1free(void* ctx_TODO, uint32_t this_ptr) {
9195         LDKRevokeAndACK this_ptr_conv;
9196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9197         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9198         RevokeAndACK_free(this_ptr_conv);
9199 }
9200
9201 uint32_t RevokeAndACK_1clone(void* ctx_TODO, uint32_t orig) {
9202         LDKRevokeAndACK orig_conv;
9203         orig_conv.inner = (void*)(orig & (~1));
9204         orig_conv.is_owned = false;
9205         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
9206         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9207         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9208         long ret_ref = (long)ret_var.inner;
9209         if (ret_var.is_owned) {
9210                 ret_ref |= 1;
9211         }
9212         return ret_ref;
9213 }
9214
9215 int8_tArray RevokeAndACK_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9216         LDKRevokeAndACK this_ptr_conv;
9217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9218         this_ptr_conv.is_owned = false;
9219         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9220         memcpy(ret_arr.ptr, *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
9221         return ret_arr;
9222 }
9223
9224 void RevokeAndACK_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9225         LDKRevokeAndACK this_ptr_conv;
9226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9227         this_ptr_conv.is_owned = false;
9228         LDKThirtyTwoBytes val_ref;
9229         CHECK(val.len == 32);
9230         memcpy(val_ref.data, val.ptr, 32);
9231         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
9232 }
9233
9234 int8_tArray RevokeAndACK_1get_1per_1commitment_1secret(void* ctx_TODO, uint32_t this_ptr) {
9235         LDKRevokeAndACK this_ptr_conv;
9236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9237         this_ptr_conv.is_owned = false;
9238         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9239         memcpy(ret_arr.ptr, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
9240         return ret_arr;
9241 }
9242
9243 void RevokeAndACK_1set_1per_1commitment_1secret(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9244         LDKRevokeAndACK this_ptr_conv;
9245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9246         this_ptr_conv.is_owned = false;
9247         LDKThirtyTwoBytes val_ref;
9248         CHECK(val.len == 32);
9249         memcpy(val_ref.data, val.ptr, 32);
9250         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
9251 }
9252
9253 int8_tArray RevokeAndACK_1get_1next_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
9254         LDKRevokeAndACK this_ptr_conv;
9255         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9256         this_ptr_conv.is_owned = false;
9257         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9258         memcpy(arg_arr.ptr, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9259         return arg_arr;
9260 }
9261
9262 void RevokeAndACK_1set_1next_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9263         LDKRevokeAndACK this_ptr_conv;
9264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9265         this_ptr_conv.is_owned = false;
9266         LDKPublicKey val_ref;
9267         CHECK(val.len == 33);
9268         memcpy(val_ref.compressed_form, val.ptr, 33);
9269         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
9270 }
9271
9272 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) {
9273         LDKThirtyTwoBytes channel_id_arg_ref;
9274         CHECK(channel_id_arg.len == 32);
9275         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
9276         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
9277         CHECK(per_commitment_secret_arg.len == 32);
9278         memcpy(per_commitment_secret_arg_ref.data, per_commitment_secret_arg.ptr, 32);
9279         LDKPublicKey next_per_commitment_point_arg_ref;
9280         CHECK(next_per_commitment_point_arg.len == 33);
9281         memcpy(next_per_commitment_point_arg_ref.compressed_form, next_per_commitment_point_arg.ptr, 33);
9282         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
9283         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9284         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9285         long ret_ref = (long)ret_var.inner;
9286         if (ret_var.is_owned) {
9287                 ret_ref |= 1;
9288         }
9289         return ret_ref;
9290 }
9291
9292 void UpdateFee_1free(void* ctx_TODO, uint32_t this_ptr) {
9293         LDKUpdateFee this_ptr_conv;
9294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9295         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9296         UpdateFee_free(this_ptr_conv);
9297 }
9298
9299 uint32_t UpdateFee_1clone(void* ctx_TODO, uint32_t orig) {
9300         LDKUpdateFee orig_conv;
9301         orig_conv.inner = (void*)(orig & (~1));
9302         orig_conv.is_owned = false;
9303         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
9304         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9305         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9306         long ret_ref = (long)ret_var.inner;
9307         if (ret_var.is_owned) {
9308                 ret_ref |= 1;
9309         }
9310         return ret_ref;
9311 }
9312
9313 int8_tArray UpdateFee_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9314         LDKUpdateFee this_ptr_conv;
9315         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9316         this_ptr_conv.is_owned = false;
9317         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9318         memcpy(ret_arr.ptr, *UpdateFee_get_channel_id(&this_ptr_conv), 32);
9319         return ret_arr;
9320 }
9321
9322 void UpdateFee_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9323         LDKUpdateFee this_ptr_conv;
9324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9325         this_ptr_conv.is_owned = false;
9326         LDKThirtyTwoBytes val_ref;
9327         CHECK(val.len == 32);
9328         memcpy(val_ref.data, val.ptr, 32);
9329         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
9330 }
9331
9332 int32_t UpdateFee_1get_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_ptr) {
9333         LDKUpdateFee this_ptr_conv;
9334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9335         this_ptr_conv.is_owned = false;
9336         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
9337         return ret_val;
9338 }
9339
9340 void UpdateFee_1set_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9341         LDKUpdateFee this_ptr_conv;
9342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9343         this_ptr_conv.is_owned = false;
9344         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
9345 }
9346
9347 uint32_t UpdateFee_1new(void* ctx_TODO, int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
9348         LDKThirtyTwoBytes channel_id_arg_ref;
9349         CHECK(channel_id_arg.len == 32);
9350         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
9351         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
9352         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9353         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9354         long ret_ref = (long)ret_var.inner;
9355         if (ret_var.is_owned) {
9356                 ret_ref |= 1;
9357         }
9358         return ret_ref;
9359 }
9360
9361 void DataLossProtect_1free(void* ctx_TODO, uint32_t this_ptr) {
9362         LDKDataLossProtect this_ptr_conv;
9363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9364         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9365         DataLossProtect_free(this_ptr_conv);
9366 }
9367
9368 uint32_t DataLossProtect_1clone(void* ctx_TODO, uint32_t orig) {
9369         LDKDataLossProtect orig_conv;
9370         orig_conv.inner = (void*)(orig & (~1));
9371         orig_conv.is_owned = false;
9372         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
9373         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9374         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9375         long ret_ref = (long)ret_var.inner;
9376         if (ret_var.is_owned) {
9377                 ret_ref |= 1;
9378         }
9379         return ret_ref;
9380 }
9381
9382 int8_tArray DataLossProtect_1get_1your_1last_1per_1commitment_1secret(void* ctx_TODO, uint32_t this_ptr) {
9383         LDKDataLossProtect this_ptr_conv;
9384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9385         this_ptr_conv.is_owned = false;
9386         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9387         memcpy(ret_arr.ptr, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
9388         return ret_arr;
9389 }
9390
9391 void DataLossProtect_1set_1your_1last_1per_1commitment_1secret(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9392         LDKDataLossProtect this_ptr_conv;
9393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9394         this_ptr_conv.is_owned = false;
9395         LDKThirtyTwoBytes val_ref;
9396         CHECK(val.len == 32);
9397         memcpy(val_ref.data, val.ptr, 32);
9398         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
9399 }
9400
9401 int8_tArray DataLossProtect_1get_1my_1current_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
9402         LDKDataLossProtect this_ptr_conv;
9403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9404         this_ptr_conv.is_owned = false;
9405         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9406         memcpy(arg_arr.ptr, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9407         return arg_arr;
9408 }
9409
9410 void DataLossProtect_1set_1my_1current_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9411         LDKDataLossProtect this_ptr_conv;
9412         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9413         this_ptr_conv.is_owned = false;
9414         LDKPublicKey val_ref;
9415         CHECK(val.len == 33);
9416         memcpy(val_ref.compressed_form, val.ptr, 33);
9417         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
9418 }
9419
9420 uint32_t DataLossProtect_1new(void* ctx_TODO, int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
9421         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
9422         CHECK(your_last_per_commitment_secret_arg.len == 32);
9423         memcpy(your_last_per_commitment_secret_arg_ref.data, your_last_per_commitment_secret_arg.ptr, 32);
9424         LDKPublicKey my_current_per_commitment_point_arg_ref;
9425         CHECK(my_current_per_commitment_point_arg.len == 33);
9426         memcpy(my_current_per_commitment_point_arg_ref.compressed_form, my_current_per_commitment_point_arg.ptr, 33);
9427         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
9428         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9429         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9430         long ret_ref = (long)ret_var.inner;
9431         if (ret_var.is_owned) {
9432                 ret_ref |= 1;
9433         }
9434         return ret_ref;
9435 }
9436
9437 void ChannelReestablish_1free(void* ctx_TODO, uint32_t this_ptr) {
9438         LDKChannelReestablish this_ptr_conv;
9439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9440         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9441         ChannelReestablish_free(this_ptr_conv);
9442 }
9443
9444 uint32_t ChannelReestablish_1clone(void* ctx_TODO, uint32_t orig) {
9445         LDKChannelReestablish orig_conv;
9446         orig_conv.inner = (void*)(orig & (~1));
9447         orig_conv.is_owned = false;
9448         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
9449         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9450         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9451         long ret_ref = (long)ret_var.inner;
9452         if (ret_var.is_owned) {
9453                 ret_ref |= 1;
9454         }
9455         return ret_ref;
9456 }
9457
9458 int8_tArray ChannelReestablish_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9459         LDKChannelReestablish this_ptr_conv;
9460         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9461         this_ptr_conv.is_owned = false;
9462         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9463         memcpy(ret_arr.ptr, *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
9464         return ret_arr;
9465 }
9466
9467 void ChannelReestablish_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9468         LDKChannelReestablish this_ptr_conv;
9469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9470         this_ptr_conv.is_owned = false;
9471         LDKThirtyTwoBytes val_ref;
9472         CHECK(val.len == 32);
9473         memcpy(val_ref.data, val.ptr, 32);
9474         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
9475 }
9476
9477 int64_t ChannelReestablish_1get_1next_1local_1commitment_1number(void* ctx_TODO, uint32_t this_ptr) {
9478         LDKChannelReestablish this_ptr_conv;
9479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9480         this_ptr_conv.is_owned = false;
9481         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
9482         return ret_val;
9483 }
9484
9485 void ChannelReestablish_1set_1next_1local_1commitment_1number(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9486         LDKChannelReestablish this_ptr_conv;
9487         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9488         this_ptr_conv.is_owned = false;
9489         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
9490 }
9491
9492 int64_t ChannelReestablish_1get_1next_1remote_1commitment_1number(void* ctx_TODO, uint32_t this_ptr) {
9493         LDKChannelReestablish this_ptr_conv;
9494         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9495         this_ptr_conv.is_owned = false;
9496         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
9497         return ret_val;
9498 }
9499
9500 void ChannelReestablish_1set_1next_1remote_1commitment_1number(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9501         LDKChannelReestablish this_ptr_conv;
9502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9503         this_ptr_conv.is_owned = false;
9504         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
9505 }
9506
9507 void AnnouncementSignatures_1free(void* ctx_TODO, uint32_t this_ptr) {
9508         LDKAnnouncementSignatures this_ptr_conv;
9509         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9510         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9511         AnnouncementSignatures_free(this_ptr_conv);
9512 }
9513
9514 uint32_t AnnouncementSignatures_1clone(void* ctx_TODO, uint32_t orig) {
9515         LDKAnnouncementSignatures orig_conv;
9516         orig_conv.inner = (void*)(orig & (~1));
9517         orig_conv.is_owned = false;
9518         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
9519         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9520         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9521         long ret_ref = (long)ret_var.inner;
9522         if (ret_var.is_owned) {
9523                 ret_ref |= 1;
9524         }
9525         return ret_ref;
9526 }
9527
9528 int8_tArray AnnouncementSignatures_1get_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9529         LDKAnnouncementSignatures this_ptr_conv;
9530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9531         this_ptr_conv.is_owned = false;
9532         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9533         memcpy(ret_arr.ptr, *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
9534         return ret_arr;
9535 }
9536
9537 void AnnouncementSignatures_1set_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9538         LDKAnnouncementSignatures this_ptr_conv;
9539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9540         this_ptr_conv.is_owned = false;
9541         LDKThirtyTwoBytes val_ref;
9542         CHECK(val.len == 32);
9543         memcpy(val_ref.data, val.ptr, 32);
9544         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
9545 }
9546
9547 int64_t AnnouncementSignatures_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9548         LDKAnnouncementSignatures this_ptr_conv;
9549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9550         this_ptr_conv.is_owned = false;
9551         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
9552         return ret_val;
9553 }
9554
9555 void AnnouncementSignatures_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9556         LDKAnnouncementSignatures this_ptr_conv;
9557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9558         this_ptr_conv.is_owned = false;
9559         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
9560 }
9561
9562 int8_tArray AnnouncementSignatures_1get_1node_1signature(void* ctx_TODO, uint32_t this_ptr) {
9563         LDKAnnouncementSignatures this_ptr_conv;
9564         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9565         this_ptr_conv.is_owned = false;
9566         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9567         memcpy(arg_arr.ptr, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
9568         return arg_arr;
9569 }
9570
9571 void AnnouncementSignatures_1set_1node_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9572         LDKAnnouncementSignatures this_ptr_conv;
9573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9574         this_ptr_conv.is_owned = false;
9575         LDKSignature val_ref;
9576         CHECK(val.len == 64);
9577         memcpy(val_ref.compact_form, val.ptr, 64);
9578         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
9579 }
9580
9581 int8_tArray AnnouncementSignatures_1get_1bitcoin_1signature(void* ctx_TODO, uint32_t this_ptr) {
9582         LDKAnnouncementSignatures this_ptr_conv;
9583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9584         this_ptr_conv.is_owned = false;
9585         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9586         memcpy(arg_arr.ptr, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
9587         return arg_arr;
9588 }
9589
9590 void AnnouncementSignatures_1set_1bitcoin_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9591         LDKAnnouncementSignatures this_ptr_conv;
9592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9593         this_ptr_conv.is_owned = false;
9594         LDKSignature val_ref;
9595         CHECK(val.len == 64);
9596         memcpy(val_ref.compact_form, val.ptr, 64);
9597         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
9598 }
9599
9600 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) {
9601         LDKThirtyTwoBytes channel_id_arg_ref;
9602         CHECK(channel_id_arg.len == 32);
9603         memcpy(channel_id_arg_ref.data, channel_id_arg.ptr, 32);
9604         LDKSignature node_signature_arg_ref;
9605         CHECK(node_signature_arg.len == 64);
9606         memcpy(node_signature_arg_ref.compact_form, node_signature_arg.ptr, 64);
9607         LDKSignature bitcoin_signature_arg_ref;
9608         CHECK(bitcoin_signature_arg.len == 64);
9609         memcpy(bitcoin_signature_arg_ref.compact_form, bitcoin_signature_arg.ptr, 64);
9610         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
9611         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9612         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9613         long ret_ref = (long)ret_var.inner;
9614         if (ret_var.is_owned) {
9615                 ret_ref |= 1;
9616         }
9617         return ret_ref;
9618 }
9619
9620 void NetAddress_1free(void* ctx_TODO, uint32_t this_ptr) {
9621         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
9622         FREE((void*)this_ptr);
9623         NetAddress_free(this_ptr_conv);
9624 }
9625
9626 uint32_t NetAddress_1clone(void* ctx_TODO, uint32_t orig) {
9627         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
9628         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9629         *ret_copy = NetAddress_clone(orig_conv);
9630         long ret_ref = (long)ret_copy;
9631         return ret_ref;
9632 }
9633
9634 int8_tArray NetAddress_1write(void* ctx_TODO, uint32_t obj) {
9635         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
9636         LDKCVec_u8Z arg_var = NetAddress_write(obj_conv);
9637         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
9638         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
9639         CVec_u8Z_free(arg_var);
9640         return arg_arr;
9641 }
9642
9643 uint32_t Result_1read(void* ctx_TODO, int8_tArray ser) {
9644         LDKu8slice ser_ref;
9645         ser_ref.datalen = ser.len;
9646         ser_ref.data = ser.ptr;
9647         LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
9648         *ret_conv = Result_read(ser_ref);
9649         return (long)ret_conv;
9650 }
9651
9652 void UnsignedNodeAnnouncement_1free(void* ctx_TODO, uint32_t this_ptr) {
9653         LDKUnsignedNodeAnnouncement this_ptr_conv;
9654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9655         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9656         UnsignedNodeAnnouncement_free(this_ptr_conv);
9657 }
9658
9659 uint32_t UnsignedNodeAnnouncement_1clone(void* ctx_TODO, uint32_t orig) {
9660         LDKUnsignedNodeAnnouncement orig_conv;
9661         orig_conv.inner = (void*)(orig & (~1));
9662         orig_conv.is_owned = false;
9663         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
9664         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9665         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9666         long ret_ref = (long)ret_var.inner;
9667         if (ret_var.is_owned) {
9668                 ret_ref |= 1;
9669         }
9670         return ret_ref;
9671 }
9672
9673 uint32_t UnsignedNodeAnnouncement_1get_1features(void* ctx_TODO, uint32_t this_ptr) {
9674         LDKUnsignedNodeAnnouncement this_ptr_conv;
9675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9676         this_ptr_conv.is_owned = false;
9677         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
9678         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9679         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9680         long ret_ref = (long)ret_var.inner;
9681         if (ret_var.is_owned) {
9682                 ret_ref |= 1;
9683         }
9684         return ret_ref;
9685 }
9686
9687 void UnsignedNodeAnnouncement_1set_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
9688         LDKUnsignedNodeAnnouncement this_ptr_conv;
9689         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9690         this_ptr_conv.is_owned = false;
9691         LDKNodeFeatures val_conv;
9692         val_conv.inner = (void*)(val & (~1));
9693         val_conv.is_owned = (val & 1) || (val == 0);
9694         // Warning: we may need a move here but can't clone!
9695         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
9696 }
9697
9698 int32_t UnsignedNodeAnnouncement_1get_1timestamp(void* ctx_TODO, uint32_t this_ptr) {
9699         LDKUnsignedNodeAnnouncement this_ptr_conv;
9700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9701         this_ptr_conv.is_owned = false;
9702         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
9703         return ret_val;
9704 }
9705
9706 void UnsignedNodeAnnouncement_1set_1timestamp(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
9707         LDKUnsignedNodeAnnouncement this_ptr_conv;
9708         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9709         this_ptr_conv.is_owned = false;
9710         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
9711 }
9712
9713 int8_tArray UnsignedNodeAnnouncement_1get_1node_1id(void* ctx_TODO, uint32_t this_ptr) {
9714         LDKUnsignedNodeAnnouncement this_ptr_conv;
9715         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9716         this_ptr_conv.is_owned = false;
9717         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9718         memcpy(arg_arr.ptr, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
9719         return arg_arr;
9720 }
9721
9722 void UnsignedNodeAnnouncement_1set_1node_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9723         LDKUnsignedNodeAnnouncement this_ptr_conv;
9724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9725         this_ptr_conv.is_owned = false;
9726         LDKPublicKey val_ref;
9727         CHECK(val.len == 33);
9728         memcpy(val_ref.compressed_form, val.ptr, 33);
9729         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
9730 }
9731
9732 int8_tArray UnsignedNodeAnnouncement_1get_1rgb(void* ctx_TODO, uint32_t this_ptr) {
9733         LDKUnsignedNodeAnnouncement this_ptr_conv;
9734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9735         this_ptr_conv.is_owned = false;
9736         int8_tArray ret_arr = { .len = 3, .ptr = MALLOC(3, "Native int8_tArray Bytes") };
9737         memcpy(ret_arr.ptr, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
9738         return ret_arr;
9739 }
9740
9741 void UnsignedNodeAnnouncement_1set_1rgb(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9742         LDKUnsignedNodeAnnouncement this_ptr_conv;
9743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9744         this_ptr_conv.is_owned = false;
9745         LDKThreeBytes val_ref;
9746         CHECK(val.len == 3);
9747         memcpy(val_ref.data, val.ptr, 3);
9748         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
9749 }
9750
9751 int8_tArray UnsignedNodeAnnouncement_1get_1alias(void* ctx_TODO, uint32_t this_ptr) {
9752         LDKUnsignedNodeAnnouncement this_ptr_conv;
9753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9754         this_ptr_conv.is_owned = false;
9755         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9756         memcpy(ret_arr.ptr, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
9757         return ret_arr;
9758 }
9759
9760 void UnsignedNodeAnnouncement_1set_1alias(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9761         LDKUnsignedNodeAnnouncement this_ptr_conv;
9762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9763         this_ptr_conv.is_owned = false;
9764         LDKThirtyTwoBytes val_ref;
9765         CHECK(val.len == 32);
9766         memcpy(val_ref.data, val.ptr, 32);
9767         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
9768 }
9769
9770 void UnsignedNodeAnnouncement_1set_1addresses(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
9771         LDKUnsignedNodeAnnouncement this_ptr_conv;
9772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9773         this_ptr_conv.is_owned = false;
9774         LDKCVec_NetAddressZ val_constr;
9775         val_constr.datalen = val.len;
9776         if (val_constr.datalen > 0)
9777                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
9778         else
9779                 val_constr.data = NULL;
9780         uint32_t* val_vals = (uint32_t*) val.ptr;
9781         for (size_t m = 0; m < val_constr.datalen; m++) {
9782                 uint32_t arr_conv_12 = val_vals[m];
9783                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
9784                 FREE((void*)arr_conv_12);
9785                 val_constr.data[m] = arr_conv_12_conv;
9786         }
9787         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
9788 }
9789
9790 void NodeAnnouncement_1free(void* ctx_TODO, uint32_t this_ptr) {
9791         LDKNodeAnnouncement this_ptr_conv;
9792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9793         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9794         NodeAnnouncement_free(this_ptr_conv);
9795 }
9796
9797 uint32_t NodeAnnouncement_1clone(void* ctx_TODO, uint32_t orig) {
9798         LDKNodeAnnouncement orig_conv;
9799         orig_conv.inner = (void*)(orig & (~1));
9800         orig_conv.is_owned = false;
9801         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
9802         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9803         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9804         long ret_ref = (long)ret_var.inner;
9805         if (ret_var.is_owned) {
9806                 ret_ref |= 1;
9807         }
9808         return ret_ref;
9809 }
9810
9811 int8_tArray NodeAnnouncement_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
9812         LDKNodeAnnouncement this_ptr_conv;
9813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9814         this_ptr_conv.is_owned = false;
9815         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
9816         memcpy(arg_arr.ptr, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
9817         return arg_arr;
9818 }
9819
9820 void NodeAnnouncement_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9821         LDKNodeAnnouncement this_ptr_conv;
9822         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9823         this_ptr_conv.is_owned = false;
9824         LDKSignature val_ref;
9825         CHECK(val.len == 64);
9826         memcpy(val_ref.compact_form, val.ptr, 64);
9827         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
9828 }
9829
9830 uint32_t NodeAnnouncement_1get_1contents(void* ctx_TODO, uint32_t this_ptr) {
9831         LDKNodeAnnouncement this_ptr_conv;
9832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9833         this_ptr_conv.is_owned = false;
9834         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
9835         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9836         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9837         long ret_ref = (long)ret_var.inner;
9838         if (ret_var.is_owned) {
9839                 ret_ref |= 1;
9840         }
9841         return ret_ref;
9842 }
9843
9844 void NodeAnnouncement_1set_1contents(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
9845         LDKNodeAnnouncement this_ptr_conv;
9846         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9847         this_ptr_conv.is_owned = false;
9848         LDKUnsignedNodeAnnouncement val_conv;
9849         val_conv.inner = (void*)(val & (~1));
9850         val_conv.is_owned = (val & 1) || (val == 0);
9851         if (val_conv.inner != NULL)
9852                 val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
9853         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
9854 }
9855
9856 uint32_t NodeAnnouncement_1new(void* ctx_TODO, int8_tArray signature_arg, uint32_t contents_arg) {
9857         LDKSignature signature_arg_ref;
9858         CHECK(signature_arg.len == 64);
9859         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
9860         LDKUnsignedNodeAnnouncement contents_arg_conv;
9861         contents_arg_conv.inner = (void*)(contents_arg & (~1));
9862         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
9863         if (contents_arg_conv.inner != NULL)
9864                 contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
9865         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
9866         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9867         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9868         long ret_ref = (long)ret_var.inner;
9869         if (ret_var.is_owned) {
9870                 ret_ref |= 1;
9871         }
9872         return ret_ref;
9873 }
9874
9875 void UnsignedChannelAnnouncement_1free(void* ctx_TODO, uint32_t this_ptr) {
9876         LDKUnsignedChannelAnnouncement this_ptr_conv;
9877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9878         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9879         UnsignedChannelAnnouncement_free(this_ptr_conv);
9880 }
9881
9882 uint32_t UnsignedChannelAnnouncement_1clone(void* ctx_TODO, uint32_t orig) {
9883         LDKUnsignedChannelAnnouncement orig_conv;
9884         orig_conv.inner = (void*)(orig & (~1));
9885         orig_conv.is_owned = false;
9886         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
9887         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9888         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9889         long ret_ref = (long)ret_var.inner;
9890         if (ret_var.is_owned) {
9891                 ret_ref |= 1;
9892         }
9893         return ret_ref;
9894 }
9895
9896 uint32_t UnsignedChannelAnnouncement_1get_1features(void* ctx_TODO, uint32_t this_ptr) {
9897         LDKUnsignedChannelAnnouncement this_ptr_conv;
9898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9899         this_ptr_conv.is_owned = false;
9900         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
9901         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9902         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9903         long ret_ref = (long)ret_var.inner;
9904         if (ret_var.is_owned) {
9905                 ret_ref |= 1;
9906         }
9907         return ret_ref;
9908 }
9909
9910 void UnsignedChannelAnnouncement_1set_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
9911         LDKUnsignedChannelAnnouncement this_ptr_conv;
9912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9913         this_ptr_conv.is_owned = false;
9914         LDKChannelFeatures val_conv;
9915         val_conv.inner = (void*)(val & (~1));
9916         val_conv.is_owned = (val & 1) || (val == 0);
9917         // Warning: we may need a move here but can't clone!
9918         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
9919 }
9920
9921 int8_tArray UnsignedChannelAnnouncement_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
9922         LDKUnsignedChannelAnnouncement this_ptr_conv;
9923         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9924         this_ptr_conv.is_owned = false;
9925         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
9926         memcpy(ret_arr.ptr, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
9927         return ret_arr;
9928 }
9929
9930 void UnsignedChannelAnnouncement_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9931         LDKUnsignedChannelAnnouncement this_ptr_conv;
9932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9933         this_ptr_conv.is_owned = false;
9934         LDKThirtyTwoBytes val_ref;
9935         CHECK(val.len == 32);
9936         memcpy(val_ref.data, val.ptr, 32);
9937         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
9938 }
9939
9940 int64_t UnsignedChannelAnnouncement_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
9941         LDKUnsignedChannelAnnouncement this_ptr_conv;
9942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9943         this_ptr_conv.is_owned = false;
9944         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
9945         return ret_val;
9946 }
9947
9948 void UnsignedChannelAnnouncement_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
9949         LDKUnsignedChannelAnnouncement this_ptr_conv;
9950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9951         this_ptr_conv.is_owned = false;
9952         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
9953 }
9954
9955 int8_tArray UnsignedChannelAnnouncement_1get_1node_1id_11(void* ctx_TODO, uint32_t this_ptr) {
9956         LDKUnsignedChannelAnnouncement this_ptr_conv;
9957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9958         this_ptr_conv.is_owned = false;
9959         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9960         memcpy(arg_arr.ptr, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
9961         return arg_arr;
9962 }
9963
9964 void UnsignedChannelAnnouncement_1set_1node_1id_11(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9965         LDKUnsignedChannelAnnouncement this_ptr_conv;
9966         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9967         this_ptr_conv.is_owned = false;
9968         LDKPublicKey val_ref;
9969         CHECK(val.len == 33);
9970         memcpy(val_ref.compressed_form, val.ptr, 33);
9971         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
9972 }
9973
9974 int8_tArray UnsignedChannelAnnouncement_1get_1node_1id_12(void* ctx_TODO, uint32_t this_ptr) {
9975         LDKUnsignedChannelAnnouncement this_ptr_conv;
9976         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9977         this_ptr_conv.is_owned = false;
9978         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9979         memcpy(arg_arr.ptr, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
9980         return arg_arr;
9981 }
9982
9983 void UnsignedChannelAnnouncement_1set_1node_1id_12(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
9984         LDKUnsignedChannelAnnouncement this_ptr_conv;
9985         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9986         this_ptr_conv.is_owned = false;
9987         LDKPublicKey val_ref;
9988         CHECK(val.len == 33);
9989         memcpy(val_ref.compressed_form, val.ptr, 33);
9990         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
9991 }
9992
9993 int8_tArray UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(void* ctx_TODO, uint32_t this_ptr) {
9994         LDKUnsignedChannelAnnouncement this_ptr_conv;
9995         this_ptr_conv.inner = (void*)(this_ptr & (~1));
9996         this_ptr_conv.is_owned = false;
9997         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
9998         memcpy(arg_arr.ptr, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
9999         return arg_arr;
10000 }
10001
10002 void UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10003         LDKUnsignedChannelAnnouncement this_ptr_conv;
10004         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10005         this_ptr_conv.is_owned = false;
10006         LDKPublicKey val_ref;
10007         CHECK(val.len == 33);
10008         memcpy(val_ref.compressed_form, val.ptr, 33);
10009         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
10010 }
10011
10012 int8_tArray UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(void* ctx_TODO, uint32_t this_ptr) {
10013         LDKUnsignedChannelAnnouncement this_ptr_conv;
10014         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10015         this_ptr_conv.is_owned = false;
10016         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
10017         memcpy(arg_arr.ptr, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
10018         return arg_arr;
10019 }
10020
10021 void UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10022         LDKUnsignedChannelAnnouncement this_ptr_conv;
10023         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10024         this_ptr_conv.is_owned = false;
10025         LDKPublicKey val_ref;
10026         CHECK(val.len == 33);
10027         memcpy(val_ref.compressed_form, val.ptr, 33);
10028         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
10029 }
10030
10031 void ChannelAnnouncement_1free(void* ctx_TODO, uint32_t this_ptr) {
10032         LDKChannelAnnouncement this_ptr_conv;
10033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10034         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10035         ChannelAnnouncement_free(this_ptr_conv);
10036 }
10037
10038 uint32_t ChannelAnnouncement_1clone(void* ctx_TODO, uint32_t orig) {
10039         LDKChannelAnnouncement orig_conv;
10040         orig_conv.inner = (void*)(orig & (~1));
10041         orig_conv.is_owned = false;
10042         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
10043         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10044         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10045         long ret_ref = (long)ret_var.inner;
10046         if (ret_var.is_owned) {
10047                 ret_ref |= 1;
10048         }
10049         return ret_ref;
10050 }
10051
10052 int8_tArray ChannelAnnouncement_1get_1node_1signature_11(void* ctx_TODO, uint32_t this_ptr) {
10053         LDKChannelAnnouncement this_ptr_conv;
10054         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10055         this_ptr_conv.is_owned = false;
10056         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
10057         memcpy(arg_arr.ptr, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
10058         return arg_arr;
10059 }
10060
10061 void ChannelAnnouncement_1set_1node_1signature_11(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10062         LDKChannelAnnouncement this_ptr_conv;
10063         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10064         this_ptr_conv.is_owned = false;
10065         LDKSignature val_ref;
10066         CHECK(val.len == 64);
10067         memcpy(val_ref.compact_form, val.ptr, 64);
10068         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
10069 }
10070
10071 int8_tArray ChannelAnnouncement_1get_1node_1signature_12(void* ctx_TODO, uint32_t this_ptr) {
10072         LDKChannelAnnouncement this_ptr_conv;
10073         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10074         this_ptr_conv.is_owned = false;
10075         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
10076         memcpy(arg_arr.ptr, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
10077         return arg_arr;
10078 }
10079
10080 void ChannelAnnouncement_1set_1node_1signature_12(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10081         LDKChannelAnnouncement this_ptr_conv;
10082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10083         this_ptr_conv.is_owned = false;
10084         LDKSignature val_ref;
10085         CHECK(val.len == 64);
10086         memcpy(val_ref.compact_form, val.ptr, 64);
10087         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
10088 }
10089
10090 int8_tArray ChannelAnnouncement_1get_1bitcoin_1signature_11(void* ctx_TODO, uint32_t this_ptr) {
10091         LDKChannelAnnouncement this_ptr_conv;
10092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10093         this_ptr_conv.is_owned = false;
10094         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
10095         memcpy(arg_arr.ptr, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
10096         return arg_arr;
10097 }
10098
10099 void ChannelAnnouncement_1set_1bitcoin_1signature_11(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10100         LDKChannelAnnouncement this_ptr_conv;
10101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10102         this_ptr_conv.is_owned = false;
10103         LDKSignature val_ref;
10104         CHECK(val.len == 64);
10105         memcpy(val_ref.compact_form, val.ptr, 64);
10106         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
10107 }
10108
10109 int8_tArray ChannelAnnouncement_1get_1bitcoin_1signature_12(void* ctx_TODO, uint32_t this_ptr) {
10110         LDKChannelAnnouncement this_ptr_conv;
10111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10112         this_ptr_conv.is_owned = false;
10113         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
10114         memcpy(arg_arr.ptr, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
10115         return arg_arr;
10116 }
10117
10118 void ChannelAnnouncement_1set_1bitcoin_1signature_12(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10119         LDKChannelAnnouncement this_ptr_conv;
10120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10121         this_ptr_conv.is_owned = false;
10122         LDKSignature val_ref;
10123         CHECK(val.len == 64);
10124         memcpy(val_ref.compact_form, val.ptr, 64);
10125         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
10126 }
10127
10128 uint32_t ChannelAnnouncement_1get_1contents(void* ctx_TODO, uint32_t this_ptr) {
10129         LDKChannelAnnouncement this_ptr_conv;
10130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10131         this_ptr_conv.is_owned = false;
10132         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
10133         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10134         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10135         long ret_ref = (long)ret_var.inner;
10136         if (ret_var.is_owned) {
10137                 ret_ref |= 1;
10138         }
10139         return ret_ref;
10140 }
10141
10142 void ChannelAnnouncement_1set_1contents(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
10143         LDKChannelAnnouncement this_ptr_conv;
10144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10145         this_ptr_conv.is_owned = false;
10146         LDKUnsignedChannelAnnouncement val_conv;
10147         val_conv.inner = (void*)(val & (~1));
10148         val_conv.is_owned = (val & 1) || (val == 0);
10149         if (val_conv.inner != NULL)
10150                 val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
10151         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
10152 }
10153
10154 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) {
10155         LDKSignature node_signature_1_arg_ref;
10156         CHECK(node_signature_1_arg.len == 64);
10157         memcpy(node_signature_1_arg_ref.compact_form, node_signature_1_arg.ptr, 64);
10158         LDKSignature node_signature_2_arg_ref;
10159         CHECK(node_signature_2_arg.len == 64);
10160         memcpy(node_signature_2_arg_ref.compact_form, node_signature_2_arg.ptr, 64);
10161         LDKSignature bitcoin_signature_1_arg_ref;
10162         CHECK(bitcoin_signature_1_arg.len == 64);
10163         memcpy(bitcoin_signature_1_arg_ref.compact_form, bitcoin_signature_1_arg.ptr, 64);
10164         LDKSignature bitcoin_signature_2_arg_ref;
10165         CHECK(bitcoin_signature_2_arg.len == 64);
10166         memcpy(bitcoin_signature_2_arg_ref.compact_form, bitcoin_signature_2_arg.ptr, 64);
10167         LDKUnsignedChannelAnnouncement contents_arg_conv;
10168         contents_arg_conv.inner = (void*)(contents_arg & (~1));
10169         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
10170         if (contents_arg_conv.inner != NULL)
10171                 contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
10172         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);
10173         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10174         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10175         long ret_ref = (long)ret_var.inner;
10176         if (ret_var.is_owned) {
10177                 ret_ref |= 1;
10178         }
10179         return ret_ref;
10180 }
10181
10182 void UnsignedChannelUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
10183         LDKUnsignedChannelUpdate this_ptr_conv;
10184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10185         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10186         UnsignedChannelUpdate_free(this_ptr_conv);
10187 }
10188
10189 uint32_t UnsignedChannelUpdate_1clone(void* ctx_TODO, uint32_t orig) {
10190         LDKUnsignedChannelUpdate orig_conv;
10191         orig_conv.inner = (void*)(orig & (~1));
10192         orig_conv.is_owned = false;
10193         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
10194         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10195         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10196         long ret_ref = (long)ret_var.inner;
10197         if (ret_var.is_owned) {
10198                 ret_ref |= 1;
10199         }
10200         return ret_ref;
10201 }
10202
10203 int8_tArray UnsignedChannelUpdate_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10204         LDKUnsignedChannelUpdate this_ptr_conv;
10205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10206         this_ptr_conv.is_owned = false;
10207         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10208         memcpy(ret_arr.ptr, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
10209         return ret_arr;
10210 }
10211
10212 void UnsignedChannelUpdate_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10213         LDKUnsignedChannelUpdate this_ptr_conv;
10214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10215         this_ptr_conv.is_owned = false;
10216         LDKThirtyTwoBytes val_ref;
10217         CHECK(val.len == 32);
10218         memcpy(val_ref.data, val.ptr, 32);
10219         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
10220 }
10221
10222 int64_t UnsignedChannelUpdate_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
10223         LDKUnsignedChannelUpdate this_ptr_conv;
10224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10225         this_ptr_conv.is_owned = false;
10226         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
10227         return ret_val;
10228 }
10229
10230 void UnsignedChannelUpdate_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
10231         LDKUnsignedChannelUpdate this_ptr_conv;
10232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10233         this_ptr_conv.is_owned = false;
10234         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
10235 }
10236
10237 int32_t UnsignedChannelUpdate_1get_1timestamp(void* ctx_TODO, uint32_t this_ptr) {
10238         LDKUnsignedChannelUpdate this_ptr_conv;
10239         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10240         this_ptr_conv.is_owned = false;
10241         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
10242         return ret_val;
10243 }
10244
10245 void UnsignedChannelUpdate_1set_1timestamp(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10246         LDKUnsignedChannelUpdate this_ptr_conv;
10247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10248         this_ptr_conv.is_owned = false;
10249         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
10250 }
10251
10252 int8_t UnsignedChannelUpdate_1get_1flags(void* ctx_TODO, uint32_t this_ptr) {
10253         LDKUnsignedChannelUpdate this_ptr_conv;
10254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10255         this_ptr_conv.is_owned = false;
10256         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
10257         return ret_val;
10258 }
10259
10260 void UnsignedChannelUpdate_1set_1flags(void* ctx_TODO, uint32_t this_ptr, int8_t val) {
10261         LDKUnsignedChannelUpdate this_ptr_conv;
10262         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10263         this_ptr_conv.is_owned = false;
10264         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
10265 }
10266
10267 jshort UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr) {
10268         LDKUnsignedChannelUpdate this_ptr_conv;
10269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10270         this_ptr_conv.is_owned = false;
10271         jshort ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
10272         return ret_val;
10273 }
10274
10275 void UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr, jshort val) {
10276         LDKUnsignedChannelUpdate this_ptr_conv;
10277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10278         this_ptr_conv.is_owned = false;
10279         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
10280 }
10281
10282 int64_t UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
10283         LDKUnsignedChannelUpdate this_ptr_conv;
10284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10285         this_ptr_conv.is_owned = false;
10286         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
10287         return ret_val;
10288 }
10289
10290 void UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
10291         LDKUnsignedChannelUpdate this_ptr_conv;
10292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10293         this_ptr_conv.is_owned = false;
10294         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
10295 }
10296
10297 int32_t UnsignedChannelUpdate_1get_1fee_1base_1msat(void* ctx_TODO, uint32_t this_ptr) {
10298         LDKUnsignedChannelUpdate this_ptr_conv;
10299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10300         this_ptr_conv.is_owned = false;
10301         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
10302         return ret_val;
10303 }
10304
10305 void UnsignedChannelUpdate_1set_1fee_1base_1msat(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10306         LDKUnsignedChannelUpdate this_ptr_conv;
10307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10308         this_ptr_conv.is_owned = false;
10309         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
10310 }
10311
10312 int32_t UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr) {
10313         LDKUnsignedChannelUpdate this_ptr_conv;
10314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10315         this_ptr_conv.is_owned = false;
10316         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
10317         return ret_val;
10318 }
10319
10320 void UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10321         LDKUnsignedChannelUpdate this_ptr_conv;
10322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10323         this_ptr_conv.is_owned = false;
10324         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
10325 }
10326
10327 void ChannelUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
10328         LDKChannelUpdate this_ptr_conv;
10329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10330         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10331         ChannelUpdate_free(this_ptr_conv);
10332 }
10333
10334 uint32_t ChannelUpdate_1clone(void* ctx_TODO, uint32_t orig) {
10335         LDKChannelUpdate orig_conv;
10336         orig_conv.inner = (void*)(orig & (~1));
10337         orig_conv.is_owned = false;
10338         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
10339         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10340         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10341         long ret_ref = (long)ret_var.inner;
10342         if (ret_var.is_owned) {
10343                 ret_ref |= 1;
10344         }
10345         return ret_ref;
10346 }
10347
10348 int8_tArray ChannelUpdate_1get_1signature(void* ctx_TODO, uint32_t this_ptr) {
10349         LDKChannelUpdate this_ptr_conv;
10350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10351         this_ptr_conv.is_owned = false;
10352         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
10353         memcpy(arg_arr.ptr, ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
10354         return arg_arr;
10355 }
10356
10357 void ChannelUpdate_1set_1signature(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10358         LDKChannelUpdate this_ptr_conv;
10359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10360         this_ptr_conv.is_owned = false;
10361         LDKSignature val_ref;
10362         CHECK(val.len == 64);
10363         memcpy(val_ref.compact_form, val.ptr, 64);
10364         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
10365 }
10366
10367 uint32_t ChannelUpdate_1get_1contents(void* ctx_TODO, uint32_t this_ptr) {
10368         LDKChannelUpdate this_ptr_conv;
10369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10370         this_ptr_conv.is_owned = false;
10371         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
10372         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10373         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10374         long ret_ref = (long)ret_var.inner;
10375         if (ret_var.is_owned) {
10376                 ret_ref |= 1;
10377         }
10378         return ret_ref;
10379 }
10380
10381 void ChannelUpdate_1set_1contents(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
10382         LDKChannelUpdate this_ptr_conv;
10383         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10384         this_ptr_conv.is_owned = false;
10385         LDKUnsignedChannelUpdate val_conv;
10386         val_conv.inner = (void*)(val & (~1));
10387         val_conv.is_owned = (val & 1) || (val == 0);
10388         if (val_conv.inner != NULL)
10389                 val_conv = UnsignedChannelUpdate_clone(&val_conv);
10390         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
10391 }
10392
10393 uint32_t ChannelUpdate_1new(void* ctx_TODO, int8_tArray signature_arg, uint32_t contents_arg) {
10394         LDKSignature signature_arg_ref;
10395         CHECK(signature_arg.len == 64);
10396         memcpy(signature_arg_ref.compact_form, signature_arg.ptr, 64);
10397         LDKUnsignedChannelUpdate contents_arg_conv;
10398         contents_arg_conv.inner = (void*)(contents_arg & (~1));
10399         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
10400         if (contents_arg_conv.inner != NULL)
10401                 contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
10402         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
10403         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10404         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10405         long ret_ref = (long)ret_var.inner;
10406         if (ret_var.is_owned) {
10407                 ret_ref |= 1;
10408         }
10409         return ret_ref;
10410 }
10411
10412 void QueryChannelRange_1free(void* ctx_TODO, uint32_t this_ptr) {
10413         LDKQueryChannelRange this_ptr_conv;
10414         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10415         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10416         QueryChannelRange_free(this_ptr_conv);
10417 }
10418
10419 uint32_t QueryChannelRange_1clone(void* ctx_TODO, uint32_t orig) {
10420         LDKQueryChannelRange orig_conv;
10421         orig_conv.inner = (void*)(orig & (~1));
10422         orig_conv.is_owned = false;
10423         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
10424         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10425         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10426         long ret_ref = (long)ret_var.inner;
10427         if (ret_var.is_owned) {
10428                 ret_ref |= 1;
10429         }
10430         return ret_ref;
10431 }
10432
10433 int8_tArray QueryChannelRange_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10434         LDKQueryChannelRange this_ptr_conv;
10435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10436         this_ptr_conv.is_owned = false;
10437         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10438         memcpy(ret_arr.ptr, *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
10439         return ret_arr;
10440 }
10441
10442 void QueryChannelRange_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10443         LDKQueryChannelRange this_ptr_conv;
10444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10445         this_ptr_conv.is_owned = false;
10446         LDKThirtyTwoBytes val_ref;
10447         CHECK(val.len == 32);
10448         memcpy(val_ref.data, val.ptr, 32);
10449         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
10450 }
10451
10452 int32_t QueryChannelRange_1get_1first_1blocknum(void* ctx_TODO, uint32_t this_ptr) {
10453         LDKQueryChannelRange this_ptr_conv;
10454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10455         this_ptr_conv.is_owned = false;
10456         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
10457         return ret_val;
10458 }
10459
10460 void QueryChannelRange_1set_1first_1blocknum(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10461         LDKQueryChannelRange this_ptr_conv;
10462         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10463         this_ptr_conv.is_owned = false;
10464         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
10465 }
10466
10467 int32_t QueryChannelRange_1get_1number_1of_1blocks(void* ctx_TODO, uint32_t this_ptr) {
10468         LDKQueryChannelRange this_ptr_conv;
10469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10470         this_ptr_conv.is_owned = false;
10471         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
10472         return ret_val;
10473 }
10474
10475 void QueryChannelRange_1set_1number_1of_1blocks(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10476         LDKQueryChannelRange this_ptr_conv;
10477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10478         this_ptr_conv.is_owned = false;
10479         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
10480 }
10481
10482 uint32_t QueryChannelRange_1new(void* ctx_TODO, int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
10483         LDKThirtyTwoBytes chain_hash_arg_ref;
10484         CHECK(chain_hash_arg.len == 32);
10485         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
10486         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
10487         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10488         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10489         long ret_ref = (long)ret_var.inner;
10490         if (ret_var.is_owned) {
10491                 ret_ref |= 1;
10492         }
10493         return ret_ref;
10494 }
10495
10496 void ReplyChannelRange_1free(void* ctx_TODO, uint32_t this_ptr) {
10497         LDKReplyChannelRange this_ptr_conv;
10498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10499         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10500         ReplyChannelRange_free(this_ptr_conv);
10501 }
10502
10503 uint32_t ReplyChannelRange_1clone(void* ctx_TODO, uint32_t orig) {
10504         LDKReplyChannelRange orig_conv;
10505         orig_conv.inner = (void*)(orig & (~1));
10506         orig_conv.is_owned = false;
10507         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
10508         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10509         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10510         long ret_ref = (long)ret_var.inner;
10511         if (ret_var.is_owned) {
10512                 ret_ref |= 1;
10513         }
10514         return ret_ref;
10515 }
10516
10517 int8_tArray ReplyChannelRange_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10518         LDKReplyChannelRange this_ptr_conv;
10519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10520         this_ptr_conv.is_owned = false;
10521         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10522         memcpy(ret_arr.ptr, *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
10523         return ret_arr;
10524 }
10525
10526 void ReplyChannelRange_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10527         LDKReplyChannelRange this_ptr_conv;
10528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10529         this_ptr_conv.is_owned = false;
10530         LDKThirtyTwoBytes val_ref;
10531         CHECK(val.len == 32);
10532         memcpy(val_ref.data, val.ptr, 32);
10533         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
10534 }
10535
10536 int32_t ReplyChannelRange_1get_1first_1blocknum(void* ctx_TODO, uint32_t this_ptr) {
10537         LDKReplyChannelRange this_ptr_conv;
10538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10539         this_ptr_conv.is_owned = false;
10540         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
10541         return ret_val;
10542 }
10543
10544 void ReplyChannelRange_1set_1first_1blocknum(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10545         LDKReplyChannelRange this_ptr_conv;
10546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10547         this_ptr_conv.is_owned = false;
10548         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
10549 }
10550
10551 int32_t ReplyChannelRange_1get_1number_1of_1blocks(void* ctx_TODO, uint32_t this_ptr) {
10552         LDKReplyChannelRange this_ptr_conv;
10553         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10554         this_ptr_conv.is_owned = false;
10555         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
10556         return ret_val;
10557 }
10558
10559 void ReplyChannelRange_1set_1number_1of_1blocks(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10560         LDKReplyChannelRange this_ptr_conv;
10561         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10562         this_ptr_conv.is_owned = false;
10563         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
10564 }
10565
10566 jboolean ReplyChannelRange_1get_1full_1information(void* ctx_TODO, uint32_t this_ptr) {
10567         LDKReplyChannelRange this_ptr_conv;
10568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10569         this_ptr_conv.is_owned = false;
10570         jboolean ret_val = ReplyChannelRange_get_full_information(&this_ptr_conv);
10571         return ret_val;
10572 }
10573
10574 void ReplyChannelRange_1set_1full_1information(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
10575         LDKReplyChannelRange this_ptr_conv;
10576         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10577         this_ptr_conv.is_owned = false;
10578         ReplyChannelRange_set_full_information(&this_ptr_conv, val);
10579 }
10580
10581 void ReplyChannelRange_1set_1short_1channel_1ids(void* ctx_TODO, uint32_t this_ptr, int64_tArray val) {
10582         LDKReplyChannelRange this_ptr_conv;
10583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10584         this_ptr_conv.is_owned = false;
10585         LDKCVec_u64Z val_constr;
10586         val_constr.datalen = val.len;
10587         if (val_constr.datalen > 0)
10588                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10589         else
10590                 val_constr.data = NULL;
10591         int64_t* val_vals = (int64_t*) val.ptr;
10592         for (size_t g = 0; g < val_constr.datalen; g++) {
10593                 int64_t arr_conv_6 = val_vals[g];
10594                 val_constr.data[g] = arr_conv_6;
10595         }
10596         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
10597 }
10598
10599 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) {
10600         LDKThirtyTwoBytes chain_hash_arg_ref;
10601         CHECK(chain_hash_arg.len == 32);
10602         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
10603         LDKCVec_u64Z short_channel_ids_arg_constr;
10604         short_channel_ids_arg_constr.datalen = short_channel_ids_arg.len;
10605         if (short_channel_ids_arg_constr.datalen > 0)
10606                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10607         else
10608                 short_channel_ids_arg_constr.data = NULL;
10609         int64_t* short_channel_ids_arg_vals = (int64_t*) short_channel_ids_arg.ptr;
10610         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
10611                 int64_t arr_conv_6 = short_channel_ids_arg_vals[g];
10612                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
10613         }
10614         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr);
10615         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10616         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10617         long ret_ref = (long)ret_var.inner;
10618         if (ret_var.is_owned) {
10619                 ret_ref |= 1;
10620         }
10621         return ret_ref;
10622 }
10623
10624 void QueryShortChannelIds_1free(void* ctx_TODO, uint32_t this_ptr) {
10625         LDKQueryShortChannelIds this_ptr_conv;
10626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10627         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10628         QueryShortChannelIds_free(this_ptr_conv);
10629 }
10630
10631 uint32_t QueryShortChannelIds_1clone(void* ctx_TODO, uint32_t orig) {
10632         LDKQueryShortChannelIds orig_conv;
10633         orig_conv.inner = (void*)(orig & (~1));
10634         orig_conv.is_owned = false;
10635         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
10636         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10637         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10638         long ret_ref = (long)ret_var.inner;
10639         if (ret_var.is_owned) {
10640                 ret_ref |= 1;
10641         }
10642         return ret_ref;
10643 }
10644
10645 int8_tArray QueryShortChannelIds_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10646         LDKQueryShortChannelIds this_ptr_conv;
10647         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10648         this_ptr_conv.is_owned = false;
10649         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10650         memcpy(ret_arr.ptr, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
10651         return ret_arr;
10652 }
10653
10654 void QueryShortChannelIds_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10655         LDKQueryShortChannelIds this_ptr_conv;
10656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10657         this_ptr_conv.is_owned = false;
10658         LDKThirtyTwoBytes val_ref;
10659         CHECK(val.len == 32);
10660         memcpy(val_ref.data, val.ptr, 32);
10661         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
10662 }
10663
10664 void QueryShortChannelIds_1set_1short_1channel_1ids(void* ctx_TODO, uint32_t this_ptr, int64_tArray val) {
10665         LDKQueryShortChannelIds this_ptr_conv;
10666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10667         this_ptr_conv.is_owned = false;
10668         LDKCVec_u64Z val_constr;
10669         val_constr.datalen = val.len;
10670         if (val_constr.datalen > 0)
10671                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10672         else
10673                 val_constr.data = NULL;
10674         int64_t* val_vals = (int64_t*) val.ptr;
10675         for (size_t g = 0; g < val_constr.datalen; g++) {
10676                 int64_t arr_conv_6 = val_vals[g];
10677                 val_constr.data[g] = arr_conv_6;
10678         }
10679         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
10680 }
10681
10682 uint32_t QueryShortChannelIds_1new(void* ctx_TODO, int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
10683         LDKThirtyTwoBytes chain_hash_arg_ref;
10684         CHECK(chain_hash_arg.len == 32);
10685         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
10686         LDKCVec_u64Z short_channel_ids_arg_constr;
10687         short_channel_ids_arg_constr.datalen = short_channel_ids_arg.len;
10688         if (short_channel_ids_arg_constr.datalen > 0)
10689                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
10690         else
10691                 short_channel_ids_arg_constr.data = NULL;
10692         int64_t* short_channel_ids_arg_vals = (int64_t*) short_channel_ids_arg.ptr;
10693         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
10694                 int64_t arr_conv_6 = short_channel_ids_arg_vals[g];
10695                 short_channel_ids_arg_constr.data[g] = arr_conv_6;
10696         }
10697         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
10698         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10699         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10700         long ret_ref = (long)ret_var.inner;
10701         if (ret_var.is_owned) {
10702                 ret_ref |= 1;
10703         }
10704         return ret_ref;
10705 }
10706
10707 void ReplyShortChannelIdsEnd_1free(void* ctx_TODO, uint32_t this_ptr) {
10708         LDKReplyShortChannelIdsEnd this_ptr_conv;
10709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10710         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10711         ReplyShortChannelIdsEnd_free(this_ptr_conv);
10712 }
10713
10714 uint32_t ReplyShortChannelIdsEnd_1clone(void* ctx_TODO, uint32_t orig) {
10715         LDKReplyShortChannelIdsEnd orig_conv;
10716         orig_conv.inner = (void*)(orig & (~1));
10717         orig_conv.is_owned = false;
10718         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
10719         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10720         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10721         long ret_ref = (long)ret_var.inner;
10722         if (ret_var.is_owned) {
10723                 ret_ref |= 1;
10724         }
10725         return ret_ref;
10726 }
10727
10728 int8_tArray ReplyShortChannelIdsEnd_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10729         LDKReplyShortChannelIdsEnd this_ptr_conv;
10730         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10731         this_ptr_conv.is_owned = false;
10732         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10733         memcpy(ret_arr.ptr, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
10734         return ret_arr;
10735 }
10736
10737 void ReplyShortChannelIdsEnd_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10738         LDKReplyShortChannelIdsEnd this_ptr_conv;
10739         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10740         this_ptr_conv.is_owned = false;
10741         LDKThirtyTwoBytes val_ref;
10742         CHECK(val.len == 32);
10743         memcpy(val_ref.data, val.ptr, 32);
10744         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
10745 }
10746
10747 jboolean ReplyShortChannelIdsEnd_1get_1full_1information(void* ctx_TODO, uint32_t this_ptr) {
10748         LDKReplyShortChannelIdsEnd this_ptr_conv;
10749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10750         this_ptr_conv.is_owned = false;
10751         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
10752         return ret_val;
10753 }
10754
10755 void ReplyShortChannelIdsEnd_1set_1full_1information(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
10756         LDKReplyShortChannelIdsEnd this_ptr_conv;
10757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10758         this_ptr_conv.is_owned = false;
10759         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
10760 }
10761
10762 uint32_t ReplyShortChannelIdsEnd_1new(void* ctx_TODO, int8_tArray chain_hash_arg, jboolean full_information_arg) {
10763         LDKThirtyTwoBytes chain_hash_arg_ref;
10764         CHECK(chain_hash_arg.len == 32);
10765         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
10766         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
10767         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10768         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10769         long ret_ref = (long)ret_var.inner;
10770         if (ret_var.is_owned) {
10771                 ret_ref |= 1;
10772         }
10773         return ret_ref;
10774 }
10775
10776 void GossipTimestampFilter_1free(void* ctx_TODO, uint32_t this_ptr) {
10777         LDKGossipTimestampFilter this_ptr_conv;
10778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10779         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10780         GossipTimestampFilter_free(this_ptr_conv);
10781 }
10782
10783 uint32_t GossipTimestampFilter_1clone(void* ctx_TODO, uint32_t orig) {
10784         LDKGossipTimestampFilter orig_conv;
10785         orig_conv.inner = (void*)(orig & (~1));
10786         orig_conv.is_owned = false;
10787         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
10788         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10789         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10790         long ret_ref = (long)ret_var.inner;
10791         if (ret_var.is_owned) {
10792                 ret_ref |= 1;
10793         }
10794         return ret_ref;
10795 }
10796
10797 int8_tArray GossipTimestampFilter_1get_1chain_1hash(void* ctx_TODO, uint32_t this_ptr) {
10798         LDKGossipTimestampFilter this_ptr_conv;
10799         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10800         this_ptr_conv.is_owned = false;
10801         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
10802         memcpy(ret_arr.ptr, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
10803         return ret_arr;
10804 }
10805
10806 void GossipTimestampFilter_1set_1chain_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10807         LDKGossipTimestampFilter this_ptr_conv;
10808         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10809         this_ptr_conv.is_owned = false;
10810         LDKThirtyTwoBytes val_ref;
10811         CHECK(val.len == 32);
10812         memcpy(val_ref.data, val.ptr, 32);
10813         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
10814 }
10815
10816 int32_t GossipTimestampFilter_1get_1first_1timestamp(void* ctx_TODO, uint32_t this_ptr) {
10817         LDKGossipTimestampFilter this_ptr_conv;
10818         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10819         this_ptr_conv.is_owned = false;
10820         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
10821         return ret_val;
10822 }
10823
10824 void GossipTimestampFilter_1set_1first_1timestamp(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10825         LDKGossipTimestampFilter this_ptr_conv;
10826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10827         this_ptr_conv.is_owned = false;
10828         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
10829 }
10830
10831 int32_t GossipTimestampFilter_1get_1timestamp_1range(void* ctx_TODO, uint32_t this_ptr) {
10832         LDKGossipTimestampFilter this_ptr_conv;
10833         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10834         this_ptr_conv.is_owned = false;
10835         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
10836         return ret_val;
10837 }
10838
10839 void GossipTimestampFilter_1set_1timestamp_1range(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
10840         LDKGossipTimestampFilter this_ptr_conv;
10841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10842         this_ptr_conv.is_owned = false;
10843         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
10844 }
10845
10846 uint32_t GossipTimestampFilter_1new(void* ctx_TODO, int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
10847         LDKThirtyTwoBytes chain_hash_arg_ref;
10848         CHECK(chain_hash_arg.len == 32);
10849         memcpy(chain_hash_arg_ref.data, chain_hash_arg.ptr, 32);
10850         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
10851         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10852         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10853         long ret_ref = (long)ret_var.inner;
10854         if (ret_var.is_owned) {
10855                 ret_ref |= 1;
10856         }
10857         return ret_ref;
10858 }
10859
10860 void ErrorAction_1free(void* ctx_TODO, uint32_t this_ptr) {
10861         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
10862         FREE((void*)this_ptr);
10863         ErrorAction_free(this_ptr_conv);
10864 }
10865
10866 uint32_t ErrorAction_1clone(void* ctx_TODO, uint32_t orig) {
10867         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
10868         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10869         *ret_copy = ErrorAction_clone(orig_conv);
10870         long ret_ref = (long)ret_copy;
10871         return ret_ref;
10872 }
10873
10874 void LightningError_1free(void* ctx_TODO, uint32_t this_ptr) {
10875         LDKLightningError this_ptr_conv;
10876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10877         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10878         LightningError_free(this_ptr_conv);
10879 }
10880
10881 jstring LightningError_1get_1err(void* ctx_TODO, uint32_t this_ptr) {
10882         LDKLightningError this_ptr_conv;
10883         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10884         this_ptr_conv.is_owned = false;
10885         LDKStr _str = LightningError_get_err(&this_ptr_conv);
10886         char* _buf = MALLOC(_str.len + 1, "str conv buf");
10887         memcpy(_buf, _str.chars, _str.len);
10888         _buf[_str.len] = 0;
10889         jstring _conv = (*env)->NewStringUTF(env, _str.chars);
10890         FREE(_buf);
10891         return _conv;
10892 }
10893
10894 void LightningError_1set_1err(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
10895         LDKLightningError this_ptr_conv;
10896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10897         this_ptr_conv.is_owned = false;
10898         LDKCVec_u8Z val_ref;
10899         val_ref.datalen = val.len;
10900         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
10901         memcpy(val_ref.data, val.ptr, val_ref.datalen);
10902         LightningError_set_err(&this_ptr_conv, val_ref);
10903 }
10904
10905 uint32_t LightningError_1get_1action(void* ctx_TODO, uint32_t this_ptr) {
10906         LDKLightningError this_ptr_conv;
10907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10908         this_ptr_conv.is_owned = false;
10909         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
10910         *ret_copy = LightningError_get_action(&this_ptr_conv);
10911         long ret_ref = (long)ret_copy;
10912         return ret_ref;
10913 }
10914
10915 void LightningError_1set_1action(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
10916         LDKLightningError this_ptr_conv;
10917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10918         this_ptr_conv.is_owned = false;
10919         LDKErrorAction val_conv = *(LDKErrorAction*)val;
10920         FREE((void*)val);
10921         LightningError_set_action(&this_ptr_conv, val_conv);
10922 }
10923
10924 uint32_t LightningError_1new(void* ctx_TODO, int8_tArray err_arg, uint32_t action_arg) {
10925         LDKCVec_u8Z err_arg_ref;
10926         err_arg_ref.datalen = err_arg.len;
10927         err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
10928         memcpy(err_arg_ref.data, err_arg.ptr, err_arg_ref.datalen);
10929         LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
10930         FREE((void*)action_arg);
10931         LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
10932         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10933         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10934         long ret_ref = (long)ret_var.inner;
10935         if (ret_var.is_owned) {
10936                 ret_ref |= 1;
10937         }
10938         return ret_ref;
10939 }
10940
10941 void CommitmentUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
10942         LDKCommitmentUpdate this_ptr_conv;
10943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10944         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10945         CommitmentUpdate_free(this_ptr_conv);
10946 }
10947
10948 uint32_t CommitmentUpdate_1clone(void* ctx_TODO, uint32_t orig) {
10949         LDKCommitmentUpdate orig_conv;
10950         orig_conv.inner = (void*)(orig & (~1));
10951         orig_conv.is_owned = false;
10952         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
10953         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10954         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10955         long ret_ref = (long)ret_var.inner;
10956         if (ret_var.is_owned) {
10957                 ret_ref |= 1;
10958         }
10959         return ret_ref;
10960 }
10961
10962 void CommitmentUpdate_1set_1update_1add_1htlcs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
10963         LDKCommitmentUpdate this_ptr_conv;
10964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10965         this_ptr_conv.is_owned = false;
10966         LDKCVec_UpdateAddHTLCZ val_constr;
10967         val_constr.datalen = val.len;
10968         if (val_constr.datalen > 0)
10969                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
10970         else
10971                 val_constr.data = NULL;
10972         uint32_t* val_vals = (uint32_t*) val.ptr;
10973         for (size_t p = 0; p < val_constr.datalen; p++) {
10974                 uint32_t arr_conv_15 = val_vals[p];
10975                 LDKUpdateAddHTLC arr_conv_15_conv;
10976                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
10977                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
10978                 if (arr_conv_15_conv.inner != NULL)
10979                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
10980                 val_constr.data[p] = arr_conv_15_conv;
10981         }
10982         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
10983 }
10984
10985 void CommitmentUpdate_1set_1update_1fulfill_1htlcs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
10986         LDKCommitmentUpdate this_ptr_conv;
10987         this_ptr_conv.inner = (void*)(this_ptr & (~1));
10988         this_ptr_conv.is_owned = false;
10989         LDKCVec_UpdateFulfillHTLCZ val_constr;
10990         val_constr.datalen = val.len;
10991         if (val_constr.datalen > 0)
10992                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
10993         else
10994                 val_constr.data = NULL;
10995         uint32_t* val_vals = (uint32_t*) val.ptr;
10996         for (size_t t = 0; t < val_constr.datalen; t++) {
10997                 uint32_t arr_conv_19 = val_vals[t];
10998                 LDKUpdateFulfillHTLC arr_conv_19_conv;
10999                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
11000                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
11001                 if (arr_conv_19_conv.inner != NULL)
11002                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
11003                 val_constr.data[t] = arr_conv_19_conv;
11004         }
11005         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
11006 }
11007
11008 void CommitmentUpdate_1set_1update_1fail_1htlcs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
11009         LDKCommitmentUpdate this_ptr_conv;
11010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11011         this_ptr_conv.is_owned = false;
11012         LDKCVec_UpdateFailHTLCZ val_constr;
11013         val_constr.datalen = val.len;
11014         if (val_constr.datalen > 0)
11015                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11016         else
11017                 val_constr.data = NULL;
11018         uint32_t* val_vals = (uint32_t*) val.ptr;
11019         for (size_t q = 0; q < val_constr.datalen; q++) {
11020                 uint32_t arr_conv_16 = val_vals[q];
11021                 LDKUpdateFailHTLC arr_conv_16_conv;
11022                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
11023                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
11024                 if (arr_conv_16_conv.inner != NULL)
11025                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
11026                 val_constr.data[q] = arr_conv_16_conv;
11027         }
11028         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
11029 }
11030
11031 void CommitmentUpdate_1set_1update_1fail_1malformed_1htlcs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
11032         LDKCommitmentUpdate this_ptr_conv;
11033         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11034         this_ptr_conv.is_owned = false;
11035         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
11036         val_constr.datalen = val.len;
11037         if (val_constr.datalen > 0)
11038                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11039         else
11040                 val_constr.data = NULL;
11041         uint32_t* val_vals = (uint32_t*) val.ptr;
11042         for (size_t z = 0; z < val_constr.datalen; z++) {
11043                 uint32_t arr_conv_25 = val_vals[z];
11044                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
11045                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
11046                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
11047                 if (arr_conv_25_conv.inner != NULL)
11048                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
11049                 val_constr.data[z] = arr_conv_25_conv;
11050         }
11051         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
11052 }
11053
11054 uint32_t CommitmentUpdate_1get_1update_1fee(void* ctx_TODO, uint32_t this_ptr) {
11055         LDKCommitmentUpdate this_ptr_conv;
11056         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11057         this_ptr_conv.is_owned = false;
11058         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
11059         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11060         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11061         long ret_ref = (long)ret_var.inner;
11062         if (ret_var.is_owned) {
11063                 ret_ref |= 1;
11064         }
11065         return ret_ref;
11066 }
11067
11068 void CommitmentUpdate_1set_1update_1fee(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
11069         LDKCommitmentUpdate this_ptr_conv;
11070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11071         this_ptr_conv.is_owned = false;
11072         LDKUpdateFee val_conv;
11073         val_conv.inner = (void*)(val & (~1));
11074         val_conv.is_owned = (val & 1) || (val == 0);
11075         if (val_conv.inner != NULL)
11076                 val_conv = UpdateFee_clone(&val_conv);
11077         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
11078 }
11079
11080 uint32_t CommitmentUpdate_1get_1commitment_1signed(void* ctx_TODO, uint32_t this_ptr) {
11081         LDKCommitmentUpdate this_ptr_conv;
11082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11083         this_ptr_conv.is_owned = false;
11084         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
11085         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11086         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11087         long ret_ref = (long)ret_var.inner;
11088         if (ret_var.is_owned) {
11089                 ret_ref |= 1;
11090         }
11091         return ret_ref;
11092 }
11093
11094 void CommitmentUpdate_1set_1commitment_1signed(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
11095         LDKCommitmentUpdate this_ptr_conv;
11096         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11097         this_ptr_conv.is_owned = false;
11098         LDKCommitmentSigned val_conv;
11099         val_conv.inner = (void*)(val & (~1));
11100         val_conv.is_owned = (val & 1) || (val == 0);
11101         if (val_conv.inner != NULL)
11102                 val_conv = CommitmentSigned_clone(&val_conv);
11103         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
11104 }
11105
11106 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) {
11107         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
11108         update_add_htlcs_arg_constr.datalen = update_add_htlcs_arg.len;
11109         if (update_add_htlcs_arg_constr.datalen > 0)
11110                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11111         else
11112                 update_add_htlcs_arg_constr.data = NULL;
11113         uint32_t* update_add_htlcs_arg_vals = (uint32_t*) update_add_htlcs_arg.ptr;
11114         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
11115                 uint32_t arr_conv_15 = update_add_htlcs_arg_vals[p];
11116                 LDKUpdateAddHTLC arr_conv_15_conv;
11117                 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
11118                 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
11119                 if (arr_conv_15_conv.inner != NULL)
11120                         arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
11121                 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
11122         }
11123         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
11124         update_fulfill_htlcs_arg_constr.datalen = update_fulfill_htlcs_arg.len;
11125         if (update_fulfill_htlcs_arg_constr.datalen > 0)
11126                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11127         else
11128                 update_fulfill_htlcs_arg_constr.data = NULL;
11129         uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*) update_fulfill_htlcs_arg.ptr;
11130         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
11131                 uint32_t arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
11132                 LDKUpdateFulfillHTLC arr_conv_19_conv;
11133                 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
11134                 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
11135                 if (arr_conv_19_conv.inner != NULL)
11136                         arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
11137                 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
11138         }
11139         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
11140         update_fail_htlcs_arg_constr.datalen = update_fail_htlcs_arg.len;
11141         if (update_fail_htlcs_arg_constr.datalen > 0)
11142                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11143         else
11144                 update_fail_htlcs_arg_constr.data = NULL;
11145         uint32_t* update_fail_htlcs_arg_vals = (uint32_t*) update_fail_htlcs_arg.ptr;
11146         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
11147                 uint32_t arr_conv_16 = update_fail_htlcs_arg_vals[q];
11148                 LDKUpdateFailHTLC arr_conv_16_conv;
11149                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
11150                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
11151                 if (arr_conv_16_conv.inner != NULL)
11152                         arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
11153                 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
11154         }
11155         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
11156         update_fail_malformed_htlcs_arg_constr.datalen = update_fail_malformed_htlcs_arg.len;
11157         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
11158                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11159         else
11160                 update_fail_malformed_htlcs_arg_constr.data = NULL;
11161         uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*) update_fail_malformed_htlcs_arg.ptr;
11162         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
11163                 uint32_t arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
11164                 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
11165                 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
11166                 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
11167                 if (arr_conv_25_conv.inner != NULL)
11168                         arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
11169                 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
11170         }
11171         LDKUpdateFee update_fee_arg_conv;
11172         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
11173         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
11174         if (update_fee_arg_conv.inner != NULL)
11175                 update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
11176         LDKCommitmentSigned commitment_signed_arg_conv;
11177         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
11178         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
11179         if (commitment_signed_arg_conv.inner != NULL)
11180                 commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
11181         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);
11182         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11183         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11184         long ret_ref = (long)ret_var.inner;
11185         if (ret_var.is_owned) {
11186                 ret_ref |= 1;
11187         }
11188         return ret_ref;
11189 }
11190
11191 void HTLCFailChannelUpdate_1free(void* ctx_TODO, uint32_t this_ptr) {
11192         LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
11193         FREE((void*)this_ptr);
11194         HTLCFailChannelUpdate_free(this_ptr_conv);
11195 }
11196
11197 uint32_t HTLCFailChannelUpdate_1clone(void* ctx_TODO, uint32_t orig) {
11198         LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
11199         LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
11200         *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
11201         long ret_ref = (long)ret_copy;
11202         return ret_ref;
11203 }
11204
11205 void ChannelMessageHandler_1free(void* ctx_TODO, uint32_t this_ptr) {
11206         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
11207         FREE((void*)this_ptr);
11208         ChannelMessageHandler_free(this_ptr_conv);
11209 }
11210
11211 void RoutingMessageHandler_1free(void* ctx_TODO, uint32_t this_ptr) {
11212         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
11213         FREE((void*)this_ptr);
11214         RoutingMessageHandler_free(this_ptr_conv);
11215 }
11216
11217 int8_tArray AcceptChannel_1write(void* ctx_TODO, uint32_t obj) {
11218         LDKAcceptChannel obj_conv;
11219         obj_conv.inner = (void*)(obj & (~1));
11220         obj_conv.is_owned = false;
11221         LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
11222         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11223         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11224         CVec_u8Z_free(arg_var);
11225         return arg_arr;
11226 }
11227
11228 uint32_t AcceptChannel_1read(void* ctx_TODO, int8_tArray ser) {
11229         LDKu8slice ser_ref;
11230         ser_ref.datalen = ser.len;
11231         ser_ref.data = ser.ptr;
11232         LDKAcceptChannel ret_var = AcceptChannel_read(ser_ref);
11233         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11234         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11235         long ret_ref = (long)ret_var.inner;
11236         if (ret_var.is_owned) {
11237                 ret_ref |= 1;
11238         }
11239         return ret_ref;
11240 }
11241
11242 int8_tArray AnnouncementSignatures_1write(void* ctx_TODO, uint32_t obj) {
11243         LDKAnnouncementSignatures obj_conv;
11244         obj_conv.inner = (void*)(obj & (~1));
11245         obj_conv.is_owned = false;
11246         LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
11247         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11248         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11249         CVec_u8Z_free(arg_var);
11250         return arg_arr;
11251 }
11252
11253 uint32_t AnnouncementSignatures_1read(void* ctx_TODO, int8_tArray ser) {
11254         LDKu8slice ser_ref;
11255         ser_ref.datalen = ser.len;
11256         ser_ref.data = ser.ptr;
11257         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_read(ser_ref);
11258         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11259         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11260         long ret_ref = (long)ret_var.inner;
11261         if (ret_var.is_owned) {
11262                 ret_ref |= 1;
11263         }
11264         return ret_ref;
11265 }
11266
11267 int8_tArray ChannelReestablish_1write(void* ctx_TODO, uint32_t obj) {
11268         LDKChannelReestablish obj_conv;
11269         obj_conv.inner = (void*)(obj & (~1));
11270         obj_conv.is_owned = false;
11271         LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
11272         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11273         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11274         CVec_u8Z_free(arg_var);
11275         return arg_arr;
11276 }
11277
11278 uint32_t ChannelReestablish_1read(void* ctx_TODO, int8_tArray ser) {
11279         LDKu8slice ser_ref;
11280         ser_ref.datalen = ser.len;
11281         ser_ref.data = ser.ptr;
11282         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
11283         *ret_conv = ChannelReestablish_read(ser_ref);
11284         return (long)ret_conv;
11285 }
11286
11287 int8_tArray ClosingSigned_1write(void* ctx_TODO, uint32_t obj) {
11288         LDKClosingSigned obj_conv;
11289         obj_conv.inner = (void*)(obj & (~1));
11290         obj_conv.is_owned = false;
11291         LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
11292         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11293         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11294         CVec_u8Z_free(arg_var);
11295         return arg_arr;
11296 }
11297
11298 uint32_t ClosingSigned_1read(void* ctx_TODO, int8_tArray ser) {
11299         LDKu8slice ser_ref;
11300         ser_ref.datalen = ser.len;
11301         ser_ref.data = ser.ptr;
11302         LDKClosingSigned ret_var = ClosingSigned_read(ser_ref);
11303         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11304         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11305         long ret_ref = (long)ret_var.inner;
11306         if (ret_var.is_owned) {
11307                 ret_ref |= 1;
11308         }
11309         return ret_ref;
11310 }
11311
11312 int8_tArray CommitmentSigned_1write(void* ctx_TODO, uint32_t obj) {
11313         LDKCommitmentSigned obj_conv;
11314         obj_conv.inner = (void*)(obj & (~1));
11315         obj_conv.is_owned = false;
11316         LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
11317         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11318         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11319         CVec_u8Z_free(arg_var);
11320         return arg_arr;
11321 }
11322
11323 uint32_t CommitmentSigned_1read(void* ctx_TODO, int8_tArray ser) {
11324         LDKu8slice ser_ref;
11325         ser_ref.datalen = ser.len;
11326         ser_ref.data = ser.ptr;
11327         LDKCommitmentSigned ret_var = CommitmentSigned_read(ser_ref);
11328         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11329         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11330         long ret_ref = (long)ret_var.inner;
11331         if (ret_var.is_owned) {
11332                 ret_ref |= 1;
11333         }
11334         return ret_ref;
11335 }
11336
11337 int8_tArray FundingCreated_1write(void* ctx_TODO, uint32_t obj) {
11338         LDKFundingCreated obj_conv;
11339         obj_conv.inner = (void*)(obj & (~1));
11340         obj_conv.is_owned = false;
11341         LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
11342         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11343         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11344         CVec_u8Z_free(arg_var);
11345         return arg_arr;
11346 }
11347
11348 uint32_t FundingCreated_1read(void* ctx_TODO, int8_tArray ser) {
11349         LDKu8slice ser_ref;
11350         ser_ref.datalen = ser.len;
11351         ser_ref.data = ser.ptr;
11352         LDKFundingCreated ret_var = FundingCreated_read(ser_ref);
11353         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11354         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11355         long ret_ref = (long)ret_var.inner;
11356         if (ret_var.is_owned) {
11357                 ret_ref |= 1;
11358         }
11359         return ret_ref;
11360 }
11361
11362 int8_tArray FundingSigned_1write(void* ctx_TODO, uint32_t obj) {
11363         LDKFundingSigned obj_conv;
11364         obj_conv.inner = (void*)(obj & (~1));
11365         obj_conv.is_owned = false;
11366         LDKCVec_u8Z arg_var = FundingSigned_write(&obj_conv);
11367         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11368         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11369         CVec_u8Z_free(arg_var);
11370         return arg_arr;
11371 }
11372
11373 uint32_t FundingSigned_1read(void* ctx_TODO, int8_tArray ser) {
11374         LDKu8slice ser_ref;
11375         ser_ref.datalen = ser.len;
11376         ser_ref.data = ser.ptr;
11377         LDKFundingSigned ret_var = FundingSigned_read(ser_ref);
11378         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11379         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11380         long ret_ref = (long)ret_var.inner;
11381         if (ret_var.is_owned) {
11382                 ret_ref |= 1;
11383         }
11384         return ret_ref;
11385 }
11386
11387 int8_tArray FundingLocked_1write(void* ctx_TODO, uint32_t obj) {
11388         LDKFundingLocked obj_conv;
11389         obj_conv.inner = (void*)(obj & (~1));
11390         obj_conv.is_owned = false;
11391         LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
11392         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11393         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11394         CVec_u8Z_free(arg_var);
11395         return arg_arr;
11396 }
11397
11398 uint32_t FundingLocked_1read(void* ctx_TODO, int8_tArray ser) {
11399         LDKu8slice ser_ref;
11400         ser_ref.datalen = ser.len;
11401         ser_ref.data = ser.ptr;
11402         LDKFundingLocked ret_var = FundingLocked_read(ser_ref);
11403         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11404         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11405         long ret_ref = (long)ret_var.inner;
11406         if (ret_var.is_owned) {
11407                 ret_ref |= 1;
11408         }
11409         return ret_ref;
11410 }
11411
11412 int8_tArray Init_1write(void* ctx_TODO, uint32_t obj) {
11413         LDKInit obj_conv;
11414         obj_conv.inner = (void*)(obj & (~1));
11415         obj_conv.is_owned = false;
11416         LDKCVec_u8Z arg_var = Init_write(&obj_conv);
11417         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11418         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11419         CVec_u8Z_free(arg_var);
11420         return arg_arr;
11421 }
11422
11423 uint32_t Init_1read(void* ctx_TODO, int8_tArray ser) {
11424         LDKu8slice ser_ref;
11425         ser_ref.datalen = ser.len;
11426         ser_ref.data = ser.ptr;
11427         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
11428         *ret_conv = Init_read(ser_ref);
11429         return (long)ret_conv;
11430 }
11431
11432 int8_tArray OpenChannel_1write(void* ctx_TODO, uint32_t obj) {
11433         LDKOpenChannel obj_conv;
11434         obj_conv.inner = (void*)(obj & (~1));
11435         obj_conv.is_owned = false;
11436         LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
11437         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11438         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11439         CVec_u8Z_free(arg_var);
11440         return arg_arr;
11441 }
11442
11443 uint32_t OpenChannel_1read(void* ctx_TODO, int8_tArray ser) {
11444         LDKu8slice ser_ref;
11445         ser_ref.datalen = ser.len;
11446         ser_ref.data = ser.ptr;
11447         LDKOpenChannel ret_var = OpenChannel_read(ser_ref);
11448         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11449         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11450         long ret_ref = (long)ret_var.inner;
11451         if (ret_var.is_owned) {
11452                 ret_ref |= 1;
11453         }
11454         return ret_ref;
11455 }
11456
11457 int8_tArray RevokeAndACK_1write(void* ctx_TODO, uint32_t obj) {
11458         LDKRevokeAndACK obj_conv;
11459         obj_conv.inner = (void*)(obj & (~1));
11460         obj_conv.is_owned = false;
11461         LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
11462         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11463         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11464         CVec_u8Z_free(arg_var);
11465         return arg_arr;
11466 }
11467
11468 uint32_t RevokeAndACK_1read(void* ctx_TODO, int8_tArray ser) {
11469         LDKu8slice ser_ref;
11470         ser_ref.datalen = ser.len;
11471         ser_ref.data = ser.ptr;
11472         LDKRevokeAndACK ret_var = RevokeAndACK_read(ser_ref);
11473         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11474         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11475         long ret_ref = (long)ret_var.inner;
11476         if (ret_var.is_owned) {
11477                 ret_ref |= 1;
11478         }
11479         return ret_ref;
11480 }
11481
11482 int8_tArray Shutdown_1write(void* ctx_TODO, uint32_t obj) {
11483         LDKShutdown obj_conv;
11484         obj_conv.inner = (void*)(obj & (~1));
11485         obj_conv.is_owned = false;
11486         LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
11487         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11488         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11489         CVec_u8Z_free(arg_var);
11490         return arg_arr;
11491 }
11492
11493 uint32_t Shutdown_1read(void* ctx_TODO, int8_tArray ser) {
11494         LDKu8slice ser_ref;
11495         ser_ref.datalen = ser.len;
11496         ser_ref.data = ser.ptr;
11497         LDKShutdown ret_var = Shutdown_read(ser_ref);
11498         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11499         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11500         long ret_ref = (long)ret_var.inner;
11501         if (ret_var.is_owned) {
11502                 ret_ref |= 1;
11503         }
11504         return ret_ref;
11505 }
11506
11507 int8_tArray UpdateFailHTLC_1write(void* ctx_TODO, uint32_t obj) {
11508         LDKUpdateFailHTLC obj_conv;
11509         obj_conv.inner = (void*)(obj & (~1));
11510         obj_conv.is_owned = false;
11511         LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
11512         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11513         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11514         CVec_u8Z_free(arg_var);
11515         return arg_arr;
11516 }
11517
11518 uint32_t UpdateFailHTLC_1read(void* ctx_TODO, int8_tArray ser) {
11519         LDKu8slice ser_ref;
11520         ser_ref.datalen = ser.len;
11521         ser_ref.data = ser.ptr;
11522         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_read(ser_ref);
11523         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11524         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11525         long ret_ref = (long)ret_var.inner;
11526         if (ret_var.is_owned) {
11527                 ret_ref |= 1;
11528         }
11529         return ret_ref;
11530 }
11531
11532 int8_tArray UpdateFailMalformedHTLC_1write(void* ctx_TODO, uint32_t obj) {
11533         LDKUpdateFailMalformedHTLC obj_conv;
11534         obj_conv.inner = (void*)(obj & (~1));
11535         obj_conv.is_owned = false;
11536         LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
11537         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11538         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11539         CVec_u8Z_free(arg_var);
11540         return arg_arr;
11541 }
11542
11543 uint32_t UpdateFailMalformedHTLC_1read(void* ctx_TODO, int8_tArray ser) {
11544         LDKu8slice ser_ref;
11545         ser_ref.datalen = ser.len;
11546         ser_ref.data = ser.ptr;
11547         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_read(ser_ref);
11548         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11549         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11550         long ret_ref = (long)ret_var.inner;
11551         if (ret_var.is_owned) {
11552                 ret_ref |= 1;
11553         }
11554         return ret_ref;
11555 }
11556
11557 int8_tArray UpdateFee_1write(void* ctx_TODO, uint32_t obj) {
11558         LDKUpdateFee obj_conv;
11559         obj_conv.inner = (void*)(obj & (~1));
11560         obj_conv.is_owned = false;
11561         LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
11562         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11563         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11564         CVec_u8Z_free(arg_var);
11565         return arg_arr;
11566 }
11567
11568 uint32_t UpdateFee_1read(void* ctx_TODO, int8_tArray ser) {
11569         LDKu8slice ser_ref;
11570         ser_ref.datalen = ser.len;
11571         ser_ref.data = ser.ptr;
11572         LDKUpdateFee ret_var = UpdateFee_read(ser_ref);
11573         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11574         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11575         long ret_ref = (long)ret_var.inner;
11576         if (ret_var.is_owned) {
11577                 ret_ref |= 1;
11578         }
11579         return ret_ref;
11580 }
11581
11582 int8_tArray UpdateFulfillHTLC_1write(void* ctx_TODO, uint32_t obj) {
11583         LDKUpdateFulfillHTLC obj_conv;
11584         obj_conv.inner = (void*)(obj & (~1));
11585         obj_conv.is_owned = false;
11586         LDKCVec_u8Z arg_var = UpdateFulfillHTLC_write(&obj_conv);
11587         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11588         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11589         CVec_u8Z_free(arg_var);
11590         return arg_arr;
11591 }
11592
11593 uint32_t UpdateFulfillHTLC_1read(void* ctx_TODO, int8_tArray ser) {
11594         LDKu8slice ser_ref;
11595         ser_ref.datalen = ser.len;
11596         ser_ref.data = ser.ptr;
11597         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_read(ser_ref);
11598         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11599         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11600         long ret_ref = (long)ret_var.inner;
11601         if (ret_var.is_owned) {
11602                 ret_ref |= 1;
11603         }
11604         return ret_ref;
11605 }
11606
11607 int8_tArray UpdateAddHTLC_1write(void* ctx_TODO, uint32_t obj) {
11608         LDKUpdateAddHTLC obj_conv;
11609         obj_conv.inner = (void*)(obj & (~1));
11610         obj_conv.is_owned = false;
11611         LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
11612         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11613         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11614         CVec_u8Z_free(arg_var);
11615         return arg_arr;
11616 }
11617
11618 uint32_t UpdateAddHTLC_1read(void* ctx_TODO, int8_tArray ser) {
11619         LDKu8slice ser_ref;
11620         ser_ref.datalen = ser.len;
11621         ser_ref.data = ser.ptr;
11622         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_read(ser_ref);
11623         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11624         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11625         long ret_ref = (long)ret_var.inner;
11626         if (ret_var.is_owned) {
11627                 ret_ref |= 1;
11628         }
11629         return ret_ref;
11630 }
11631
11632 int8_tArray Ping_1write(void* ctx_TODO, uint32_t obj) {
11633         LDKPing obj_conv;
11634         obj_conv.inner = (void*)(obj & (~1));
11635         obj_conv.is_owned = false;
11636         LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
11637         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11638         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11639         CVec_u8Z_free(arg_var);
11640         return arg_arr;
11641 }
11642
11643 uint32_t Ping_1read(void* ctx_TODO, int8_tArray ser) {
11644         LDKu8slice ser_ref;
11645         ser_ref.datalen = ser.len;
11646         ser_ref.data = ser.ptr;
11647         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
11648         *ret_conv = Ping_read(ser_ref);
11649         return (long)ret_conv;
11650 }
11651
11652 int8_tArray Pong_1write(void* ctx_TODO, uint32_t obj) {
11653         LDKPong obj_conv;
11654         obj_conv.inner = (void*)(obj & (~1));
11655         obj_conv.is_owned = false;
11656         LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
11657         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11658         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11659         CVec_u8Z_free(arg_var);
11660         return arg_arr;
11661 }
11662
11663 uint32_t Pong_1read(void* ctx_TODO, int8_tArray ser) {
11664         LDKu8slice ser_ref;
11665         ser_ref.datalen = ser.len;
11666         ser_ref.data = ser.ptr;
11667         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
11668         *ret_conv = Pong_read(ser_ref);
11669         return (long)ret_conv;
11670 }
11671
11672 int8_tArray UnsignedChannelAnnouncement_1write(void* ctx_TODO, uint32_t obj) {
11673         LDKUnsignedChannelAnnouncement obj_conv;
11674         obj_conv.inner = (void*)(obj & (~1));
11675         obj_conv.is_owned = false;
11676         LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_write(&obj_conv);
11677         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11678         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11679         CVec_u8Z_free(arg_var);
11680         return arg_arr;
11681 }
11682
11683 uint32_t UnsignedChannelAnnouncement_1read(void* ctx_TODO, int8_tArray ser) {
11684         LDKu8slice ser_ref;
11685         ser_ref.datalen = ser.len;
11686         ser_ref.data = ser.ptr;
11687         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
11688         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
11689         return (long)ret_conv;
11690 }
11691
11692 int8_tArray ChannelAnnouncement_1write(void* ctx_TODO, uint32_t obj) {
11693         LDKChannelAnnouncement obj_conv;
11694         obj_conv.inner = (void*)(obj & (~1));
11695         obj_conv.is_owned = false;
11696         LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
11697         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11698         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11699         CVec_u8Z_free(arg_var);
11700         return arg_arr;
11701 }
11702
11703 uint32_t ChannelAnnouncement_1read(void* ctx_TODO, int8_tArray ser) {
11704         LDKu8slice ser_ref;
11705         ser_ref.datalen = ser.len;
11706         ser_ref.data = ser.ptr;
11707         LDKChannelAnnouncement ret_var = ChannelAnnouncement_read(ser_ref);
11708         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11709         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11710         long ret_ref = (long)ret_var.inner;
11711         if (ret_var.is_owned) {
11712                 ret_ref |= 1;
11713         }
11714         return ret_ref;
11715 }
11716
11717 int8_tArray UnsignedChannelUpdate_1write(void* ctx_TODO, uint32_t obj) {
11718         LDKUnsignedChannelUpdate obj_conv;
11719         obj_conv.inner = (void*)(obj & (~1));
11720         obj_conv.is_owned = false;
11721         LDKCVec_u8Z arg_var = UnsignedChannelUpdate_write(&obj_conv);
11722         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11723         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11724         CVec_u8Z_free(arg_var);
11725         return arg_arr;
11726 }
11727
11728 uint32_t UnsignedChannelUpdate_1read(void* ctx_TODO, int8_tArray ser) {
11729         LDKu8slice ser_ref;
11730         ser_ref.datalen = ser.len;
11731         ser_ref.data = ser.ptr;
11732         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
11733         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
11734         return (long)ret_conv;
11735 }
11736
11737 int8_tArray ChannelUpdate_1write(void* ctx_TODO, uint32_t obj) {
11738         LDKChannelUpdate obj_conv;
11739         obj_conv.inner = (void*)(obj & (~1));
11740         obj_conv.is_owned = false;
11741         LDKCVec_u8Z arg_var = ChannelUpdate_write(&obj_conv);
11742         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11743         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11744         CVec_u8Z_free(arg_var);
11745         return arg_arr;
11746 }
11747
11748 uint32_t ChannelUpdate_1read(void* ctx_TODO, int8_tArray ser) {
11749         LDKu8slice ser_ref;
11750         ser_ref.datalen = ser.len;
11751         ser_ref.data = ser.ptr;
11752         LDKChannelUpdate ret_var = ChannelUpdate_read(ser_ref);
11753         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11754         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11755         long ret_ref = (long)ret_var.inner;
11756         if (ret_var.is_owned) {
11757                 ret_ref |= 1;
11758         }
11759         return ret_ref;
11760 }
11761
11762 int8_tArray ErrorMessage_1write(void* ctx_TODO, uint32_t obj) {
11763         LDKErrorMessage obj_conv;
11764         obj_conv.inner = (void*)(obj & (~1));
11765         obj_conv.is_owned = false;
11766         LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
11767         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11768         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11769         CVec_u8Z_free(arg_var);
11770         return arg_arr;
11771 }
11772
11773 uint32_t ErrorMessage_1read(void* ctx_TODO, int8_tArray ser) {
11774         LDKu8slice ser_ref;
11775         ser_ref.datalen = ser.len;
11776         ser_ref.data = ser.ptr;
11777         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
11778         *ret_conv = ErrorMessage_read(ser_ref);
11779         return (long)ret_conv;
11780 }
11781
11782 int8_tArray UnsignedNodeAnnouncement_1write(void* ctx_TODO, uint32_t obj) {
11783         LDKUnsignedNodeAnnouncement obj_conv;
11784         obj_conv.inner = (void*)(obj & (~1));
11785         obj_conv.is_owned = false;
11786         LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_write(&obj_conv);
11787         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11788         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11789         CVec_u8Z_free(arg_var);
11790         return arg_arr;
11791 }
11792
11793 uint32_t UnsignedNodeAnnouncement_1read(void* ctx_TODO, int8_tArray ser) {
11794         LDKu8slice ser_ref;
11795         ser_ref.datalen = ser.len;
11796         ser_ref.data = ser.ptr;
11797         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
11798         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
11799         return (long)ret_conv;
11800 }
11801
11802 int8_tArray NodeAnnouncement_1write(void* ctx_TODO, uint32_t obj) {
11803         LDKNodeAnnouncement obj_conv;
11804         obj_conv.inner = (void*)(obj & (~1));
11805         obj_conv.is_owned = false;
11806         LDKCVec_u8Z arg_var = NodeAnnouncement_write(&obj_conv);
11807         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11808         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11809         CVec_u8Z_free(arg_var);
11810         return arg_arr;
11811 }
11812
11813 uint32_t NodeAnnouncement_1read(void* ctx_TODO, int8_tArray ser) {
11814         LDKu8slice ser_ref;
11815         ser_ref.datalen = ser.len;
11816         ser_ref.data = ser.ptr;
11817         LDKNodeAnnouncement ret_var = NodeAnnouncement_read(ser_ref);
11818         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11819         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11820         long ret_ref = (long)ret_var.inner;
11821         if (ret_var.is_owned) {
11822                 ret_ref |= 1;
11823         }
11824         return ret_ref;
11825 }
11826
11827 uint32_t QueryShortChannelIds_1read(void* ctx_TODO, int8_tArray ser) {
11828         LDKu8slice ser_ref;
11829         ser_ref.datalen = ser.len;
11830         ser_ref.data = ser.ptr;
11831         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
11832         *ret_conv = QueryShortChannelIds_read(ser_ref);
11833         return (long)ret_conv;
11834 }
11835
11836 int8_tArray QueryShortChannelIds_1write(void* ctx_TODO, uint32_t obj) {
11837         LDKQueryShortChannelIds obj_conv;
11838         obj_conv.inner = (void*)(obj & (~1));
11839         obj_conv.is_owned = false;
11840         LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
11841         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11842         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11843         CVec_u8Z_free(arg_var);
11844         return arg_arr;
11845 }
11846
11847 uint32_t ReplyShortChannelIdsEnd_1read(void* ctx_TODO, int8_tArray ser) {
11848         LDKu8slice ser_ref;
11849         ser_ref.datalen = ser.len;
11850         ser_ref.data = ser.ptr;
11851         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
11852         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
11853         return (long)ret_conv;
11854 }
11855
11856 int8_tArray ReplyShortChannelIdsEnd_1write(void* ctx_TODO, uint32_t obj) {
11857         LDKReplyShortChannelIdsEnd obj_conv;
11858         obj_conv.inner = (void*)(obj & (~1));
11859         obj_conv.is_owned = false;
11860         LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
11861         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11862         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11863         CVec_u8Z_free(arg_var);
11864         return arg_arr;
11865 }
11866
11867 uint32_t QueryChannelRange_1read(void* ctx_TODO, int8_tArray ser) {
11868         LDKu8slice ser_ref;
11869         ser_ref.datalen = ser.len;
11870         ser_ref.data = ser.ptr;
11871         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
11872         *ret_conv = QueryChannelRange_read(ser_ref);
11873         return (long)ret_conv;
11874 }
11875
11876 int8_tArray QueryChannelRange_1write(void* ctx_TODO, uint32_t obj) {
11877         LDKQueryChannelRange obj_conv;
11878         obj_conv.inner = (void*)(obj & (~1));
11879         obj_conv.is_owned = false;
11880         LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
11881         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11882         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11883         CVec_u8Z_free(arg_var);
11884         return arg_arr;
11885 }
11886
11887 uint32_t ReplyChannelRange_1read(void* ctx_TODO, int8_tArray ser) {
11888         LDKu8slice ser_ref;
11889         ser_ref.datalen = ser.len;
11890         ser_ref.data = ser.ptr;
11891         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
11892         *ret_conv = ReplyChannelRange_read(ser_ref);
11893         return (long)ret_conv;
11894 }
11895
11896 int8_tArray ReplyChannelRange_1write(void* ctx_TODO, uint32_t obj) {
11897         LDKReplyChannelRange obj_conv;
11898         obj_conv.inner = (void*)(obj & (~1));
11899         obj_conv.is_owned = false;
11900         LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
11901         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11902         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11903         CVec_u8Z_free(arg_var);
11904         return arg_arr;
11905 }
11906
11907 uint32_t GossipTimestampFilter_1read(void* ctx_TODO, int8_tArray ser) {
11908         LDKu8slice ser_ref;
11909         ser_ref.datalen = ser.len;
11910         ser_ref.data = ser.ptr;
11911         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
11912         *ret_conv = GossipTimestampFilter_read(ser_ref);
11913         return (long)ret_conv;
11914 }
11915
11916 int8_tArray GossipTimestampFilter_1write(void* ctx_TODO, uint32_t obj) {
11917         LDKGossipTimestampFilter obj_conv;
11918         obj_conv.inner = (void*)(obj & (~1));
11919         obj_conv.is_owned = false;
11920         LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
11921         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
11922         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
11923         CVec_u8Z_free(arg_var);
11924         return arg_arr;
11925 }
11926
11927 void MessageHandler_1free(void* ctx_TODO, uint32_t this_ptr) {
11928         LDKMessageHandler this_ptr_conv;
11929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11930         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11931         MessageHandler_free(this_ptr_conv);
11932 }
11933
11934 uint32_t MessageHandler_1get_1chan_1handler(void* ctx_TODO, uint32_t this_ptr) {
11935         LDKMessageHandler this_ptr_conv;
11936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11937         this_ptr_conv.is_owned = false;
11938         long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
11939         return ret_ret;
11940 }
11941
11942 void MessageHandler_1set_1chan_1handler(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
11943         LDKMessageHandler this_ptr_conv;
11944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11945         this_ptr_conv.is_owned = false;
11946         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
11947         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
11948                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11949                 LDKChannelMessageHandler_JCalls_clone(val_conv.this_arg);
11950         }
11951         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
11952 }
11953
11954 uint32_t MessageHandler_1get_1route_1handler(void* ctx_TODO, uint32_t this_ptr) {
11955         LDKMessageHandler this_ptr_conv;
11956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11957         this_ptr_conv.is_owned = false;
11958         long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
11959         return ret_ret;
11960 }
11961
11962 void MessageHandler_1set_1route_1handler(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
11963         LDKMessageHandler this_ptr_conv;
11964         this_ptr_conv.inner = (void*)(this_ptr & (~1));
11965         this_ptr_conv.is_owned = false;
11966         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
11967         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11968                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11969                 LDKRoutingMessageHandler_JCalls_clone(val_conv.this_arg);
11970         }
11971         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
11972 }
11973
11974 uint32_t MessageHandler_1new(void* ctx_TODO, uint32_t chan_handler_arg, uint32_t route_handler_arg) {
11975         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
11976         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
11977                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11978                 LDKChannelMessageHandler_JCalls_clone(chan_handler_arg_conv.this_arg);
11979         }
11980         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
11981         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
11982                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11983                 LDKRoutingMessageHandler_JCalls_clone(route_handler_arg_conv.this_arg);
11984         }
11985         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
11986         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11987         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11988         long ret_ref = (long)ret_var.inner;
11989         if (ret_var.is_owned) {
11990                 ret_ref |= 1;
11991         }
11992         return ret_ref;
11993 }
11994
11995 uint32_t SocketDescriptor_1clone(void* ctx_TODO, uint32_t orig) {
11996         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig;
11997         LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
11998         *ret = SocketDescriptor_clone(orig_conv);
11999         return (long)ret;
12000 }
12001
12002 void SocketDescriptor_1free(void* ctx_TODO, uint32_t this_ptr) {
12003         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
12004         FREE((void*)this_ptr);
12005         SocketDescriptor_free(this_ptr_conv);
12006 }
12007
12008 void PeerHandleError_1free(void* ctx_TODO, uint32_t this_ptr) {
12009         LDKPeerHandleError this_ptr_conv;
12010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12011         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12012         PeerHandleError_free(this_ptr_conv);
12013 }
12014
12015 jboolean PeerHandleError_1get_1no_1connection_1possible(void* ctx_TODO, uint32_t this_ptr) {
12016         LDKPeerHandleError this_ptr_conv;
12017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12018         this_ptr_conv.is_owned = false;
12019         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
12020         return ret_val;
12021 }
12022
12023 void PeerHandleError_1set_1no_1connection_1possible(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
12024         LDKPeerHandleError this_ptr_conv;
12025         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12026         this_ptr_conv.is_owned = false;
12027         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
12028 }
12029
12030 uint32_t PeerHandleError_1new(void* ctx_TODO, jboolean no_connection_possible_arg) {
12031         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
12032         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12033         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12034         long ret_ref = (long)ret_var.inner;
12035         if (ret_var.is_owned) {
12036                 ret_ref |= 1;
12037         }
12038         return ret_ref;
12039 }
12040
12041 void PeerManager_1free(void* ctx_TODO, uint32_t this_ptr) {
12042         LDKPeerManager this_ptr_conv;
12043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12044         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12045         PeerManager_free(this_ptr_conv);
12046 }
12047
12048 uint32_t PeerManager_1new(void* ctx_TODO, uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger) {
12049         LDKMessageHandler message_handler_conv;
12050         message_handler_conv.inner = (void*)(message_handler & (~1));
12051         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
12052         // Warning: we may need a move here but can't clone!
12053         LDKSecretKey our_node_secret_ref;
12054         CHECK(our_node_secret.len == 32);
12055         memcpy(our_node_secret_ref.bytes, our_node_secret.ptr, 32);
12056         unsigned char ephemeral_random_data_arr[32];
12057         CHECK(ephemeral_random_data.len == 32);
12058         memcpy(ephemeral_random_data_arr, ephemeral_random_data.ptr, 32);
12059         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
12060         LDKLogger logger_conv = *(LDKLogger*)logger;
12061         if (logger_conv.free == LDKLogger_JCalls_free) {
12062                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12063                 LDKLogger_JCalls_clone(logger_conv.this_arg);
12064         }
12065         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
12066         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12067         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12068         long ret_ref = (long)ret_var.inner;
12069         if (ret_var.is_owned) {
12070                 ret_ref |= 1;
12071         }
12072         return ret_ref;
12073 }
12074
12075 uint32_tArray PeerManager_1get_1peer_1node_1ids(void* ctx_TODO, uint32_t this_arg) {
12076         LDKPeerManager this_arg_conv;
12077         this_arg_conv.inner = (void*)(this_arg & (~1));
12078         this_arg_conv.is_owned = false;
12079         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
12080         uint32_tArray ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
12081         for (size_t i = 0; i < ret_var.datalen; i++) {
12082                 int8_tArray arr_conv_8_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12083                 memcpy(arr_conv_8_arr.ptr, ret_var.data[i].compressed_form, 33);
12084                 (*env)->SetObjectArrayElement(env, ret_arr, i, arr_conv_8_arr);
12085         }
12086         FREE(ret_var.data);
12087         return ret_arr;
12088 }
12089
12090 uint32_t PeerManager_1new_1outbound_1connection(void* ctx_TODO, uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
12091         LDKPeerManager this_arg_conv;
12092         this_arg_conv.inner = (void*)(this_arg & (~1));
12093         this_arg_conv.is_owned = false;
12094         LDKPublicKey their_node_id_ref;
12095         CHECK(their_node_id.len == 33);
12096         memcpy(their_node_id_ref.compressed_form, their_node_id.ptr, 33);
12097         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
12098         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
12099                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12100                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
12101         }
12102         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
12103         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
12104         return (long)ret_conv;
12105 }
12106
12107 uint32_t PeerManager_1new_1inbound_1connection(void* ctx_TODO, uint32_t this_arg, uint32_t descriptor) {
12108         LDKPeerManager this_arg_conv;
12109         this_arg_conv.inner = (void*)(this_arg & (~1));
12110         this_arg_conv.is_owned = false;
12111         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
12112         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
12113                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
12114                 LDKSocketDescriptor_JCalls_clone(descriptor_conv.this_arg);
12115         }
12116         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12117         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
12118         return (long)ret_conv;
12119 }
12120
12121 uint32_t PeerManager_1write_1buffer_1space_1avail(void* ctx_TODO, uint32_t this_arg, uint32_t descriptor) {
12122         LDKPeerManager this_arg_conv;
12123         this_arg_conv.inner = (void*)(this_arg & (~1));
12124         this_arg_conv.is_owned = false;
12125         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
12126         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12127         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
12128         return (long)ret_conv;
12129 }
12130
12131 uint32_t PeerManager_1read_1event(void* ctx_TODO, uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
12132         LDKPeerManager this_arg_conv;
12133         this_arg_conv.inner = (void*)(this_arg & (~1));
12134         this_arg_conv.is_owned = false;
12135         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
12136         LDKu8slice data_ref;
12137         data_ref.datalen = data.len;
12138         data_ref.data = data.ptr;
12139         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12140         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
12141         return (long)ret_conv;
12142 }
12143
12144 void PeerManager_1process_1events(void* ctx_TODO, uint32_t this_arg) {
12145         LDKPeerManager this_arg_conv;
12146         this_arg_conv.inner = (void*)(this_arg & (~1));
12147         this_arg_conv.is_owned = false;
12148         PeerManager_process_events(&this_arg_conv);
12149 }
12150
12151 void PeerManager_1socket_1disconnected(void* ctx_TODO, uint32_t this_arg, uint32_t descriptor) {
12152         LDKPeerManager this_arg_conv;
12153         this_arg_conv.inner = (void*)(this_arg & (~1));
12154         this_arg_conv.is_owned = false;
12155         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
12156         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
12157 }
12158
12159 void PeerManager_1timer_1tick_1occured(void* ctx_TODO, uint32_t this_arg) {
12160         LDKPeerManager this_arg_conv;
12161         this_arg_conv.inner = (void*)(this_arg & (~1));
12162         this_arg_conv.is_owned = false;
12163         PeerManager_timer_tick_occured(&this_arg_conv);
12164 }
12165
12166 int8_tArray build_1commitment_1secret(void* ctx_TODO, int8_tArray commitment_seed, int64_t idx) {
12167         unsigned char commitment_seed_arr[32];
12168         CHECK(commitment_seed.len == 32);
12169         memcpy(commitment_seed_arr, commitment_seed.ptr, 32);
12170         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
12171         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
12172         memcpy(arg_arr.ptr, build_commitment_secret(commitment_seed_ref, idx).data, 32);
12173         return arg_arr;
12174 }
12175
12176 uint32_t derive_1private_1key(void* ctx_TODO, int8_tArray per_commitment_point, int8_tArray base_secret) {
12177         LDKPublicKey per_commitment_point_ref;
12178         CHECK(per_commitment_point.len == 33);
12179         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
12180         unsigned char base_secret_arr[32];
12181         CHECK(base_secret.len == 32);
12182         memcpy(base_secret_arr, base_secret.ptr, 32);
12183         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
12184         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
12185         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
12186         return (long)ret_conv;
12187 }
12188
12189 uint32_t derive_1public_1key(void* ctx_TODO, int8_tArray per_commitment_point, int8_tArray base_point) {
12190         LDKPublicKey per_commitment_point_ref;
12191         CHECK(per_commitment_point.len == 33);
12192         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
12193         LDKPublicKey base_point_ref;
12194         CHECK(base_point.len == 33);
12195         memcpy(base_point_ref.compressed_form, base_point.ptr, 33);
12196         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
12197         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
12198         return (long)ret_conv;
12199 }
12200
12201 uint32_t derive_1private_1revocation_1key(void* ctx_TODO, int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
12202         unsigned char per_commitment_secret_arr[32];
12203         CHECK(per_commitment_secret.len == 32);
12204         memcpy(per_commitment_secret_arr, per_commitment_secret.ptr, 32);
12205         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
12206         unsigned char countersignatory_revocation_base_secret_arr[32];
12207         CHECK(countersignatory_revocation_base_secret.len == 32);
12208         memcpy(countersignatory_revocation_base_secret_arr, countersignatory_revocation_base_secret.ptr, 32);
12209         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
12210         LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
12211         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
12212         return (long)ret_conv;
12213 }
12214
12215 uint32_t derive_1public_1revocation_1key(void* ctx_TODO, int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
12216         LDKPublicKey per_commitment_point_ref;
12217         CHECK(per_commitment_point.len == 33);
12218         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
12219         LDKPublicKey countersignatory_revocation_base_point_ref;
12220         CHECK(countersignatory_revocation_base_point.len == 33);
12221         memcpy(countersignatory_revocation_base_point_ref.compressed_form, countersignatory_revocation_base_point.ptr, 33);
12222         LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
12223         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
12224         return (long)ret_conv;
12225 }
12226
12227 void TxCreationKeys_1free(void* ctx_TODO, uint32_t this_ptr) {
12228         LDKTxCreationKeys this_ptr_conv;
12229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12230         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12231         TxCreationKeys_free(this_ptr_conv);
12232 }
12233
12234 uint32_t TxCreationKeys_1clone(void* ctx_TODO, uint32_t orig) {
12235         LDKTxCreationKeys orig_conv;
12236         orig_conv.inner = (void*)(orig & (~1));
12237         orig_conv.is_owned = false;
12238         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
12239         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12240         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12241         long ret_ref = (long)ret_var.inner;
12242         if (ret_var.is_owned) {
12243                 ret_ref |= 1;
12244         }
12245         return ret_ref;
12246 }
12247
12248 int8_tArray TxCreationKeys_1get_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr) {
12249         LDKTxCreationKeys this_ptr_conv;
12250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12251         this_ptr_conv.is_owned = false;
12252         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12253         memcpy(arg_arr.ptr, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
12254         return arg_arr;
12255 }
12256
12257 void TxCreationKeys_1set_1per_1commitment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12258         LDKTxCreationKeys this_ptr_conv;
12259         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12260         this_ptr_conv.is_owned = false;
12261         LDKPublicKey val_ref;
12262         CHECK(val.len == 33);
12263         memcpy(val_ref.compressed_form, val.ptr, 33);
12264         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
12265 }
12266
12267 int8_tArray TxCreationKeys_1get_1revocation_1key(void* ctx_TODO, uint32_t this_ptr) {
12268         LDKTxCreationKeys this_ptr_conv;
12269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12270         this_ptr_conv.is_owned = false;
12271         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12272         memcpy(arg_arr.ptr, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
12273         return arg_arr;
12274 }
12275
12276 void TxCreationKeys_1set_1revocation_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12277         LDKTxCreationKeys this_ptr_conv;
12278         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12279         this_ptr_conv.is_owned = false;
12280         LDKPublicKey val_ref;
12281         CHECK(val.len == 33);
12282         memcpy(val_ref.compressed_form, val.ptr, 33);
12283         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
12284 }
12285
12286 int8_tArray TxCreationKeys_1get_1broadcaster_1htlc_1key(void* ctx_TODO, uint32_t this_ptr) {
12287         LDKTxCreationKeys this_ptr_conv;
12288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12289         this_ptr_conv.is_owned = false;
12290         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12291         memcpy(arg_arr.ptr, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
12292         return arg_arr;
12293 }
12294
12295 void TxCreationKeys_1set_1broadcaster_1htlc_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12296         LDKTxCreationKeys this_ptr_conv;
12297         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12298         this_ptr_conv.is_owned = false;
12299         LDKPublicKey val_ref;
12300         CHECK(val.len == 33);
12301         memcpy(val_ref.compressed_form, val.ptr, 33);
12302         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
12303 }
12304
12305 int8_tArray TxCreationKeys_1get_1countersignatory_1htlc_1key(void* ctx_TODO, uint32_t this_ptr) {
12306         LDKTxCreationKeys this_ptr_conv;
12307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12308         this_ptr_conv.is_owned = false;
12309         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12310         memcpy(arg_arr.ptr, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
12311         return arg_arr;
12312 }
12313
12314 void TxCreationKeys_1set_1countersignatory_1htlc_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12315         LDKTxCreationKeys this_ptr_conv;
12316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12317         this_ptr_conv.is_owned = false;
12318         LDKPublicKey val_ref;
12319         CHECK(val.len == 33);
12320         memcpy(val_ref.compressed_form, val.ptr, 33);
12321         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
12322 }
12323
12324 int8_tArray TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(void* ctx_TODO, uint32_t this_ptr) {
12325         LDKTxCreationKeys this_ptr_conv;
12326         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12327         this_ptr_conv.is_owned = false;
12328         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12329         memcpy(arg_arr.ptr, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
12330         return arg_arr;
12331 }
12332
12333 void TxCreationKeys_1set_1broadcaster_1delayed_1payment_1key(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12334         LDKTxCreationKeys this_ptr_conv;
12335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12336         this_ptr_conv.is_owned = false;
12337         LDKPublicKey val_ref;
12338         CHECK(val.len == 33);
12339         memcpy(val_ref.compressed_form, val.ptr, 33);
12340         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
12341 }
12342
12343 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) {
12344         LDKPublicKey per_commitment_point_arg_ref;
12345         CHECK(per_commitment_point_arg.len == 33);
12346         memcpy(per_commitment_point_arg_ref.compressed_form, per_commitment_point_arg.ptr, 33);
12347         LDKPublicKey revocation_key_arg_ref;
12348         CHECK(revocation_key_arg.len == 33);
12349         memcpy(revocation_key_arg_ref.compressed_form, revocation_key_arg.ptr, 33);
12350         LDKPublicKey broadcaster_htlc_key_arg_ref;
12351         CHECK(broadcaster_htlc_key_arg.len == 33);
12352         memcpy(broadcaster_htlc_key_arg_ref.compressed_form, broadcaster_htlc_key_arg.ptr, 33);
12353         LDKPublicKey countersignatory_htlc_key_arg_ref;
12354         CHECK(countersignatory_htlc_key_arg.len == 33);
12355         memcpy(countersignatory_htlc_key_arg_ref.compressed_form, countersignatory_htlc_key_arg.ptr, 33);
12356         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
12357         CHECK(broadcaster_delayed_payment_key_arg.len == 33);
12358         memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, broadcaster_delayed_payment_key_arg.ptr, 33);
12359         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);
12360         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12361         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12362         long ret_ref = (long)ret_var.inner;
12363         if (ret_var.is_owned) {
12364                 ret_ref |= 1;
12365         }
12366         return ret_ref;
12367 }
12368
12369 int8_tArray TxCreationKeys_1write(void* ctx_TODO, uint32_t obj) {
12370         LDKTxCreationKeys obj_conv;
12371         obj_conv.inner = (void*)(obj & (~1));
12372         obj_conv.is_owned = false;
12373         LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
12374         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12375         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12376         CVec_u8Z_free(arg_var);
12377         return arg_arr;
12378 }
12379
12380 uint32_t TxCreationKeys_1read(void* ctx_TODO, int8_tArray ser) {
12381         LDKu8slice ser_ref;
12382         ser_ref.datalen = ser.len;
12383         ser_ref.data = ser.ptr;
12384         LDKTxCreationKeys ret_var = TxCreationKeys_read(ser_ref);
12385         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12386         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12387         long ret_ref = (long)ret_var.inner;
12388         if (ret_var.is_owned) {
12389                 ret_ref |= 1;
12390         }
12391         return ret_ref;
12392 }
12393
12394 void ChannelPublicKeys_1free(void* ctx_TODO, uint32_t this_ptr) {
12395         LDKChannelPublicKeys this_ptr_conv;
12396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12397         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12398         ChannelPublicKeys_free(this_ptr_conv);
12399 }
12400
12401 uint32_t ChannelPublicKeys_1clone(void* ctx_TODO, uint32_t orig) {
12402         LDKChannelPublicKeys orig_conv;
12403         orig_conv.inner = (void*)(orig & (~1));
12404         orig_conv.is_owned = false;
12405         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
12406         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12407         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12408         long ret_ref = (long)ret_var.inner;
12409         if (ret_var.is_owned) {
12410                 ret_ref |= 1;
12411         }
12412         return ret_ref;
12413 }
12414
12415 int8_tArray ChannelPublicKeys_1get_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
12416         LDKChannelPublicKeys this_ptr_conv;
12417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12418         this_ptr_conv.is_owned = false;
12419         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12420         memcpy(arg_arr.ptr, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
12421         return arg_arr;
12422 }
12423
12424 void ChannelPublicKeys_1set_1funding_1pubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12425         LDKChannelPublicKeys this_ptr_conv;
12426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12427         this_ptr_conv.is_owned = false;
12428         LDKPublicKey val_ref;
12429         CHECK(val.len == 33);
12430         memcpy(val_ref.compressed_form, val.ptr, 33);
12431         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
12432 }
12433
12434 int8_tArray ChannelPublicKeys_1get_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
12435         LDKChannelPublicKeys this_ptr_conv;
12436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12437         this_ptr_conv.is_owned = false;
12438         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12439         memcpy(arg_arr.ptr, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
12440         return arg_arr;
12441 }
12442
12443 void ChannelPublicKeys_1set_1revocation_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12444         LDKChannelPublicKeys this_ptr_conv;
12445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12446         this_ptr_conv.is_owned = false;
12447         LDKPublicKey val_ref;
12448         CHECK(val.len == 33);
12449         memcpy(val_ref.compressed_form, val.ptr, 33);
12450         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
12451 }
12452
12453 int8_tArray ChannelPublicKeys_1get_1payment_1point(void* ctx_TODO, uint32_t this_ptr) {
12454         LDKChannelPublicKeys this_ptr_conv;
12455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12456         this_ptr_conv.is_owned = false;
12457         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12458         memcpy(arg_arr.ptr, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
12459         return arg_arr;
12460 }
12461
12462 void ChannelPublicKeys_1set_1payment_1point(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12463         LDKChannelPublicKeys this_ptr_conv;
12464         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12465         this_ptr_conv.is_owned = false;
12466         LDKPublicKey val_ref;
12467         CHECK(val.len == 33);
12468         memcpy(val_ref.compressed_form, val.ptr, 33);
12469         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
12470 }
12471
12472 int8_tArray ChannelPublicKeys_1get_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
12473         LDKChannelPublicKeys this_ptr_conv;
12474         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12475         this_ptr_conv.is_owned = false;
12476         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12477         memcpy(arg_arr.ptr, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
12478         return arg_arr;
12479 }
12480
12481 void ChannelPublicKeys_1set_1delayed_1payment_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12482         LDKChannelPublicKeys this_ptr_conv;
12483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12484         this_ptr_conv.is_owned = false;
12485         LDKPublicKey val_ref;
12486         CHECK(val.len == 33);
12487         memcpy(val_ref.compressed_form, val.ptr, 33);
12488         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
12489 }
12490
12491 int8_tArray ChannelPublicKeys_1get_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr) {
12492         LDKChannelPublicKeys this_ptr_conv;
12493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12494         this_ptr_conv.is_owned = false;
12495         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
12496         memcpy(arg_arr.ptr, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
12497         return arg_arr;
12498 }
12499
12500 void ChannelPublicKeys_1set_1htlc_1basepoint(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12501         LDKChannelPublicKeys this_ptr_conv;
12502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12503         this_ptr_conv.is_owned = false;
12504         LDKPublicKey val_ref;
12505         CHECK(val.len == 33);
12506         memcpy(val_ref.compressed_form, val.ptr, 33);
12507         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
12508 }
12509
12510 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) {
12511         LDKPublicKey funding_pubkey_arg_ref;
12512         CHECK(funding_pubkey_arg.len == 33);
12513         memcpy(funding_pubkey_arg_ref.compressed_form, funding_pubkey_arg.ptr, 33);
12514         LDKPublicKey revocation_basepoint_arg_ref;
12515         CHECK(revocation_basepoint_arg.len == 33);
12516         memcpy(revocation_basepoint_arg_ref.compressed_form, revocation_basepoint_arg.ptr, 33);
12517         LDKPublicKey payment_point_arg_ref;
12518         CHECK(payment_point_arg.len == 33);
12519         memcpy(payment_point_arg_ref.compressed_form, payment_point_arg.ptr, 33);
12520         LDKPublicKey delayed_payment_basepoint_arg_ref;
12521         CHECK(delayed_payment_basepoint_arg.len == 33);
12522         memcpy(delayed_payment_basepoint_arg_ref.compressed_form, delayed_payment_basepoint_arg.ptr, 33);
12523         LDKPublicKey htlc_basepoint_arg_ref;
12524         CHECK(htlc_basepoint_arg.len == 33);
12525         memcpy(htlc_basepoint_arg_ref.compressed_form, htlc_basepoint_arg.ptr, 33);
12526         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);
12527         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12528         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12529         long ret_ref = (long)ret_var.inner;
12530         if (ret_var.is_owned) {
12531                 ret_ref |= 1;
12532         }
12533         return ret_ref;
12534 }
12535
12536 int8_tArray ChannelPublicKeys_1write(void* ctx_TODO, uint32_t obj) {
12537         LDKChannelPublicKeys obj_conv;
12538         obj_conv.inner = (void*)(obj & (~1));
12539         obj_conv.is_owned = false;
12540         LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
12541         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12542         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12543         CVec_u8Z_free(arg_var);
12544         return arg_arr;
12545 }
12546
12547 uint32_t ChannelPublicKeys_1read(void* ctx_TODO, int8_tArray ser) {
12548         LDKu8slice ser_ref;
12549         ser_ref.datalen = ser.len;
12550         ser_ref.data = ser.ptr;
12551         LDKChannelPublicKeys ret_var = ChannelPublicKeys_read(ser_ref);
12552         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12553         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12554         long ret_ref = (long)ret_var.inner;
12555         if (ret_var.is_owned) {
12556                 ret_ref |= 1;
12557         }
12558         return ret_ref;
12559 }
12560
12561 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) {
12562         LDKPublicKey per_commitment_point_ref;
12563         CHECK(per_commitment_point.len == 33);
12564         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
12565         LDKPublicKey broadcaster_delayed_payment_base_ref;
12566         CHECK(broadcaster_delayed_payment_base.len == 33);
12567         memcpy(broadcaster_delayed_payment_base_ref.compressed_form, broadcaster_delayed_payment_base.ptr, 33);
12568         LDKPublicKey broadcaster_htlc_base_ref;
12569         CHECK(broadcaster_htlc_base.len == 33);
12570         memcpy(broadcaster_htlc_base_ref.compressed_form, broadcaster_htlc_base.ptr, 33);
12571         LDKPublicKey countersignatory_revocation_base_ref;
12572         CHECK(countersignatory_revocation_base.len == 33);
12573         memcpy(countersignatory_revocation_base_ref.compressed_form, countersignatory_revocation_base.ptr, 33);
12574         LDKPublicKey countersignatory_htlc_base_ref;
12575         CHECK(countersignatory_htlc_base.len == 33);
12576         memcpy(countersignatory_htlc_base_ref.compressed_form, countersignatory_htlc_base.ptr, 33);
12577         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
12578         *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);
12579         return (long)ret_conv;
12580 }
12581
12582 uint32_t TxCreationKeys_1from_1channel_1static_1keys(void* ctx_TODO, int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
12583         LDKPublicKey per_commitment_point_ref;
12584         CHECK(per_commitment_point.len == 33);
12585         memcpy(per_commitment_point_ref.compressed_form, per_commitment_point.ptr, 33);
12586         LDKChannelPublicKeys broadcaster_keys_conv;
12587         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
12588         broadcaster_keys_conv.is_owned = false;
12589         LDKChannelPublicKeys countersignatory_keys_conv;
12590         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
12591         countersignatory_keys_conv.is_owned = false;
12592         LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
12593         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
12594         return (long)ret_conv;
12595 }
12596
12597 int8_tArray get_1revokeable_1redeemscript(void* ctx_TODO, int8_tArray revocation_key, jshort contest_delay, int8_tArray broadcaster_delayed_payment_key) {
12598         LDKPublicKey revocation_key_ref;
12599         CHECK(revocation_key.len == 33);
12600         memcpy(revocation_key_ref.compressed_form, revocation_key.ptr, 33);
12601         LDKPublicKey broadcaster_delayed_payment_key_ref;
12602         CHECK(broadcaster_delayed_payment_key.len == 33);
12603         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key.ptr, 33);
12604         LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
12605         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12606         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12607         CVec_u8Z_free(arg_var);
12608         return arg_arr;
12609 }
12610
12611 void HTLCOutputInCommitment_1free(void* ctx_TODO, uint32_t this_ptr) {
12612         LDKHTLCOutputInCommitment this_ptr_conv;
12613         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12614         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12615         HTLCOutputInCommitment_free(this_ptr_conv);
12616 }
12617
12618 uint32_t HTLCOutputInCommitment_1clone(void* ctx_TODO, uint32_t orig) {
12619         LDKHTLCOutputInCommitment orig_conv;
12620         orig_conv.inner = (void*)(orig & (~1));
12621         orig_conv.is_owned = false;
12622         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
12623         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12624         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12625         long ret_ref = (long)ret_var.inner;
12626         if (ret_var.is_owned) {
12627                 ret_ref |= 1;
12628         }
12629         return ret_ref;
12630 }
12631
12632 jboolean HTLCOutputInCommitment_1get_1offered(void* ctx_TODO, uint32_t this_ptr) {
12633         LDKHTLCOutputInCommitment this_ptr_conv;
12634         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12635         this_ptr_conv.is_owned = false;
12636         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
12637         return ret_val;
12638 }
12639
12640 void HTLCOutputInCommitment_1set_1offered(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
12641         LDKHTLCOutputInCommitment this_ptr_conv;
12642         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12643         this_ptr_conv.is_owned = false;
12644         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
12645 }
12646
12647 int64_t HTLCOutputInCommitment_1get_1amount_1msat(void* ctx_TODO, uint32_t this_ptr) {
12648         LDKHTLCOutputInCommitment this_ptr_conv;
12649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12650         this_ptr_conv.is_owned = false;
12651         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
12652         return ret_val;
12653 }
12654
12655 void HTLCOutputInCommitment_1set_1amount_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
12656         LDKHTLCOutputInCommitment this_ptr_conv;
12657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12658         this_ptr_conv.is_owned = false;
12659         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
12660 }
12661
12662 int32_t HTLCOutputInCommitment_1get_1cltv_1expiry(void* ctx_TODO, uint32_t this_ptr) {
12663         LDKHTLCOutputInCommitment this_ptr_conv;
12664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12665         this_ptr_conv.is_owned = false;
12666         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
12667         return ret_val;
12668 }
12669
12670 void HTLCOutputInCommitment_1set_1cltv_1expiry(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
12671         LDKHTLCOutputInCommitment this_ptr_conv;
12672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12673         this_ptr_conv.is_owned = false;
12674         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
12675 }
12676
12677 int8_tArray HTLCOutputInCommitment_1get_1payment_1hash(void* ctx_TODO, uint32_t this_ptr) {
12678         LDKHTLCOutputInCommitment this_ptr_conv;
12679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12680         this_ptr_conv.is_owned = false;
12681         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
12682         memcpy(ret_arr.ptr, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
12683         return ret_arr;
12684 }
12685
12686 void HTLCOutputInCommitment_1set_1payment_1hash(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
12687         LDKHTLCOutputInCommitment this_ptr_conv;
12688         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12689         this_ptr_conv.is_owned = false;
12690         LDKThirtyTwoBytes val_ref;
12691         CHECK(val.len == 32);
12692         memcpy(val_ref.data, val.ptr, 32);
12693         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
12694 }
12695
12696 int8_tArray HTLCOutputInCommitment_1write(void* ctx_TODO, uint32_t obj) {
12697         LDKHTLCOutputInCommitment obj_conv;
12698         obj_conv.inner = (void*)(obj & (~1));
12699         obj_conv.is_owned = false;
12700         LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
12701         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12702         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12703         CVec_u8Z_free(arg_var);
12704         return arg_arr;
12705 }
12706
12707 uint32_t HTLCOutputInCommitment_1read(void* ctx_TODO, int8_tArray ser) {
12708         LDKu8slice ser_ref;
12709         ser_ref.datalen = ser.len;
12710         ser_ref.data = ser.ptr;
12711         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_read(ser_ref);
12712         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12713         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12714         long ret_ref = (long)ret_var.inner;
12715         if (ret_var.is_owned) {
12716                 ret_ref |= 1;
12717         }
12718         return ret_ref;
12719 }
12720
12721 int8_tArray get_1htlc_1redeemscript(void* ctx_TODO, uint32_t htlc, uint32_t keys) {
12722         LDKHTLCOutputInCommitment htlc_conv;
12723         htlc_conv.inner = (void*)(htlc & (~1));
12724         htlc_conv.is_owned = false;
12725         LDKTxCreationKeys keys_conv;
12726         keys_conv.inner = (void*)(keys & (~1));
12727         keys_conv.is_owned = false;
12728         LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
12729         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12730         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12731         CVec_u8Z_free(arg_var);
12732         return arg_arr;
12733 }
12734
12735 int8_tArray make_1funding_1redeemscript(void* ctx_TODO, int8_tArray broadcaster, int8_tArray countersignatory) {
12736         LDKPublicKey broadcaster_ref;
12737         CHECK(broadcaster.len == 33);
12738         memcpy(broadcaster_ref.compressed_form, broadcaster.ptr, 33);
12739         LDKPublicKey countersignatory_ref;
12740         CHECK(countersignatory.len == 33);
12741         memcpy(countersignatory_ref.compressed_form, countersignatory.ptr, 33);
12742         LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
12743         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12744         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12745         CVec_u8Z_free(arg_var);
12746         return arg_arr;
12747 }
12748
12749 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) {
12750         unsigned char prev_hash_arr[32];
12751         CHECK(prev_hash.len == 32);
12752         memcpy(prev_hash_arr, prev_hash.ptr, 32);
12753         unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
12754         LDKHTLCOutputInCommitment htlc_conv;
12755         htlc_conv.inner = (void*)(htlc & (~1));
12756         htlc_conv.is_owned = false;
12757         LDKPublicKey broadcaster_delayed_payment_key_ref;
12758         CHECK(broadcaster_delayed_payment_key.len == 33);
12759         memcpy(broadcaster_delayed_payment_key_ref.compressed_form, broadcaster_delayed_payment_key.ptr, 33);
12760         LDKPublicKey revocation_key_ref;
12761         CHECK(revocation_key.len == 33);
12762         memcpy(revocation_key_ref.compressed_form, revocation_key.ptr, 33);
12763         LDKTransaction arg_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
12764         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
12765         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
12766         Transaction_free(arg_var);
12767         return arg_arr;
12768 }
12769
12770 void ChannelTransactionParameters_1free(void* ctx_TODO, uint32_t this_ptr) {
12771         LDKChannelTransactionParameters this_ptr_conv;
12772         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12773         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12774         ChannelTransactionParameters_free(this_ptr_conv);
12775 }
12776
12777 uint32_t ChannelTransactionParameters_1clone(void* ctx_TODO, uint32_t orig) {
12778         LDKChannelTransactionParameters orig_conv;
12779         orig_conv.inner = (void*)(orig & (~1));
12780         orig_conv.is_owned = false;
12781         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
12782         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12783         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12784         long ret_ref = (long)ret_var.inner;
12785         if (ret_var.is_owned) {
12786                 ret_ref |= 1;
12787         }
12788         return ret_ref;
12789 }
12790
12791 uint32_t ChannelTransactionParameters_1get_1holder_1pubkeys(void* ctx_TODO, uint32_t this_ptr) {
12792         LDKChannelTransactionParameters this_ptr_conv;
12793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12794         this_ptr_conv.is_owned = false;
12795         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
12796         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12797         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12798         long ret_ref = (long)ret_var.inner;
12799         if (ret_var.is_owned) {
12800                 ret_ref |= 1;
12801         }
12802         return ret_ref;
12803 }
12804
12805 void ChannelTransactionParameters_1set_1holder_1pubkeys(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
12806         LDKChannelTransactionParameters this_ptr_conv;
12807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12808         this_ptr_conv.is_owned = false;
12809         LDKChannelPublicKeys val_conv;
12810         val_conv.inner = (void*)(val & (~1));
12811         val_conv.is_owned = (val & 1) || (val == 0);
12812         if (val_conv.inner != NULL)
12813                 val_conv = ChannelPublicKeys_clone(&val_conv);
12814         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
12815 }
12816
12817 jshort ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_ptr) {
12818         LDKChannelTransactionParameters this_ptr_conv;
12819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12820         this_ptr_conv.is_owned = false;
12821         jshort ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
12822         return ret_val;
12823 }
12824
12825 void ChannelTransactionParameters_1set_1holder_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
12826         LDKChannelTransactionParameters this_ptr_conv;
12827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12828         this_ptr_conv.is_owned = false;
12829         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
12830 }
12831
12832 jboolean ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(void* ctx_TODO, uint32_t this_ptr) {
12833         LDKChannelTransactionParameters this_ptr_conv;
12834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12835         this_ptr_conv.is_owned = false;
12836         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
12837         return ret_val;
12838 }
12839
12840 void ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
12841         LDKChannelTransactionParameters this_ptr_conv;
12842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12843         this_ptr_conv.is_owned = false;
12844         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
12845 }
12846
12847 uint32_t ChannelTransactionParameters_1get_1counterparty_1parameters(void* ctx_TODO, uint32_t this_ptr) {
12848         LDKChannelTransactionParameters this_ptr_conv;
12849         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12850         this_ptr_conv.is_owned = false;
12851         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
12852         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12853         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12854         long ret_ref = (long)ret_var.inner;
12855         if (ret_var.is_owned) {
12856                 ret_ref |= 1;
12857         }
12858         return ret_ref;
12859 }
12860
12861 void ChannelTransactionParameters_1set_1counterparty_1parameters(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
12862         LDKChannelTransactionParameters this_ptr_conv;
12863         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12864         this_ptr_conv.is_owned = false;
12865         LDKCounterpartyChannelTransactionParameters val_conv;
12866         val_conv.inner = (void*)(val & (~1));
12867         val_conv.is_owned = (val & 1) || (val == 0);
12868         if (val_conv.inner != NULL)
12869                 val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
12870         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
12871 }
12872
12873 uint32_t ChannelTransactionParameters_1get_1funding_1outpoint(void* ctx_TODO, uint32_t this_ptr) {
12874         LDKChannelTransactionParameters this_ptr_conv;
12875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12876         this_ptr_conv.is_owned = false;
12877         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
12878         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12879         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12880         long ret_ref = (long)ret_var.inner;
12881         if (ret_var.is_owned) {
12882                 ret_ref |= 1;
12883         }
12884         return ret_ref;
12885 }
12886
12887 void ChannelTransactionParameters_1set_1funding_1outpoint(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
12888         LDKChannelTransactionParameters this_ptr_conv;
12889         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12890         this_ptr_conv.is_owned = false;
12891         LDKOutPoint val_conv;
12892         val_conv.inner = (void*)(val & (~1));
12893         val_conv.is_owned = (val & 1) || (val == 0);
12894         if (val_conv.inner != NULL)
12895                 val_conv = OutPoint_clone(&val_conv);
12896         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
12897 }
12898
12899 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) {
12900         LDKChannelPublicKeys holder_pubkeys_arg_conv;
12901         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
12902         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
12903         if (holder_pubkeys_arg_conv.inner != NULL)
12904                 holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
12905         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
12906         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
12907         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
12908         if (counterparty_parameters_arg_conv.inner != NULL)
12909                 counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
12910         LDKOutPoint funding_outpoint_arg_conv;
12911         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
12912         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
12913         if (funding_outpoint_arg_conv.inner != NULL)
12914                 funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
12915         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);
12916         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12917         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12918         long ret_ref = (long)ret_var.inner;
12919         if (ret_var.is_owned) {
12920                 ret_ref |= 1;
12921         }
12922         return ret_ref;
12923 }
12924
12925 void CounterpartyChannelTransactionParameters_1free(void* ctx_TODO, uint32_t this_ptr) {
12926         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12928         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12929         CounterpartyChannelTransactionParameters_free(this_ptr_conv);
12930 }
12931
12932 uint32_t CounterpartyChannelTransactionParameters_1clone(void* ctx_TODO, uint32_t orig) {
12933         LDKCounterpartyChannelTransactionParameters orig_conv;
12934         orig_conv.inner = (void*)(orig & (~1));
12935         orig_conv.is_owned = false;
12936         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
12937         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12938         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12939         long ret_ref = (long)ret_var.inner;
12940         if (ret_var.is_owned) {
12941                 ret_ref |= 1;
12942         }
12943         return ret_ref;
12944 }
12945
12946 uint32_t CounterpartyChannelTransactionParameters_1get_1pubkeys(void* ctx_TODO, uint32_t this_ptr) {
12947         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12949         this_ptr_conv.is_owned = false;
12950         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
12951         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12952         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12953         long ret_ref = (long)ret_var.inner;
12954         if (ret_var.is_owned) {
12955                 ret_ref |= 1;
12956         }
12957         return ret_ref;
12958 }
12959
12960 void CounterpartyChannelTransactionParameters_1set_1pubkeys(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
12961         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12963         this_ptr_conv.is_owned = false;
12964         LDKChannelPublicKeys val_conv;
12965         val_conv.inner = (void*)(val & (~1));
12966         val_conv.is_owned = (val & 1) || (val == 0);
12967         if (val_conv.inner != NULL)
12968                 val_conv = ChannelPublicKeys_clone(&val_conv);
12969         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
12970 }
12971
12972 jshort CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_ptr) {
12973         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12975         this_ptr_conv.is_owned = false;
12976         jshort ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
12977         return ret_val;
12978 }
12979
12980 void CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(void* ctx_TODO, uint32_t this_ptr, jshort val) {
12981         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
12982         this_ptr_conv.inner = (void*)(this_ptr & (~1));
12983         this_ptr_conv.is_owned = false;
12984         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
12985 }
12986
12987 uint32_t CounterpartyChannelTransactionParameters_1new(void* ctx_TODO, uint32_t pubkeys_arg, jshort selected_contest_delay_arg) {
12988         LDKChannelPublicKeys pubkeys_arg_conv;
12989         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
12990         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
12991         if (pubkeys_arg_conv.inner != NULL)
12992                 pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
12993         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
12994         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12995         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12996         long ret_ref = (long)ret_var.inner;
12997         if (ret_var.is_owned) {
12998                 ret_ref |= 1;
12999         }
13000         return ret_ref;
13001 }
13002
13003 jboolean ChannelTransactionParameters_1is_1populated(void* ctx_TODO, uint32_t this_arg) {
13004         LDKChannelTransactionParameters this_arg_conv;
13005         this_arg_conv.inner = (void*)(this_arg & (~1));
13006         this_arg_conv.is_owned = false;
13007         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
13008         return ret_val;
13009 }
13010
13011 uint32_t ChannelTransactionParameters_1as_1holder_1broadcastable(void* ctx_TODO, uint32_t this_arg) {
13012         LDKChannelTransactionParameters this_arg_conv;
13013         this_arg_conv.inner = (void*)(this_arg & (~1));
13014         this_arg_conv.is_owned = false;
13015         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
13016         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13017         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13018         long ret_ref = (long)ret_var.inner;
13019         if (ret_var.is_owned) {
13020                 ret_ref |= 1;
13021         }
13022         return ret_ref;
13023 }
13024
13025 uint32_t ChannelTransactionParameters_1as_1counterparty_1broadcastable(void* ctx_TODO, uint32_t this_arg) {
13026         LDKChannelTransactionParameters this_arg_conv;
13027         this_arg_conv.inner = (void*)(this_arg & (~1));
13028         this_arg_conv.is_owned = false;
13029         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
13030         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13031         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13032         long ret_ref = (long)ret_var.inner;
13033         if (ret_var.is_owned) {
13034                 ret_ref |= 1;
13035         }
13036         return ret_ref;
13037 }
13038
13039 int8_tArray CounterpartyChannelTransactionParameters_1write(void* ctx_TODO, uint32_t obj) {
13040         LDKCounterpartyChannelTransactionParameters obj_conv;
13041         obj_conv.inner = (void*)(obj & (~1));
13042         obj_conv.is_owned = false;
13043         LDKCVec_u8Z arg_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
13044         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13045         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13046         CVec_u8Z_free(arg_var);
13047         return arg_arr;
13048 }
13049
13050 uint32_t CounterpartyChannelTransactionParameters_1read(void* ctx_TODO, int8_tArray ser) {
13051         LDKu8slice ser_ref;
13052         ser_ref.datalen = ser.len;
13053         ser_ref.data = ser.ptr;
13054         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_read(ser_ref);
13055         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13056         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13057         long ret_ref = (long)ret_var.inner;
13058         if (ret_var.is_owned) {
13059                 ret_ref |= 1;
13060         }
13061         return ret_ref;
13062 }
13063
13064 int8_tArray ChannelTransactionParameters_1write(void* ctx_TODO, uint32_t obj) {
13065         LDKChannelTransactionParameters obj_conv;
13066         obj_conv.inner = (void*)(obj & (~1));
13067         obj_conv.is_owned = false;
13068         LDKCVec_u8Z arg_var = ChannelTransactionParameters_write(&obj_conv);
13069         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13070         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13071         CVec_u8Z_free(arg_var);
13072         return arg_arr;
13073 }
13074
13075 uint32_t ChannelTransactionParameters_1read(void* ctx_TODO, int8_tArray ser) {
13076         LDKu8slice ser_ref;
13077         ser_ref.datalen = ser.len;
13078         ser_ref.data = ser.ptr;
13079         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_read(ser_ref);
13080         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13081         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13082         long ret_ref = (long)ret_var.inner;
13083         if (ret_var.is_owned) {
13084                 ret_ref |= 1;
13085         }
13086         return ret_ref;
13087 }
13088
13089 void DirectedChannelTransactionParameters_1free(void* ctx_TODO, uint32_t this_ptr) {
13090         LDKDirectedChannelTransactionParameters this_ptr_conv;
13091         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13092         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13093         DirectedChannelTransactionParameters_free(this_ptr_conv);
13094 }
13095
13096 uint32_t DirectedChannelTransactionParameters_1broadcaster_1pubkeys(void* ctx_TODO, uint32_t this_arg) {
13097         LDKDirectedChannelTransactionParameters this_arg_conv;
13098         this_arg_conv.inner = (void*)(this_arg & (~1));
13099         this_arg_conv.is_owned = false;
13100         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
13101         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13102         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13103         long ret_ref = (long)ret_var.inner;
13104         if (ret_var.is_owned) {
13105                 ret_ref |= 1;
13106         }
13107         return ret_ref;
13108 }
13109
13110 uint32_t DirectedChannelTransactionParameters_1countersignatory_1pubkeys(void* ctx_TODO, uint32_t this_arg) {
13111         LDKDirectedChannelTransactionParameters this_arg_conv;
13112         this_arg_conv.inner = (void*)(this_arg & (~1));
13113         this_arg_conv.is_owned = false;
13114         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
13115         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13116         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13117         long ret_ref = (long)ret_var.inner;
13118         if (ret_var.is_owned) {
13119                 ret_ref |= 1;
13120         }
13121         return ret_ref;
13122 }
13123
13124 jshort DirectedChannelTransactionParameters_1contest_1delay(void* ctx_TODO, uint32_t this_arg) {
13125         LDKDirectedChannelTransactionParameters this_arg_conv;
13126         this_arg_conv.inner = (void*)(this_arg & (~1));
13127         this_arg_conv.is_owned = false;
13128         jshort ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
13129         return ret_val;
13130 }
13131
13132 jboolean DirectedChannelTransactionParameters_1is_1outbound(void* ctx_TODO, uint32_t this_arg) {
13133         LDKDirectedChannelTransactionParameters this_arg_conv;
13134         this_arg_conv.inner = (void*)(this_arg & (~1));
13135         this_arg_conv.is_owned = false;
13136         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
13137         return ret_val;
13138 }
13139
13140 uint32_t DirectedChannelTransactionParameters_1funding_1outpoint(void* ctx_TODO, uint32_t this_arg) {
13141         LDKDirectedChannelTransactionParameters this_arg_conv;
13142         this_arg_conv.inner = (void*)(this_arg & (~1));
13143         this_arg_conv.is_owned = false;
13144         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
13145         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13146         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13147         long ret_ref = (long)ret_var.inner;
13148         if (ret_var.is_owned) {
13149                 ret_ref |= 1;
13150         }
13151         return ret_ref;
13152 }
13153
13154 void HolderCommitmentTransaction_1free(void* ctx_TODO, uint32_t this_ptr) {
13155         LDKHolderCommitmentTransaction this_ptr_conv;
13156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13157         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13158         HolderCommitmentTransaction_free(this_ptr_conv);
13159 }
13160
13161 uint32_t HolderCommitmentTransaction_1clone(void* ctx_TODO, uint32_t orig) {
13162         LDKHolderCommitmentTransaction orig_conv;
13163         orig_conv.inner = (void*)(orig & (~1));
13164         orig_conv.is_owned = false;
13165         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
13166         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13167         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13168         long ret_ref = (long)ret_var.inner;
13169         if (ret_var.is_owned) {
13170                 ret_ref |= 1;
13171         }
13172         return ret_ref;
13173 }
13174
13175 int8_tArray HolderCommitmentTransaction_1get_1counterparty_1sig(void* ctx_TODO, uint32_t this_ptr) {
13176         LDKHolderCommitmentTransaction this_ptr_conv;
13177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13178         this_ptr_conv.is_owned = false;
13179         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
13180         memcpy(arg_arr.ptr, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
13181         return arg_arr;
13182 }
13183
13184 void HolderCommitmentTransaction_1set_1counterparty_1sig(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13185         LDKHolderCommitmentTransaction this_ptr_conv;
13186         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13187         this_ptr_conv.is_owned = false;
13188         LDKSignature val_ref;
13189         CHECK(val.len == 64);
13190         memcpy(val_ref.compact_form, val.ptr, 64);
13191         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
13192 }
13193
13194 void HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
13195         LDKHolderCommitmentTransaction this_ptr_conv;
13196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13197         this_ptr_conv.is_owned = false;
13198         LDKCVec_SignatureZ val_constr;
13199         val_constr.datalen = val.len;
13200         if (val_constr.datalen > 0)
13201                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13202         else
13203                 val_constr.data = NULL;
13204         int8_tArray* val_vals = (int8_tArray*) val.ptr;
13205         for (size_t i = 0; i < val_constr.datalen; i++) {
13206                 int8_tArray arr_conv_8 = val_vals[i];
13207                 LDKSignature arr_conv_8_ref;
13208                 CHECK(arr_conv_8.len == 64);
13209                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
13210                 val_constr.data[i] = arr_conv_8_ref;
13211         }
13212         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
13213 }
13214
13215 int8_tArray HolderCommitmentTransaction_1write(void* ctx_TODO, uint32_t obj) {
13216         LDKHolderCommitmentTransaction obj_conv;
13217         obj_conv.inner = (void*)(obj & (~1));
13218         obj_conv.is_owned = false;
13219         LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
13220         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13221         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13222         CVec_u8Z_free(arg_var);
13223         return arg_arr;
13224 }
13225
13226 uint32_t HolderCommitmentTransaction_1read(void* ctx_TODO, int8_tArray ser) {
13227         LDKu8slice ser_ref;
13228         ser_ref.datalen = ser.len;
13229         ser_ref.data = ser.ptr;
13230         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_read(ser_ref);
13231         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13232         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13233         long ret_ref = (long)ret_var.inner;
13234         if (ret_var.is_owned) {
13235                 ret_ref |= 1;
13236         }
13237         return ret_ref;
13238 }
13239
13240 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) {
13241         LDKCommitmentTransaction commitment_tx_conv;
13242         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
13243         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
13244         if (commitment_tx_conv.inner != NULL)
13245                 commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
13246         LDKSignature counterparty_sig_ref;
13247         CHECK(counterparty_sig.len == 64);
13248         memcpy(counterparty_sig_ref.compact_form, counterparty_sig.ptr, 64);
13249         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
13250         counterparty_htlc_sigs_constr.datalen = counterparty_htlc_sigs.len;
13251         if (counterparty_htlc_sigs_constr.datalen > 0)
13252                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13253         else
13254                 counterparty_htlc_sigs_constr.data = NULL;
13255         int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*) counterparty_htlc_sigs.ptr;
13256         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
13257                 int8_tArray arr_conv_8 = counterparty_htlc_sigs_vals[i];
13258                 LDKSignature arr_conv_8_ref;
13259                 CHECK(arr_conv_8.len == 64);
13260                 memcpy(arr_conv_8_ref.compact_form, arr_conv_8.ptr, 64);
13261                 counterparty_htlc_sigs_constr.data[i] = arr_conv_8_ref;
13262         }
13263         LDKPublicKey holder_funding_key_ref;
13264         CHECK(holder_funding_key.len == 33);
13265         memcpy(holder_funding_key_ref.compressed_form, holder_funding_key.ptr, 33);
13266         LDKPublicKey counterparty_funding_key_ref;
13267         CHECK(counterparty_funding_key.len == 33);
13268         memcpy(counterparty_funding_key_ref.compressed_form, counterparty_funding_key.ptr, 33);
13269         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
13270         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13271         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13272         long ret_ref = (long)ret_var.inner;
13273         if (ret_var.is_owned) {
13274                 ret_ref |= 1;
13275         }
13276         return ret_ref;
13277 }
13278
13279 void BuiltCommitmentTransaction_1free(void* ctx_TODO, uint32_t this_ptr) {
13280         LDKBuiltCommitmentTransaction this_ptr_conv;
13281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13282         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13283         BuiltCommitmentTransaction_free(this_ptr_conv);
13284 }
13285
13286 uint32_t BuiltCommitmentTransaction_1clone(void* ctx_TODO, uint32_t orig) {
13287         LDKBuiltCommitmentTransaction orig_conv;
13288         orig_conv.inner = (void*)(orig & (~1));
13289         orig_conv.is_owned = false;
13290         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
13291         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13292         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13293         long ret_ref = (long)ret_var.inner;
13294         if (ret_var.is_owned) {
13295                 ret_ref |= 1;
13296         }
13297         return ret_ref;
13298 }
13299
13300 int8_tArray BuiltCommitmentTransaction_1get_1transaction(void* ctx_TODO, uint32_t this_ptr) {
13301         LDKBuiltCommitmentTransaction this_ptr_conv;
13302         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13303         this_ptr_conv.is_owned = false;
13304         LDKTransaction arg_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
13305         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13306         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13307         Transaction_free(arg_var);
13308         return arg_arr;
13309 }
13310
13311 void BuiltCommitmentTransaction_1set_1transaction(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13312         LDKBuiltCommitmentTransaction this_ptr_conv;
13313         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13314         this_ptr_conv.is_owned = false;
13315         LDKTransaction val_ref;
13316         val_ref.datalen = val.len;
13317         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
13318         memcpy(val_ref.data, val.ptr, val_ref.datalen);
13319         val_ref.data_is_owned = true;
13320         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
13321 }
13322
13323 int8_tArray BuiltCommitmentTransaction_1get_1txid(void* ctx_TODO, uint32_t this_ptr) {
13324         LDKBuiltCommitmentTransaction this_ptr_conv;
13325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13326         this_ptr_conv.is_owned = false;
13327         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
13328         memcpy(ret_arr.ptr, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
13329         return ret_arr;
13330 }
13331
13332 void BuiltCommitmentTransaction_1set_1txid(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13333         LDKBuiltCommitmentTransaction this_ptr_conv;
13334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13335         this_ptr_conv.is_owned = false;
13336         LDKThirtyTwoBytes val_ref;
13337         CHECK(val.len == 32);
13338         memcpy(val_ref.data, val.ptr, 32);
13339         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
13340 }
13341
13342 uint32_t BuiltCommitmentTransaction_1new(void* ctx_TODO, int8_tArray transaction_arg, int8_tArray txid_arg) {
13343         LDKTransaction transaction_arg_ref;
13344         transaction_arg_ref.datalen = transaction_arg.len;
13345         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
13346         memcpy(transaction_arg_ref.data, transaction_arg.ptr, transaction_arg_ref.datalen);
13347         transaction_arg_ref.data_is_owned = true;
13348         LDKThirtyTwoBytes txid_arg_ref;
13349         CHECK(txid_arg.len == 32);
13350         memcpy(txid_arg_ref.data, txid_arg.ptr, 32);
13351         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
13352         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13353         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13354         long ret_ref = (long)ret_var.inner;
13355         if (ret_var.is_owned) {
13356                 ret_ref |= 1;
13357         }
13358         return ret_ref;
13359 }
13360
13361 int8_tArray BuiltCommitmentTransaction_1write(void* ctx_TODO, uint32_t obj) {
13362         LDKBuiltCommitmentTransaction obj_conv;
13363         obj_conv.inner = (void*)(obj & (~1));
13364         obj_conv.is_owned = false;
13365         LDKCVec_u8Z arg_var = BuiltCommitmentTransaction_write(&obj_conv);
13366         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13367         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13368         CVec_u8Z_free(arg_var);
13369         return arg_arr;
13370 }
13371
13372 uint32_t BuiltCommitmentTransaction_1read(void* ctx_TODO, int8_tArray ser) {
13373         LDKu8slice ser_ref;
13374         ser_ref.datalen = ser.len;
13375         ser_ref.data = ser.ptr;
13376         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_read(ser_ref);
13377         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13378         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13379         long ret_ref = (long)ret_var.inner;
13380         if (ret_var.is_owned) {
13381                 ret_ref |= 1;
13382         }
13383         return ret_ref;
13384 }
13385
13386 int8_tArray BuiltCommitmentTransaction_1get_1sighash_1all(void* ctx_TODO, uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
13387         LDKBuiltCommitmentTransaction this_arg_conv;
13388         this_arg_conv.inner = (void*)(this_arg & (~1));
13389         this_arg_conv.is_owned = false;
13390         LDKu8slice funding_redeemscript_ref;
13391         funding_redeemscript_ref.datalen = funding_redeemscript.len;
13392         funding_redeemscript_ref.data = funding_redeemscript.ptr;
13393         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
13394         memcpy(arg_arr.ptr, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
13395         return arg_arr;
13396 }
13397
13398 int8_tArray BuiltCommitmentTransaction_1sign(void* ctx_TODO, uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
13399         LDKBuiltCommitmentTransaction this_arg_conv;
13400         this_arg_conv.inner = (void*)(this_arg & (~1));
13401         this_arg_conv.is_owned = false;
13402         unsigned char funding_key_arr[32];
13403         CHECK(funding_key.len == 32);
13404         memcpy(funding_key_arr, funding_key.ptr, 32);
13405         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
13406         LDKu8slice funding_redeemscript_ref;
13407         funding_redeemscript_ref.datalen = funding_redeemscript.len;
13408         funding_redeemscript_ref.data = funding_redeemscript.ptr;
13409         int8_tArray arg_arr = { .len = 64, .ptr = MALLOC(64, "Native int8_tArray Bytes") };
13410         memcpy(arg_arr.ptr, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
13411         return arg_arr;
13412 }
13413
13414 void CommitmentTransaction_1free(void* ctx_TODO, uint32_t this_ptr) {
13415         LDKCommitmentTransaction this_ptr_conv;
13416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13417         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13418         CommitmentTransaction_free(this_ptr_conv);
13419 }
13420
13421 uint32_t CommitmentTransaction_1clone(void* ctx_TODO, uint32_t orig) {
13422         LDKCommitmentTransaction orig_conv;
13423         orig_conv.inner = (void*)(orig & (~1));
13424         orig_conv.is_owned = false;
13425         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
13426         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13427         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13428         long ret_ref = (long)ret_var.inner;
13429         if (ret_var.is_owned) {
13430                 ret_ref |= 1;
13431         }
13432         return ret_ref;
13433 }
13434
13435 int8_tArray CommitmentTransaction_1write(void* ctx_TODO, uint32_t obj) {
13436         LDKCommitmentTransaction obj_conv;
13437         obj_conv.inner = (void*)(obj & (~1));
13438         obj_conv.is_owned = false;
13439         LDKCVec_u8Z arg_var = CommitmentTransaction_write(&obj_conv);
13440         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13441         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13442         CVec_u8Z_free(arg_var);
13443         return arg_arr;
13444 }
13445
13446 uint32_t CommitmentTransaction_1read(void* ctx_TODO, int8_tArray ser) {
13447         LDKu8slice ser_ref;
13448         ser_ref.datalen = ser.len;
13449         ser_ref.data = ser.ptr;
13450         LDKCommitmentTransaction ret_var = CommitmentTransaction_read(ser_ref);
13451         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13452         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13453         long ret_ref = (long)ret_var.inner;
13454         if (ret_var.is_owned) {
13455                 ret_ref |= 1;
13456         }
13457         return ret_ref;
13458 }
13459
13460 int64_t CommitmentTransaction_1commitment_1number(void* ctx_TODO, uint32_t this_arg) {
13461         LDKCommitmentTransaction this_arg_conv;
13462         this_arg_conv.inner = (void*)(this_arg & (~1));
13463         this_arg_conv.is_owned = false;
13464         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
13465         return ret_val;
13466 }
13467
13468 int64_t CommitmentTransaction_1to_1broadcaster_1value_1sat(void* ctx_TODO, uint32_t this_arg) {
13469         LDKCommitmentTransaction this_arg_conv;
13470         this_arg_conv.inner = (void*)(this_arg & (~1));
13471         this_arg_conv.is_owned = false;
13472         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
13473         return ret_val;
13474 }
13475
13476 int64_t CommitmentTransaction_1to_1countersignatory_1value_1sat(void* ctx_TODO, uint32_t this_arg) {
13477         LDKCommitmentTransaction this_arg_conv;
13478         this_arg_conv.inner = (void*)(this_arg & (~1));
13479         this_arg_conv.is_owned = false;
13480         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
13481         return ret_val;
13482 }
13483
13484 int32_t CommitmentTransaction_1feerate_1per_1kw(void* ctx_TODO, uint32_t this_arg) {
13485         LDKCommitmentTransaction this_arg_conv;
13486         this_arg_conv.inner = (void*)(this_arg & (~1));
13487         this_arg_conv.is_owned = false;
13488         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
13489         return ret_val;
13490 }
13491
13492 uint32_t CommitmentTransaction_1trust(void* ctx_TODO, uint32_t this_arg) {
13493         LDKCommitmentTransaction this_arg_conv;
13494         this_arg_conv.inner = (void*)(this_arg & (~1));
13495         this_arg_conv.is_owned = false;
13496         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
13497         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13498         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13499         long ret_ref = (long)ret_var.inner;
13500         if (ret_var.is_owned) {
13501                 ret_ref |= 1;
13502         }
13503         return ret_ref;
13504 }
13505
13506 uint32_t CommitmentTransaction_1verify(void* ctx_TODO, uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
13507         LDKCommitmentTransaction this_arg_conv;
13508         this_arg_conv.inner = (void*)(this_arg & (~1));
13509         this_arg_conv.is_owned = false;
13510         LDKDirectedChannelTransactionParameters channel_parameters_conv;
13511         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
13512         channel_parameters_conv.is_owned = false;
13513         LDKChannelPublicKeys broadcaster_keys_conv;
13514         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
13515         broadcaster_keys_conv.is_owned = false;
13516         LDKChannelPublicKeys countersignatory_keys_conv;
13517         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
13518         countersignatory_keys_conv.is_owned = false;
13519         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
13520         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
13521         return (long)ret_conv;
13522 }
13523
13524 void TrustedCommitmentTransaction_1free(void* ctx_TODO, uint32_t this_ptr) {
13525         LDKTrustedCommitmentTransaction this_ptr_conv;
13526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13527         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13528         TrustedCommitmentTransaction_free(this_ptr_conv);
13529 }
13530
13531 int8_tArray TrustedCommitmentTransaction_1txid(void* ctx_TODO, uint32_t this_arg) {
13532         LDKTrustedCommitmentTransaction this_arg_conv;
13533         this_arg_conv.inner = (void*)(this_arg & (~1));
13534         this_arg_conv.is_owned = false;
13535         int8_tArray arg_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
13536         memcpy(arg_arr.ptr, TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
13537         return arg_arr;
13538 }
13539
13540 uint32_t TrustedCommitmentTransaction_1built_1transaction(void* ctx_TODO, uint32_t this_arg) {
13541         LDKTrustedCommitmentTransaction this_arg_conv;
13542         this_arg_conv.inner = (void*)(this_arg & (~1));
13543         this_arg_conv.is_owned = false;
13544         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
13545         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13546         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13547         long ret_ref = (long)ret_var.inner;
13548         if (ret_var.is_owned) {
13549                 ret_ref |= 1;
13550         }
13551         return ret_ref;
13552 }
13553
13554 uint32_t TrustedCommitmentTransaction_1keys(void* ctx_TODO, uint32_t this_arg) {
13555         LDKTrustedCommitmentTransaction this_arg_conv;
13556         this_arg_conv.inner = (void*)(this_arg & (~1));
13557         this_arg_conv.is_owned = false;
13558         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
13559         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13560         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13561         long ret_ref = (long)ret_var.inner;
13562         if (ret_var.is_owned) {
13563                 ret_ref |= 1;
13564         }
13565         return ret_ref;
13566 }
13567
13568 uint32_t TrustedCommitmentTransaction_1get_1htlc_1sigs(void* ctx_TODO, uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
13569         LDKTrustedCommitmentTransaction this_arg_conv;
13570         this_arg_conv.inner = (void*)(this_arg & (~1));
13571         this_arg_conv.is_owned = false;
13572         unsigned char htlc_base_key_arr[32];
13573         CHECK(htlc_base_key.len == 32);
13574         memcpy(htlc_base_key_arr, htlc_base_key.ptr, 32);
13575         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
13576         LDKDirectedChannelTransactionParameters channel_parameters_conv;
13577         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
13578         channel_parameters_conv.is_owned = false;
13579         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
13580         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
13581         return (long)ret_conv;
13582 }
13583
13584 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) {
13585         LDKPublicKey broadcaster_payment_basepoint_ref;
13586         CHECK(broadcaster_payment_basepoint.len == 33);
13587         memcpy(broadcaster_payment_basepoint_ref.compressed_form, broadcaster_payment_basepoint.ptr, 33);
13588         LDKPublicKey countersignatory_payment_basepoint_ref;
13589         CHECK(countersignatory_payment_basepoint.len == 33);
13590         memcpy(countersignatory_payment_basepoint_ref.compressed_form, countersignatory_payment_basepoint.ptr, 33);
13591         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
13592         return ret_val;
13593 }
13594
13595 void InitFeatures_1free(void* ctx_TODO, uint32_t this_ptr) {
13596         LDKInitFeatures this_ptr_conv;
13597         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13598         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13599         InitFeatures_free(this_ptr_conv);
13600 }
13601
13602 void NodeFeatures_1free(void* ctx_TODO, uint32_t this_ptr) {
13603         LDKNodeFeatures this_ptr_conv;
13604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13605         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13606         NodeFeatures_free(this_ptr_conv);
13607 }
13608
13609 void ChannelFeatures_1free(void* ctx_TODO, uint32_t this_ptr) {
13610         LDKChannelFeatures this_ptr_conv;
13611         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13612         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13613         ChannelFeatures_free(this_ptr_conv);
13614 }
13615
13616 void RouteHop_1free(void* ctx_TODO, uint32_t this_ptr) {
13617         LDKRouteHop this_ptr_conv;
13618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13619         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13620         RouteHop_free(this_ptr_conv);
13621 }
13622
13623 uint32_t RouteHop_1clone(void* ctx_TODO, uint32_t orig) {
13624         LDKRouteHop orig_conv;
13625         orig_conv.inner = (void*)(orig & (~1));
13626         orig_conv.is_owned = false;
13627         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
13628         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13629         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13630         long ret_ref = (long)ret_var.inner;
13631         if (ret_var.is_owned) {
13632                 ret_ref |= 1;
13633         }
13634         return ret_ref;
13635 }
13636
13637 int8_tArray RouteHop_1get_1pubkey(void* ctx_TODO, uint32_t this_ptr) {
13638         LDKRouteHop this_ptr_conv;
13639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13640         this_ptr_conv.is_owned = false;
13641         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
13642         memcpy(arg_arr.ptr, RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
13643         return arg_arr;
13644 }
13645
13646 void RouteHop_1set_1pubkey(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13647         LDKRouteHop this_ptr_conv;
13648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13649         this_ptr_conv.is_owned = false;
13650         LDKPublicKey val_ref;
13651         CHECK(val.len == 33);
13652         memcpy(val_ref.compressed_form, val.ptr, 33);
13653         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
13654 }
13655
13656 uint32_t RouteHop_1get_1node_1features(void* ctx_TODO, uint32_t this_ptr) {
13657         LDKRouteHop this_ptr_conv;
13658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13659         this_ptr_conv.is_owned = false;
13660         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
13661         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13662         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13663         long ret_ref = (long)ret_var.inner;
13664         if (ret_var.is_owned) {
13665                 ret_ref |= 1;
13666         }
13667         return ret_ref;
13668 }
13669
13670 void RouteHop_1set_1node_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13671         LDKRouteHop this_ptr_conv;
13672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13673         this_ptr_conv.is_owned = false;
13674         LDKNodeFeatures val_conv;
13675         val_conv.inner = (void*)(val & (~1));
13676         val_conv.is_owned = (val & 1) || (val == 0);
13677         // Warning: we may need a move here but can't clone!
13678         RouteHop_set_node_features(&this_ptr_conv, val_conv);
13679 }
13680
13681 int64_t RouteHop_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
13682         LDKRouteHop this_ptr_conv;
13683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13684         this_ptr_conv.is_owned = false;
13685         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
13686         return ret_val;
13687 }
13688
13689 void RouteHop_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13690         LDKRouteHop this_ptr_conv;
13691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13692         this_ptr_conv.is_owned = false;
13693         RouteHop_set_short_channel_id(&this_ptr_conv, val);
13694 }
13695
13696 uint32_t RouteHop_1get_1channel_1features(void* ctx_TODO, uint32_t this_ptr) {
13697         LDKRouteHop this_ptr_conv;
13698         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13699         this_ptr_conv.is_owned = false;
13700         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
13701         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13702         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13703         long ret_ref = (long)ret_var.inner;
13704         if (ret_var.is_owned) {
13705                 ret_ref |= 1;
13706         }
13707         return ret_ref;
13708 }
13709
13710 void RouteHop_1set_1channel_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13711         LDKRouteHop this_ptr_conv;
13712         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13713         this_ptr_conv.is_owned = false;
13714         LDKChannelFeatures val_conv;
13715         val_conv.inner = (void*)(val & (~1));
13716         val_conv.is_owned = (val & 1) || (val == 0);
13717         // Warning: we may need a move here but can't clone!
13718         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
13719 }
13720
13721 int64_t RouteHop_1get_1fee_1msat(void* ctx_TODO, uint32_t this_ptr) {
13722         LDKRouteHop this_ptr_conv;
13723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13724         this_ptr_conv.is_owned = false;
13725         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
13726         return ret_val;
13727 }
13728
13729 void RouteHop_1set_1fee_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13730         LDKRouteHop this_ptr_conv;
13731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13732         this_ptr_conv.is_owned = false;
13733         RouteHop_set_fee_msat(&this_ptr_conv, val);
13734 }
13735
13736 int32_t RouteHop_1get_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr) {
13737         LDKRouteHop this_ptr_conv;
13738         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13739         this_ptr_conv.is_owned = false;
13740         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
13741         return ret_val;
13742 }
13743
13744 void RouteHop_1set_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
13745         LDKRouteHop this_ptr_conv;
13746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13747         this_ptr_conv.is_owned = false;
13748         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
13749 }
13750
13751 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) {
13752         LDKPublicKey pubkey_arg_ref;
13753         CHECK(pubkey_arg.len == 33);
13754         memcpy(pubkey_arg_ref.compressed_form, pubkey_arg.ptr, 33);
13755         LDKNodeFeatures node_features_arg_conv;
13756         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
13757         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
13758         // Warning: we may need a move here but can't clone!
13759         LDKChannelFeatures channel_features_arg_conv;
13760         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
13761         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
13762         // Warning: we may need a move here but can't clone!
13763         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);
13764         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13765         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13766         long ret_ref = (long)ret_var.inner;
13767         if (ret_var.is_owned) {
13768                 ret_ref |= 1;
13769         }
13770         return ret_ref;
13771 }
13772
13773 void Route_1free(void* ctx_TODO, uint32_t this_ptr) {
13774         LDKRoute this_ptr_conv;
13775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13776         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13777         Route_free(this_ptr_conv);
13778 }
13779
13780 uint32_t Route_1clone(void* ctx_TODO, uint32_t orig) {
13781         LDKRoute orig_conv;
13782         orig_conv.inner = (void*)(orig & (~1));
13783         orig_conv.is_owned = false;
13784         LDKRoute ret_var = Route_clone(&orig_conv);
13785         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13786         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13787         long ret_ref = (long)ret_var.inner;
13788         if (ret_var.is_owned) {
13789                 ret_ref |= 1;
13790         }
13791         return ret_ref;
13792 }
13793
13794 void Route_1set_1paths(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
13795         LDKRoute this_ptr_conv;
13796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13797         this_ptr_conv.is_owned = false;
13798         LDKCVec_CVec_RouteHopZZ val_constr;
13799         val_constr.datalen = val.len;
13800         if (val_constr.datalen > 0)
13801                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
13802         else
13803                 val_constr.data = NULL;
13804         uint32_tArray* val_vals = (uint32_tArray*) val.ptr;
13805         for (size_t m = 0; m < val_constr.datalen; m++) {
13806                 uint32_tArray arr_conv_12 = val_vals[m];
13807                 LDKCVec_RouteHopZ arr_conv_12_constr;
13808                 arr_conv_12_constr.datalen = arr_conv_12.len;
13809                 if (arr_conv_12_constr.datalen > 0)
13810                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13811                 else
13812                         arr_conv_12_constr.data = NULL;
13813                 uint32_t* arr_conv_12_vals = (uint32_t*) arr_conv_12.ptr;
13814                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
13815                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
13816                         LDKRouteHop arr_conv_10_conv;
13817                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
13818                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
13819                         if (arr_conv_10_conv.inner != NULL)
13820                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
13821                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
13822                 }
13823                 val_constr.data[m] = arr_conv_12_constr;
13824         }
13825         Route_set_paths(&this_ptr_conv, val_constr);
13826 }
13827
13828 uint32_t Route_1new(void* ctx_TODO, uint32_tArray paths_arg) {
13829         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
13830         paths_arg_constr.datalen = paths_arg.len;
13831         if (paths_arg_constr.datalen > 0)
13832                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
13833         else
13834                 paths_arg_constr.data = NULL;
13835         uint32_tArray* paths_arg_vals = (uint32_tArray*) paths_arg.ptr;
13836         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
13837                 uint32_tArray arr_conv_12 = paths_arg_vals[m];
13838                 LDKCVec_RouteHopZ arr_conv_12_constr;
13839                 arr_conv_12_constr.datalen = arr_conv_12.len;
13840                 if (arr_conv_12_constr.datalen > 0)
13841                         arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
13842                 else
13843                         arr_conv_12_constr.data = NULL;
13844                 uint32_t* arr_conv_12_vals = (uint32_t*) arr_conv_12.ptr;
13845                 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
13846                         uint32_t arr_conv_10 = arr_conv_12_vals[k];
13847                         LDKRouteHop arr_conv_10_conv;
13848                         arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
13849                         arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
13850                         if (arr_conv_10_conv.inner != NULL)
13851                                 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
13852                         arr_conv_12_constr.data[k] = arr_conv_10_conv;
13853                 }
13854                 paths_arg_constr.data[m] = arr_conv_12_constr;
13855         }
13856         LDKRoute ret_var = Route_new(paths_arg_constr);
13857         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13858         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13859         long ret_ref = (long)ret_var.inner;
13860         if (ret_var.is_owned) {
13861                 ret_ref |= 1;
13862         }
13863         return ret_ref;
13864 }
13865
13866 int8_tArray Route_1write(void* ctx_TODO, uint32_t obj) {
13867         LDKRoute obj_conv;
13868         obj_conv.inner = (void*)(obj & (~1));
13869         obj_conv.is_owned = false;
13870         LDKCVec_u8Z arg_var = Route_write(&obj_conv);
13871         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
13872         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
13873         CVec_u8Z_free(arg_var);
13874         return arg_arr;
13875 }
13876
13877 uint32_t Route_1read(void* ctx_TODO, int8_tArray ser) {
13878         LDKu8slice ser_ref;
13879         ser_ref.datalen = ser.len;
13880         ser_ref.data = ser.ptr;
13881         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
13882         *ret_conv = Route_read(ser_ref);
13883         return (long)ret_conv;
13884 }
13885
13886 void RouteHint_1free(void* ctx_TODO, uint32_t this_ptr) {
13887         LDKRouteHint this_ptr_conv;
13888         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13889         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13890         RouteHint_free(this_ptr_conv);
13891 }
13892
13893 uint32_t RouteHint_1clone(void* ctx_TODO, uint32_t orig) {
13894         LDKRouteHint orig_conv;
13895         orig_conv.inner = (void*)(orig & (~1));
13896         orig_conv.is_owned = false;
13897         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
13898         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13899         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13900         long ret_ref = (long)ret_var.inner;
13901         if (ret_var.is_owned) {
13902                 ret_ref |= 1;
13903         }
13904         return ret_ref;
13905 }
13906
13907 int8_tArray RouteHint_1get_1src_1node_1id(void* ctx_TODO, uint32_t this_ptr) {
13908         LDKRouteHint this_ptr_conv;
13909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13910         this_ptr_conv.is_owned = false;
13911         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
13912         memcpy(arg_arr.ptr, RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
13913         return arg_arr;
13914 }
13915
13916 void RouteHint_1set_1src_1node_1id(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
13917         LDKRouteHint this_ptr_conv;
13918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13919         this_ptr_conv.is_owned = false;
13920         LDKPublicKey val_ref;
13921         CHECK(val.len == 33);
13922         memcpy(val_ref.compressed_form, val.ptr, 33);
13923         RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
13924 }
13925
13926 int64_t RouteHint_1get_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr) {
13927         LDKRouteHint this_ptr_conv;
13928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13929         this_ptr_conv.is_owned = false;
13930         int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
13931         return ret_val;
13932 }
13933
13934 void RouteHint_1set_1short_1channel_1id(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13935         LDKRouteHint this_ptr_conv;
13936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13937         this_ptr_conv.is_owned = false;
13938         RouteHint_set_short_channel_id(&this_ptr_conv, val);
13939 }
13940
13941 uint32_t RouteHint_1get_1fees(void* ctx_TODO, uint32_t this_ptr) {
13942         LDKRouteHint this_ptr_conv;
13943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13944         this_ptr_conv.is_owned = false;
13945         LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
13946         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13947         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13948         long ret_ref = (long)ret_var.inner;
13949         if (ret_var.is_owned) {
13950                 ret_ref |= 1;
13951         }
13952         return ret_ref;
13953 }
13954
13955 void RouteHint_1set_1fees(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
13956         LDKRouteHint this_ptr_conv;
13957         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13958         this_ptr_conv.is_owned = false;
13959         LDKRoutingFees val_conv;
13960         val_conv.inner = (void*)(val & (~1));
13961         val_conv.is_owned = (val & 1) || (val == 0);
13962         if (val_conv.inner != NULL)
13963                 val_conv = RoutingFees_clone(&val_conv);
13964         RouteHint_set_fees(&this_ptr_conv, val_conv);
13965 }
13966
13967 jshort RouteHint_1get_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr) {
13968         LDKRouteHint this_ptr_conv;
13969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13970         this_ptr_conv.is_owned = false;
13971         jshort ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
13972         return ret_val;
13973 }
13974
13975 void RouteHint_1set_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr, jshort val) {
13976         LDKRouteHint this_ptr_conv;
13977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13978         this_ptr_conv.is_owned = false;
13979         RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
13980 }
13981
13982 int64_t RouteHint_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
13983         LDKRouteHint this_ptr_conv;
13984         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13985         this_ptr_conv.is_owned = false;
13986         int64_t ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
13987         return ret_val;
13988 }
13989
13990 void RouteHint_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
13991         LDKRouteHint this_ptr_conv;
13992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
13993         this_ptr_conv.is_owned = false;
13994         RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
13995 }
13996
13997 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) {
13998         LDKPublicKey src_node_id_arg_ref;
13999         CHECK(src_node_id_arg.len == 33);
14000         memcpy(src_node_id_arg_ref.compressed_form, src_node_id_arg.ptr, 33);
14001         LDKRoutingFees fees_arg_conv;
14002         fees_arg_conv.inner = (void*)(fees_arg & (~1));
14003         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
14004         if (fees_arg_conv.inner != NULL)
14005                 fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
14006         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);
14007         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14008         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14009         long ret_ref = (long)ret_var.inner;
14010         if (ret_var.is_owned) {
14011                 ret_ref |= 1;
14012         }
14013         return ret_ref;
14014 }
14015
14016 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) {
14017         LDKPublicKey our_node_id_ref;
14018         CHECK(our_node_id.len == 33);
14019         memcpy(our_node_id_ref.compressed_form, our_node_id.ptr, 33);
14020         LDKNetworkGraph network_conv;
14021         network_conv.inner = (void*)(network & (~1));
14022         network_conv.is_owned = false;
14023         LDKPublicKey target_ref;
14024         CHECK(target.len == 33);
14025         memcpy(target_ref.compressed_form, target.ptr, 33);
14026         LDKCVec_ChannelDetailsZ first_hops_constr;
14027         first_hops_constr.datalen = first_hops.len;
14028         if (first_hops_constr.datalen > 0)
14029                 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14030         else
14031                 first_hops_constr.data = NULL;
14032         uint32_t* first_hops_vals = (uint32_t*) first_hops.ptr;
14033         for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14034                 uint32_t arr_conv_16 = first_hops_vals[q];
14035                 LDKChannelDetails arr_conv_16_conv;
14036                 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
14037                 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
14038                 first_hops_constr.data[q] = arr_conv_16_conv;
14039         }
14040         LDKCVec_RouteHintZ last_hops_constr;
14041         last_hops_constr.datalen = last_hops.len;
14042         if (last_hops_constr.datalen > 0)
14043                 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
14044         else
14045                 last_hops_constr.data = NULL;
14046         uint32_t* last_hops_vals = (uint32_t*) last_hops.ptr;
14047         for (size_t l = 0; l < last_hops_constr.datalen; l++) {
14048                 uint32_t arr_conv_11 = last_hops_vals[l];
14049                 LDKRouteHint arr_conv_11_conv;
14050                 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
14051                 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
14052                 if (arr_conv_11_conv.inner != NULL)
14053                         arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
14054                 last_hops_constr.data[l] = arr_conv_11_conv;
14055         }
14056         LDKLogger logger_conv = *(LDKLogger*)logger;
14057         if (logger_conv.free == LDKLogger_JCalls_free) {
14058                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14059                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14060         }
14061         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14062         *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);
14063         FREE(first_hops_constr.data);
14064         return (long)ret_conv;
14065 }
14066
14067 void NetworkGraph_1free(void* ctx_TODO, uint32_t this_ptr) {
14068         LDKNetworkGraph this_ptr_conv;
14069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14070         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14071         NetworkGraph_free(this_ptr_conv);
14072 }
14073
14074 void LockedNetworkGraph_1free(void* ctx_TODO, uint32_t this_ptr) {
14075         LDKLockedNetworkGraph this_ptr_conv;
14076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14077         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14078         LockedNetworkGraph_free(this_ptr_conv);
14079 }
14080
14081 void NetGraphMsgHandler_1free(void* ctx_TODO, uint32_t this_ptr) {
14082         LDKNetGraphMsgHandler this_ptr_conv;
14083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14084         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14085         NetGraphMsgHandler_free(this_ptr_conv);
14086 }
14087
14088 uint32_t NetGraphMsgHandler_1new(void* ctx_TODO, int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
14089         LDKThirtyTwoBytes genesis_hash_ref;
14090         CHECK(genesis_hash.len == 32);
14091         memcpy(genesis_hash_ref.data, genesis_hash.ptr, 32);
14092         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14093         LDKLogger logger_conv = *(LDKLogger*)logger;
14094         if (logger_conv.free == LDKLogger_JCalls_free) {
14095                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14096                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14097         }
14098         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv, logger_conv);
14099         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14100         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14101         long ret_ref = (long)ret_var.inner;
14102         if (ret_var.is_owned) {
14103                 ret_ref |= 1;
14104         }
14105         return ret_ref;
14106 }
14107
14108 uint32_t NetGraphMsgHandler_1from_1net_1graph(void* ctx_TODO, uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
14109         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14110         LDKLogger logger_conv = *(LDKLogger*)logger;
14111         if (logger_conv.free == LDKLogger_JCalls_free) {
14112                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14113                 LDKLogger_JCalls_clone(logger_conv.this_arg);
14114         }
14115         LDKNetworkGraph network_graph_conv;
14116         network_graph_conv.inner = (void*)(network_graph & (~1));
14117         network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
14118         // Warning: we may need a move here but can't clone!
14119         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
14120         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14121         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14122         long ret_ref = (long)ret_var.inner;
14123         if (ret_var.is_owned) {
14124                 ret_ref |= 1;
14125         }
14126         return ret_ref;
14127 }
14128
14129 uint32_t NetGraphMsgHandler_1read_1locked_1graph(void* ctx_TODO, uint32_t this_arg) {
14130         LDKNetGraphMsgHandler this_arg_conv;
14131         this_arg_conv.inner = (void*)(this_arg & (~1));
14132         this_arg_conv.is_owned = false;
14133         LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
14134         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14135         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14136         long ret_ref = (long)ret_var.inner;
14137         if (ret_var.is_owned) {
14138                 ret_ref |= 1;
14139         }
14140         return ret_ref;
14141 }
14142
14143 uint32_t LockedNetworkGraph_1graph(void* ctx_TODO, uint32_t this_arg) {
14144         LDKLockedNetworkGraph this_arg_conv;
14145         this_arg_conv.inner = (void*)(this_arg & (~1));
14146         this_arg_conv.is_owned = false;
14147         LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
14148         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14149         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14150         long ret_ref = (long)ret_var.inner;
14151         if (ret_var.is_owned) {
14152                 ret_ref |= 1;
14153         }
14154         return ret_ref;
14155 }
14156
14157 uint32_t NetGraphMsgHandler_1as_1RoutingMessageHandler(void* ctx_TODO, uint32_t this_arg) {
14158         LDKNetGraphMsgHandler this_arg_conv;
14159         this_arg_conv.inner = (void*)(this_arg & (~1));
14160         this_arg_conv.is_owned = false;
14161         LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
14162         *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
14163         return (long)ret;
14164 }
14165
14166 uint32_t NetGraphMsgHandler_1as_1MessageSendEventsProvider(void* ctx_TODO, uint32_t this_arg) {
14167         LDKNetGraphMsgHandler this_arg_conv;
14168         this_arg_conv.inner = (void*)(this_arg & (~1));
14169         this_arg_conv.is_owned = false;
14170         LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
14171         *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
14172         return (long)ret;
14173 }
14174
14175 void DirectionalChannelInfo_1free(void* ctx_TODO, uint32_t this_ptr) {
14176         LDKDirectionalChannelInfo this_ptr_conv;
14177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14178         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14179         DirectionalChannelInfo_free(this_ptr_conv);
14180 }
14181
14182 int32_t DirectionalChannelInfo_1get_1last_1update(void* ctx_TODO, uint32_t this_ptr) {
14183         LDKDirectionalChannelInfo this_ptr_conv;
14184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14185         this_ptr_conv.is_owned = false;
14186         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
14187         return ret_val;
14188 }
14189
14190 void DirectionalChannelInfo_1set_1last_1update(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
14191         LDKDirectionalChannelInfo this_ptr_conv;
14192         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14193         this_ptr_conv.is_owned = false;
14194         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
14195 }
14196
14197 jboolean DirectionalChannelInfo_1get_1enabled(void* ctx_TODO, uint32_t this_ptr) {
14198         LDKDirectionalChannelInfo this_ptr_conv;
14199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14200         this_ptr_conv.is_owned = false;
14201         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
14202         return ret_val;
14203 }
14204
14205 void DirectionalChannelInfo_1set_1enabled(void* ctx_TODO, uint32_t this_ptr, jboolean val) {
14206         LDKDirectionalChannelInfo this_ptr_conv;
14207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14208         this_ptr_conv.is_owned = false;
14209         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
14210 }
14211
14212 jshort DirectionalChannelInfo_1get_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr) {
14213         LDKDirectionalChannelInfo this_ptr_conv;
14214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14215         this_ptr_conv.is_owned = false;
14216         jshort ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
14217         return ret_val;
14218 }
14219
14220 void DirectionalChannelInfo_1set_1cltv_1expiry_1delta(void* ctx_TODO, uint32_t this_ptr, jshort val) {
14221         LDKDirectionalChannelInfo this_ptr_conv;
14222         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14223         this_ptr_conv.is_owned = false;
14224         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
14225 }
14226
14227 int64_t DirectionalChannelInfo_1get_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr) {
14228         LDKDirectionalChannelInfo this_ptr_conv;
14229         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14230         this_ptr_conv.is_owned = false;
14231         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
14232         return ret_val;
14233 }
14234
14235 void DirectionalChannelInfo_1set_1htlc_1minimum_1msat(void* ctx_TODO, uint32_t this_ptr, int64_t val) {
14236         LDKDirectionalChannelInfo this_ptr_conv;
14237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14238         this_ptr_conv.is_owned = false;
14239         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
14240 }
14241
14242 uint32_t DirectionalChannelInfo_1get_1fees(void* ctx_TODO, uint32_t this_ptr) {
14243         LDKDirectionalChannelInfo this_ptr_conv;
14244         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14245         this_ptr_conv.is_owned = false;
14246         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
14247         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14248         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14249         long ret_ref = (long)ret_var.inner;
14250         if (ret_var.is_owned) {
14251                 ret_ref |= 1;
14252         }
14253         return ret_ref;
14254 }
14255
14256 void DirectionalChannelInfo_1set_1fees(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14257         LDKDirectionalChannelInfo this_ptr_conv;
14258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14259         this_ptr_conv.is_owned = false;
14260         LDKRoutingFees val_conv;
14261         val_conv.inner = (void*)(val & (~1));
14262         val_conv.is_owned = (val & 1) || (val == 0);
14263         if (val_conv.inner != NULL)
14264                 val_conv = RoutingFees_clone(&val_conv);
14265         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
14266 }
14267
14268 uint32_t DirectionalChannelInfo_1get_1last_1update_1message(void* ctx_TODO, uint32_t this_ptr) {
14269         LDKDirectionalChannelInfo this_ptr_conv;
14270         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14271         this_ptr_conv.is_owned = false;
14272         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
14273         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14274         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14275         long ret_ref = (long)ret_var.inner;
14276         if (ret_var.is_owned) {
14277                 ret_ref |= 1;
14278         }
14279         return ret_ref;
14280 }
14281
14282 void DirectionalChannelInfo_1set_1last_1update_1message(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14283         LDKDirectionalChannelInfo this_ptr_conv;
14284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14285         this_ptr_conv.is_owned = false;
14286         LDKChannelUpdate val_conv;
14287         val_conv.inner = (void*)(val & (~1));
14288         val_conv.is_owned = (val & 1) || (val == 0);
14289         if (val_conv.inner != NULL)
14290                 val_conv = ChannelUpdate_clone(&val_conv);
14291         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
14292 }
14293
14294 int8_tArray DirectionalChannelInfo_1write(void* ctx_TODO, uint32_t obj) {
14295         LDKDirectionalChannelInfo obj_conv;
14296         obj_conv.inner = (void*)(obj & (~1));
14297         obj_conv.is_owned = false;
14298         LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
14299         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14300         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14301         CVec_u8Z_free(arg_var);
14302         return arg_arr;
14303 }
14304
14305 uint32_t DirectionalChannelInfo_1read(void* ctx_TODO, int8_tArray ser) {
14306         LDKu8slice ser_ref;
14307         ser_ref.datalen = ser.len;
14308         ser_ref.data = ser.ptr;
14309         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_read(ser_ref);
14310         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14311         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14312         long ret_ref = (long)ret_var.inner;
14313         if (ret_var.is_owned) {
14314                 ret_ref |= 1;
14315         }
14316         return ret_ref;
14317 }
14318
14319 void ChannelInfo_1free(void* ctx_TODO, uint32_t this_ptr) {
14320         LDKChannelInfo this_ptr_conv;
14321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14322         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14323         ChannelInfo_free(this_ptr_conv);
14324 }
14325
14326 uint32_t ChannelInfo_1get_1features(void* ctx_TODO, uint32_t this_ptr) {
14327         LDKChannelInfo this_ptr_conv;
14328         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14329         this_ptr_conv.is_owned = false;
14330         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
14331         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14332         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14333         long ret_ref = (long)ret_var.inner;
14334         if (ret_var.is_owned) {
14335                 ret_ref |= 1;
14336         }
14337         return ret_ref;
14338 }
14339
14340 void ChannelInfo_1set_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14341         LDKChannelInfo this_ptr_conv;
14342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14343         this_ptr_conv.is_owned = false;
14344         LDKChannelFeatures val_conv;
14345         val_conv.inner = (void*)(val & (~1));
14346         val_conv.is_owned = (val & 1) || (val == 0);
14347         // Warning: we may need a move here but can't clone!
14348         ChannelInfo_set_features(&this_ptr_conv, val_conv);
14349 }
14350
14351 int8_tArray ChannelInfo_1get_1node_1one(void* ctx_TODO, uint32_t this_ptr) {
14352         LDKChannelInfo this_ptr_conv;
14353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14354         this_ptr_conv.is_owned = false;
14355         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
14356         memcpy(arg_arr.ptr, ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
14357         return arg_arr;
14358 }
14359
14360 void ChannelInfo_1set_1node_1one(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
14361         LDKChannelInfo this_ptr_conv;
14362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14363         this_ptr_conv.is_owned = false;
14364         LDKPublicKey val_ref;
14365         CHECK(val.len == 33);
14366         memcpy(val_ref.compressed_form, val.ptr, 33);
14367         ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
14368 }
14369
14370 uint32_t ChannelInfo_1get_1one_1to_1two(void* ctx_TODO, uint32_t this_ptr) {
14371         LDKChannelInfo this_ptr_conv;
14372         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14373         this_ptr_conv.is_owned = false;
14374         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
14375         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14376         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14377         long ret_ref = (long)ret_var.inner;
14378         if (ret_var.is_owned) {
14379                 ret_ref |= 1;
14380         }
14381         return ret_ref;
14382 }
14383
14384 void ChannelInfo_1set_1one_1to_1two(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14385         LDKChannelInfo this_ptr_conv;
14386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14387         this_ptr_conv.is_owned = false;
14388         LDKDirectionalChannelInfo val_conv;
14389         val_conv.inner = (void*)(val & (~1));
14390         val_conv.is_owned = (val & 1) || (val == 0);
14391         // Warning: we may need a move here but can't clone!
14392         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
14393 }
14394
14395 int8_tArray ChannelInfo_1get_1node_1two(void* ctx_TODO, uint32_t this_ptr) {
14396         LDKChannelInfo this_ptr_conv;
14397         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14398         this_ptr_conv.is_owned = false;
14399         int8_tArray arg_arr = { .len = 33, .ptr = MALLOC(33, "Native int8_tArray Bytes") };
14400         memcpy(arg_arr.ptr, ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
14401         return arg_arr;
14402 }
14403
14404 void ChannelInfo_1set_1node_1two(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
14405         LDKChannelInfo this_ptr_conv;
14406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14407         this_ptr_conv.is_owned = false;
14408         LDKPublicKey val_ref;
14409         CHECK(val.len == 33);
14410         memcpy(val_ref.compressed_form, val.ptr, 33);
14411         ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
14412 }
14413
14414 uint32_t ChannelInfo_1get_1two_1to_1one(void* ctx_TODO, uint32_t this_ptr) {
14415         LDKChannelInfo this_ptr_conv;
14416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14417         this_ptr_conv.is_owned = false;
14418         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
14419         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14420         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14421         long ret_ref = (long)ret_var.inner;
14422         if (ret_var.is_owned) {
14423                 ret_ref |= 1;
14424         }
14425         return ret_ref;
14426 }
14427
14428 void ChannelInfo_1set_1two_1to_1one(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14429         LDKChannelInfo this_ptr_conv;
14430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14431         this_ptr_conv.is_owned = false;
14432         LDKDirectionalChannelInfo val_conv;
14433         val_conv.inner = (void*)(val & (~1));
14434         val_conv.is_owned = (val & 1) || (val == 0);
14435         // Warning: we may need a move here but can't clone!
14436         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
14437 }
14438
14439 uint32_t ChannelInfo_1get_1announcement_1message(void* ctx_TODO, uint32_t this_ptr) {
14440         LDKChannelInfo this_ptr_conv;
14441         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14442         this_ptr_conv.is_owned = false;
14443         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
14444         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14445         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14446         long ret_ref = (long)ret_var.inner;
14447         if (ret_var.is_owned) {
14448                 ret_ref |= 1;
14449         }
14450         return ret_ref;
14451 }
14452
14453 void ChannelInfo_1set_1announcement_1message(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14454         LDKChannelInfo this_ptr_conv;
14455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14456         this_ptr_conv.is_owned = false;
14457         LDKChannelAnnouncement val_conv;
14458         val_conv.inner = (void*)(val & (~1));
14459         val_conv.is_owned = (val & 1) || (val == 0);
14460         if (val_conv.inner != NULL)
14461                 val_conv = ChannelAnnouncement_clone(&val_conv);
14462         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
14463 }
14464
14465 int8_tArray ChannelInfo_1write(void* ctx_TODO, uint32_t obj) {
14466         LDKChannelInfo obj_conv;
14467         obj_conv.inner = (void*)(obj & (~1));
14468         obj_conv.is_owned = false;
14469         LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
14470         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14471         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14472         CVec_u8Z_free(arg_var);
14473         return arg_arr;
14474 }
14475
14476 uint32_t ChannelInfo_1read(void* ctx_TODO, int8_tArray ser) {
14477         LDKu8slice ser_ref;
14478         ser_ref.datalen = ser.len;
14479         ser_ref.data = ser.ptr;
14480         LDKChannelInfo ret_var = ChannelInfo_read(ser_ref);
14481         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14482         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14483         long ret_ref = (long)ret_var.inner;
14484         if (ret_var.is_owned) {
14485                 ret_ref |= 1;
14486         }
14487         return ret_ref;
14488 }
14489
14490 void RoutingFees_1free(void* ctx_TODO, uint32_t this_ptr) {
14491         LDKRoutingFees this_ptr_conv;
14492         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14493         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14494         RoutingFees_free(this_ptr_conv);
14495 }
14496
14497 uint32_t RoutingFees_1clone(void* ctx_TODO, uint32_t orig) {
14498         LDKRoutingFees orig_conv;
14499         orig_conv.inner = (void*)(orig & (~1));
14500         orig_conv.is_owned = false;
14501         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
14502         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14503         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14504         long ret_ref = (long)ret_var.inner;
14505         if (ret_var.is_owned) {
14506                 ret_ref |= 1;
14507         }
14508         return ret_ref;
14509 }
14510
14511 int32_t RoutingFees_1get_1base_1msat(void* ctx_TODO, uint32_t this_ptr) {
14512         LDKRoutingFees this_ptr_conv;
14513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14514         this_ptr_conv.is_owned = false;
14515         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
14516         return ret_val;
14517 }
14518
14519 void RoutingFees_1set_1base_1msat(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
14520         LDKRoutingFees this_ptr_conv;
14521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14522         this_ptr_conv.is_owned = false;
14523         RoutingFees_set_base_msat(&this_ptr_conv, val);
14524 }
14525
14526 int32_t RoutingFees_1get_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr) {
14527         LDKRoutingFees this_ptr_conv;
14528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14529         this_ptr_conv.is_owned = false;
14530         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
14531         return ret_val;
14532 }
14533
14534 void RoutingFees_1set_1proportional_1millionths(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
14535         LDKRoutingFees this_ptr_conv;
14536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14537         this_ptr_conv.is_owned = false;
14538         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
14539 }
14540
14541 uint32_t RoutingFees_1new(void* ctx_TODO, int32_t base_msat_arg, int32_t proportional_millionths_arg) {
14542         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
14543         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14544         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14545         long ret_ref = (long)ret_var.inner;
14546         if (ret_var.is_owned) {
14547                 ret_ref |= 1;
14548         }
14549         return ret_ref;
14550 }
14551
14552 uint32_t RoutingFees_1read(void* ctx_TODO, int8_tArray ser) {
14553         LDKu8slice ser_ref;
14554         ser_ref.datalen = ser.len;
14555         ser_ref.data = ser.ptr;
14556         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
14557         *ret_conv = RoutingFees_read(ser_ref);
14558         return (long)ret_conv;
14559 }
14560
14561 int8_tArray RoutingFees_1write(void* ctx_TODO, uint32_t obj) {
14562         LDKRoutingFees obj_conv;
14563         obj_conv.inner = (void*)(obj & (~1));
14564         obj_conv.is_owned = false;
14565         LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
14566         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14567         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14568         CVec_u8Z_free(arg_var);
14569         return arg_arr;
14570 }
14571
14572 void NodeAnnouncementInfo_1free(void* ctx_TODO, uint32_t this_ptr) {
14573         LDKNodeAnnouncementInfo this_ptr_conv;
14574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14575         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14576         NodeAnnouncementInfo_free(this_ptr_conv);
14577 }
14578
14579 uint32_t NodeAnnouncementInfo_1get_1features(void* ctx_TODO, uint32_t this_ptr) {
14580         LDKNodeAnnouncementInfo this_ptr_conv;
14581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14582         this_ptr_conv.is_owned = false;
14583         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
14584         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14585         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14586         long ret_ref = (long)ret_var.inner;
14587         if (ret_var.is_owned) {
14588                 ret_ref |= 1;
14589         }
14590         return ret_ref;
14591 }
14592
14593 void NodeAnnouncementInfo_1set_1features(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14594         LDKNodeAnnouncementInfo this_ptr_conv;
14595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14596         this_ptr_conv.is_owned = false;
14597         LDKNodeFeatures val_conv;
14598         val_conv.inner = (void*)(val & (~1));
14599         val_conv.is_owned = (val & 1) || (val == 0);
14600         // Warning: we may need a move here but can't clone!
14601         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
14602 }
14603
14604 int32_t NodeAnnouncementInfo_1get_1last_1update(void* ctx_TODO, uint32_t this_ptr) {
14605         LDKNodeAnnouncementInfo this_ptr_conv;
14606         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14607         this_ptr_conv.is_owned = false;
14608         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
14609         return ret_val;
14610 }
14611
14612 void NodeAnnouncementInfo_1set_1last_1update(void* ctx_TODO, uint32_t this_ptr, int32_t val) {
14613         LDKNodeAnnouncementInfo this_ptr_conv;
14614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14615         this_ptr_conv.is_owned = false;
14616         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
14617 }
14618
14619 int8_tArray NodeAnnouncementInfo_1get_1rgb(void* ctx_TODO, uint32_t this_ptr) {
14620         LDKNodeAnnouncementInfo this_ptr_conv;
14621         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14622         this_ptr_conv.is_owned = false;
14623         int8_tArray ret_arr = { .len = 3, .ptr = MALLOC(3, "Native int8_tArray Bytes") };
14624         memcpy(ret_arr.ptr, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
14625         return ret_arr;
14626 }
14627
14628 void NodeAnnouncementInfo_1set_1rgb(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
14629         LDKNodeAnnouncementInfo this_ptr_conv;
14630         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14631         this_ptr_conv.is_owned = false;
14632         LDKThreeBytes val_ref;
14633         CHECK(val.len == 3);
14634         memcpy(val_ref.data, val.ptr, 3);
14635         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
14636 }
14637
14638 int8_tArray NodeAnnouncementInfo_1get_1alias(void* ctx_TODO, uint32_t this_ptr) {
14639         LDKNodeAnnouncementInfo this_ptr_conv;
14640         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14641         this_ptr_conv.is_owned = false;
14642         int8_tArray ret_arr = { .len = 32, .ptr = MALLOC(32, "Native int8_tArray Bytes") };
14643         memcpy(ret_arr.ptr, *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
14644         return ret_arr;
14645 }
14646
14647 void NodeAnnouncementInfo_1set_1alias(void* ctx_TODO, uint32_t this_ptr, int8_tArray val) {
14648         LDKNodeAnnouncementInfo this_ptr_conv;
14649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14650         this_ptr_conv.is_owned = false;
14651         LDKThirtyTwoBytes val_ref;
14652         CHECK(val.len == 32);
14653         memcpy(val_ref.data, val.ptr, 32);
14654         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
14655 }
14656
14657 void NodeAnnouncementInfo_1set_1addresses(void* ctx_TODO, uint32_t this_ptr, uint32_tArray val) {
14658         LDKNodeAnnouncementInfo this_ptr_conv;
14659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14660         this_ptr_conv.is_owned = false;
14661         LDKCVec_NetAddressZ val_constr;
14662         val_constr.datalen = val.len;
14663         if (val_constr.datalen > 0)
14664                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14665         else
14666                 val_constr.data = NULL;
14667         uint32_t* val_vals = (uint32_t*) val.ptr;
14668         for (size_t m = 0; m < val_constr.datalen; m++) {
14669                 uint32_t arr_conv_12 = val_vals[m];
14670                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
14671                 FREE((void*)arr_conv_12);
14672                 val_constr.data[m] = arr_conv_12_conv;
14673         }
14674         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
14675 }
14676
14677 uint32_t NodeAnnouncementInfo_1get_1announcement_1message(void* ctx_TODO, uint32_t this_ptr) {
14678         LDKNodeAnnouncementInfo this_ptr_conv;
14679         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14680         this_ptr_conv.is_owned = false;
14681         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
14682         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14683         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14684         long ret_ref = (long)ret_var.inner;
14685         if (ret_var.is_owned) {
14686                 ret_ref |= 1;
14687         }
14688         return ret_ref;
14689 }
14690
14691 void NodeAnnouncementInfo_1set_1announcement_1message(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14692         LDKNodeAnnouncementInfo this_ptr_conv;
14693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14694         this_ptr_conv.is_owned = false;
14695         LDKNodeAnnouncement val_conv;
14696         val_conv.inner = (void*)(val & (~1));
14697         val_conv.is_owned = (val & 1) || (val == 0);
14698         if (val_conv.inner != NULL)
14699                 val_conv = NodeAnnouncement_clone(&val_conv);
14700         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
14701 }
14702
14703 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) {
14704         LDKNodeFeatures features_arg_conv;
14705         features_arg_conv.inner = (void*)(features_arg & (~1));
14706         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
14707         // Warning: we may need a move here but can't clone!
14708         LDKThreeBytes rgb_arg_ref;
14709         CHECK(rgb_arg.len == 3);
14710         memcpy(rgb_arg_ref.data, rgb_arg.ptr, 3);
14711         LDKThirtyTwoBytes alias_arg_ref;
14712         CHECK(alias_arg.len == 32);
14713         memcpy(alias_arg_ref.data, alias_arg.ptr, 32);
14714         LDKCVec_NetAddressZ addresses_arg_constr;
14715         addresses_arg_constr.datalen = addresses_arg.len;
14716         if (addresses_arg_constr.datalen > 0)
14717                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14718         else
14719                 addresses_arg_constr.data = NULL;
14720         uint32_t* addresses_arg_vals = (uint32_t*) addresses_arg.ptr;
14721         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
14722                 uint32_t arr_conv_12 = addresses_arg_vals[m];
14723                 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
14724                 FREE((void*)arr_conv_12);
14725                 addresses_arg_constr.data[m] = arr_conv_12_conv;
14726         }
14727         LDKNodeAnnouncement announcement_message_arg_conv;
14728         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
14729         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
14730         if (announcement_message_arg_conv.inner != NULL)
14731                 announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
14732         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
14733         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14734         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14735         long ret_ref = (long)ret_var.inner;
14736         if (ret_var.is_owned) {
14737                 ret_ref |= 1;
14738         }
14739         return ret_ref;
14740 }
14741
14742 int8_tArray NodeAnnouncementInfo_1write(void* ctx_TODO, uint32_t obj) {
14743         LDKNodeAnnouncementInfo obj_conv;
14744         obj_conv.inner = (void*)(obj & (~1));
14745         obj_conv.is_owned = false;
14746         LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
14747         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14748         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14749         CVec_u8Z_free(arg_var);
14750         return arg_arr;
14751 }
14752
14753 uint32_t NodeAnnouncementInfo_1read(void* ctx_TODO, int8_tArray ser) {
14754         LDKu8slice ser_ref;
14755         ser_ref.datalen = ser.len;
14756         ser_ref.data = ser.ptr;
14757         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
14758         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
14759         return (long)ret_conv;
14760 }
14761
14762 void NodeInfo_1free(void* ctx_TODO, uint32_t this_ptr) {
14763         LDKNodeInfo this_ptr_conv;
14764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14765         this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14766         NodeInfo_free(this_ptr_conv);
14767 }
14768
14769 void NodeInfo_1set_1channels(void* ctx_TODO, uint32_t this_ptr, int64_tArray val) {
14770         LDKNodeInfo this_ptr_conv;
14771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14772         this_ptr_conv.is_owned = false;
14773         LDKCVec_u64Z val_constr;
14774         val_constr.datalen = val.len;
14775         if (val_constr.datalen > 0)
14776                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14777         else
14778                 val_constr.data = NULL;
14779         int64_t* val_vals = (int64_t*) val.ptr;
14780         for (size_t g = 0; g < val_constr.datalen; g++) {
14781                 int64_t arr_conv_6 = val_vals[g];
14782                 val_constr.data[g] = arr_conv_6;
14783         }
14784         NodeInfo_set_channels(&this_ptr_conv, val_constr);
14785 }
14786
14787 uint32_t NodeInfo_1get_1lowest_1inbound_1channel_1fees(void* ctx_TODO, uint32_t this_ptr) {
14788         LDKNodeInfo this_ptr_conv;
14789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14790         this_ptr_conv.is_owned = false;
14791         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
14792         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14793         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14794         long ret_ref = (long)ret_var.inner;
14795         if (ret_var.is_owned) {
14796                 ret_ref |= 1;
14797         }
14798         return ret_ref;
14799 }
14800
14801 void NodeInfo_1set_1lowest_1inbound_1channel_1fees(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14802         LDKNodeInfo this_ptr_conv;
14803         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14804         this_ptr_conv.is_owned = false;
14805         LDKRoutingFees val_conv;
14806         val_conv.inner = (void*)(val & (~1));
14807         val_conv.is_owned = (val & 1) || (val == 0);
14808         if (val_conv.inner != NULL)
14809                 val_conv = RoutingFees_clone(&val_conv);
14810         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
14811 }
14812
14813 uint32_t NodeInfo_1get_1announcement_1info(void* ctx_TODO, uint32_t this_ptr) {
14814         LDKNodeInfo this_ptr_conv;
14815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14816         this_ptr_conv.is_owned = false;
14817         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
14818         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14819         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14820         long ret_ref = (long)ret_var.inner;
14821         if (ret_var.is_owned) {
14822                 ret_ref |= 1;
14823         }
14824         return ret_ref;
14825 }
14826
14827 void NodeInfo_1set_1announcement_1info(void* ctx_TODO, uint32_t this_ptr, uint32_t val) {
14828         LDKNodeInfo this_ptr_conv;
14829         this_ptr_conv.inner = (void*)(this_ptr & (~1));
14830         this_ptr_conv.is_owned = false;
14831         LDKNodeAnnouncementInfo val_conv;
14832         val_conv.inner = (void*)(val & (~1));
14833         val_conv.is_owned = (val & 1) || (val == 0);
14834         // Warning: we may need a move here but can't clone!
14835         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
14836 }
14837
14838 uint32_t NodeInfo_1new(void* ctx_TODO, int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
14839         LDKCVec_u64Z channels_arg_constr;
14840         channels_arg_constr.datalen = channels_arg.len;
14841         if (channels_arg_constr.datalen > 0)
14842                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
14843         else
14844                 channels_arg_constr.data = NULL;
14845         int64_t* channels_arg_vals = (int64_t*) channels_arg.ptr;
14846         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
14847                 int64_t arr_conv_6 = channels_arg_vals[g];
14848                 channels_arg_constr.data[g] = arr_conv_6;
14849         }
14850         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
14851         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
14852         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
14853         if (lowest_inbound_channel_fees_arg_conv.inner != NULL)
14854                 lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
14855         LDKNodeAnnouncementInfo announcement_info_arg_conv;
14856         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
14857         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
14858         // Warning: we may need a move here but can't clone!
14859         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
14860         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14861         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14862         long ret_ref = (long)ret_var.inner;
14863         if (ret_var.is_owned) {
14864                 ret_ref |= 1;
14865         }
14866         return ret_ref;
14867 }
14868
14869 int8_tArray NodeInfo_1write(void* ctx_TODO, uint32_t obj) {
14870         LDKNodeInfo obj_conv;
14871         obj_conv.inner = (void*)(obj & (~1));
14872         obj_conv.is_owned = false;
14873         LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
14874         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14875         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14876         CVec_u8Z_free(arg_var);
14877         return arg_arr;
14878 }
14879
14880 uint32_t NodeInfo_1read(void* ctx_TODO, int8_tArray ser) {
14881         LDKu8slice ser_ref;
14882         ser_ref.datalen = ser.len;
14883         ser_ref.data = ser.ptr;
14884         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
14885         *ret_conv = NodeInfo_read(ser_ref);
14886         return (long)ret_conv;
14887 }
14888
14889 int8_tArray NetworkGraph_1write(void* ctx_TODO, uint32_t obj) {
14890         LDKNetworkGraph obj_conv;
14891         obj_conv.inner = (void*)(obj & (~1));
14892         obj_conv.is_owned = false;
14893         LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
14894         int8_tArray arg_arr = { .len = arg_var.datalen, .ptr = MALLOC(arg_var.datalen, "Native int8_tArray Bytes") };
14895         memcpy(arg_arr.ptr, arg_var.data, arg_var.datalen);
14896         CVec_u8Z_free(arg_var);
14897         return arg_arr;
14898 }
14899
14900 uint32_t NetworkGraph_1read(void* ctx_TODO, int8_tArray ser) {
14901         LDKu8slice ser_ref;
14902         ser_ref.datalen = ser.len;
14903         ser_ref.data = ser.ptr;
14904         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
14905         *ret_conv = NetworkGraph_read(ser_ref);
14906         return (long)ret_conv;
14907 }
14908
14909 uint32_t NetworkGraph_1new(void* ctx_TODO, int8_tArray genesis_hash) {
14910         LDKThirtyTwoBytes genesis_hash_ref;
14911         CHECK(genesis_hash.len == 32);
14912         memcpy(genesis_hash_ref.data, genesis_hash.ptr, 32);
14913         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
14914         CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14915         CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14916         long ret_ref = (long)ret_var.inner;
14917         if (ret_var.is_owned) {
14918                 ret_ref |= 1;
14919         }
14920         return ret_ref;
14921 }
14922
14923 uint32_t NetworkGraph_1update_1node_1from_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
14924         LDKNetworkGraph this_arg_conv;
14925         this_arg_conv.inner = (void*)(this_arg & (~1));
14926         this_arg_conv.is_owned = false;
14927         LDKNodeAnnouncement msg_conv;
14928         msg_conv.inner = (void*)(msg & (~1));
14929         msg_conv.is_owned = false;
14930         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14931         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
14932         return (long)ret_conv;
14933 }
14934
14935 uint32_t NetworkGraph_1update_1node_1from_1unsigned_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
14936         LDKNetworkGraph this_arg_conv;
14937         this_arg_conv.inner = (void*)(this_arg & (~1));
14938         this_arg_conv.is_owned = false;
14939         LDKUnsignedNodeAnnouncement msg_conv;
14940         msg_conv.inner = (void*)(msg & (~1));
14941         msg_conv.is_owned = false;
14942         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14943         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
14944         return (long)ret_conv;
14945 }
14946
14947 uint32_t NetworkGraph_1update_1channel_1from_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
14948         LDKNetworkGraph this_arg_conv;
14949         this_arg_conv.inner = (void*)(this_arg & (~1));
14950         this_arg_conv.is_owned = false;
14951         LDKChannelAnnouncement msg_conv;
14952         msg_conv.inner = (void*)(msg & (~1));
14953         msg_conv.is_owned = false;
14954         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14955         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14956         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
14957         return (long)ret_conv;
14958 }
14959
14960 uint32_t NetworkGraph_1update_1channel_1from_1unsigned_1announcement(void* ctx_TODO, uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
14961         LDKNetworkGraph this_arg_conv;
14962         this_arg_conv.inner = (void*)(this_arg & (~1));
14963         this_arg_conv.is_owned = false;
14964         LDKUnsignedChannelAnnouncement msg_conv;
14965         msg_conv.inner = (void*)(msg & (~1));
14966         msg_conv.is_owned = false;
14967         LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14968         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14969         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
14970         return (long)ret_conv;
14971 }
14972
14973 void NetworkGraph_1close_1channel_1from_1update(void* ctx_TODO, uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
14974         LDKNetworkGraph this_arg_conv;
14975         this_arg_conv.inner = (void*)(this_arg & (~1));
14976         this_arg_conv.is_owned = false;
14977         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
14978 }
14979
14980 uint32_t NetworkGraph_1update_1channel(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
14981         LDKNetworkGraph this_arg_conv;
14982         this_arg_conv.inner = (void*)(this_arg & (~1));
14983         this_arg_conv.is_owned = false;
14984         LDKChannelUpdate msg_conv;
14985         msg_conv.inner = (void*)(msg & (~1));
14986         msg_conv.is_owned = false;
14987         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14988         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
14989         return (long)ret_conv;
14990 }
14991
14992 uint32_t NetworkGraph_1update_1channel_1unsigned(void* ctx_TODO, uint32_t this_arg, uint32_t msg) {
14993         LDKNetworkGraph this_arg_conv;
14994         this_arg_conv.inner = (void*)(this_arg & (~1));
14995         this_arg_conv.is_owned = false;
14996         LDKUnsignedChannelUpdate msg_conv;
14997         msg_conv.inner = (void*)(msg & (~1));
14998         msg_conv.is_owned = false;
14999         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15000         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
15001         return (long)ret_conv;
15002 }
15003