1 #include <rust_types.h>
6 // These should be provided...somehow...
7 void *memset(void *s, int c, size_t n);
8 void *memcpy(void *dest, const void *src, size_t n);
9 int memcmp(const void *s1, const void *s2, size_t n);
11 void __attribute__((noreturn)) abort(void);
12 static inline void assert(bool expression) {
13 if (!expression) { abort(); }
16 // Always run a, then assert it is true:
17 #define DO_ASSERT(a) do { bool _assert_val = (a); assert(_assert_val); } while(0)
18 // Assert a is true or do nothing
19 #define CHECK(a) DO_ASSERT(a)
21 // Running a leak check across all the allocations and frees of the JDK is a mess,
22 // so instead we implement our own naive leak checker here, relying on the -wrap
23 // linker option to wrap malloc/calloc/realloc/free, tracking everyhing allocated
24 // and free'd in Rust or C across the generated bindings shared library.
27 typedef struct allocation {
28 struct allocation* next;
30 const char* struct_name;
32 static allocation* allocation_ll = NULL;
34 void* __real_malloc(size_t len);
35 void* __real_calloc(size_t nmemb, size_t len);
36 static void new_allocation(void* res, const char* struct_name) {
37 allocation* new_alloc = __real_malloc(sizeof(allocation));
39 new_alloc->struct_name = struct_name;
40 new_alloc->next = allocation_ll;
41 allocation_ll = new_alloc;
43 static void* MALLOC(size_t len, const char* struct_name) {
44 void* res = __real_malloc(len);
45 new_allocation(res, struct_name);
48 void __real_free(void* ptr);
49 static void alloc_freed(void* ptr) {
51 allocation* it = allocation_ll;
52 while (it->ptr != ptr) {
53 p = it; it = it->next;
55 //XXX: fprintf(stderr, "Tried to free unknown pointer %p\n", ptr);
56 return; // addrsan should catch malloc-unknown and print more info than we have
59 if (p) { p->next = it->next; } else { allocation_ll = it->next; }
60 DO_ASSERT(it->ptr == ptr);
63 static void FREE(void* ptr) {
64 if ((long)ptr < 1024) return; // Rust loves to create pointers to the NULL page for dummys
69 void* __wrap_malloc(size_t len) {
70 void* res = __real_malloc(len);
71 new_allocation(res, "malloc call");
74 void* __wrap_calloc(size_t nmemb, size_t len) {
75 void* res = __real_calloc(nmemb, len);
76 new_allocation(res, "calloc call");
79 void __wrap_free(void* ptr) {
80 if (ptr == NULL) return;
85 void* __real_realloc(void* ptr, size_t newlen);
86 void* __wrap_realloc(void* ptr, size_t len) {
87 if (ptr != NULL) alloc_freed(ptr);
88 void* res = __real_realloc(ptr, len);
89 new_allocation(res, "realloc call");
92 void __wrap_reallocarray(void* ptr, size_t new_sz) {
93 // Rust doesn't seem to use reallocarray currently
97 void __attribute__((destructor)) check_leaks() {
98 for (allocation* a = allocation_ll; a != NULL; a = a->next) {
99 //XXX: fprintf(stderr, "%s %p remains\n", a->struct_name, a->ptr);
101 DO_ASSERT(allocation_ll == NULL);
104 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
105 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
106 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
107 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
109 _Static_assert(sizeof(void*) == 4, "Pointers mut be 32 bits");
111 //typedef struct int64_tArray { uint32_t *len; /* len + 1 is data */ } int64_tArray;
112 //typedef struct uint32_tArray { uint32_t *len; /* len + 1 is data */ } uint32_tArray;
113 //typedef struct ptrArray { uint32_t *len; /* len + 1 is data */ } ptrArray;
114 //typedef struct int8_tArray { uint32_t *len; /* len + 1 is data */ } int8_tArray;
115 typedef uint32_t int64_tArray;
116 typedef uint32_t int8_tArray;
117 typedef uint32_t uint32_tArray;
118 typedef uint32_t ptrArray;
119 typedef uint32_t jstring;
121 static inline uint32_t init_arr(size_t arr_len, size_t elem_size, const char *type_desc) {
122 uint32_t *elems = (uint32_t*)MALLOC(arr_len * elem_size + 4, type_desc);
124 return (uint32_t)elems;
127 jstring str_ref_to_ts(const char* chars, size_t len) {
128 char* err_buf = MALLOC(len + 4, "str conv buf");
129 *((uint32_t*)err_buf) = len;
130 memcpy(err_buf + 4, chars, len);
131 return (uint32_t) err_buf;
134 typedef bool jboolean;
136 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
137 static inline LDKAccessError LDKAccessError_from_js(int32_t ord) {
139 case 0: return LDKAccessError_UnknownChain;
140 case 1: return LDKAccessError_UnknownTx;
144 static inline int32_t LDKAccessError_to_js(LDKAccessError val) {
146 case LDKAccessError_UnknownChain: return 0;
147 case LDKAccessError_UnknownTx: return 1;
151 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_js(int32_t ord) {
153 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
154 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
158 static inline int32_t LDKChannelMonitorUpdateErr_to_js(LDKChannelMonitorUpdateErr val) {
160 case LDKChannelMonitorUpdateErr_TemporaryFailure: return 0;
161 case LDKChannelMonitorUpdateErr_PermanentFailure: return 1;
165 static inline LDKConfirmationTarget LDKConfirmationTarget_from_js(int32_t ord) {
167 case 0: return LDKConfirmationTarget_Background;
168 case 1: return LDKConfirmationTarget_Normal;
169 case 2: return LDKConfirmationTarget_HighPriority;
173 static inline int32_t LDKConfirmationTarget_to_js(LDKConfirmationTarget val) {
175 case LDKConfirmationTarget_Background: return 0;
176 case LDKConfirmationTarget_Normal: return 1;
177 case LDKConfirmationTarget_HighPriority: return 2;
181 static inline LDKLevel LDKLevel_from_js(int32_t ord) {
183 case 0: return LDKLevel_Off;
184 case 1: return LDKLevel_Error;
185 case 2: return LDKLevel_Warn;
186 case 3: return LDKLevel_Info;
187 case 4: return LDKLevel_Debug;
188 case 5: return LDKLevel_Trace;
192 static inline int32_t LDKLevel_to_js(LDKLevel val) {
194 case LDKLevel_Off: return 0;
195 case LDKLevel_Error: return 1;
196 case LDKLevel_Warn: return 2;
197 case LDKLevel_Info: return 3;
198 case LDKLevel_Debug: return 4;
199 case LDKLevel_Trace: return 5;
203 static inline LDKNetwork LDKNetwork_from_js(int32_t ord) {
205 case 0: return LDKNetwork_Bitcoin;
206 case 1: return LDKNetwork_Testnet;
207 case 2: return LDKNetwork_Regtest;
211 static inline int32_t LDKNetwork_to_js(LDKNetwork val) {
213 case LDKNetwork_Bitcoin: return 0;
214 case LDKNetwork_Testnet: return 1;
215 case LDKNetwork_Regtest: return 2;
219 static inline LDKSecp256k1Error LDKSecp256k1Error_from_js(int32_t ord) {
221 case 0: return LDKSecp256k1Error_IncorrectSignature;
222 case 1: return LDKSecp256k1Error_InvalidMessage;
223 case 2: return LDKSecp256k1Error_InvalidPublicKey;
224 case 3: return LDKSecp256k1Error_InvalidSignature;
225 case 4: return LDKSecp256k1Error_InvalidSecretKey;
226 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
227 case 6: return LDKSecp256k1Error_InvalidTweak;
228 case 7: return LDKSecp256k1Error_TweakCheckFailed;
229 case 8: return LDKSecp256k1Error_NotEnoughMemory;
233 static inline int32_t LDKSecp256k1Error_to_js(LDKSecp256k1Error val) {
235 case LDKSecp256k1Error_IncorrectSignature: return 0;
236 case LDKSecp256k1Error_InvalidMessage: return 1;
237 case LDKSecp256k1Error_InvalidPublicKey: return 2;
238 case LDKSecp256k1Error_InvalidSignature: return 3;
239 case LDKSecp256k1Error_InvalidSecretKey: return 4;
240 case LDKSecp256k1Error_InvalidRecoveryId: return 5;
241 case LDKSecp256k1Error_InvalidTweak: return 6;
242 case LDKSecp256k1Error_TweakCheckFailed: return 7;
243 case LDKSecp256k1Error_NotEnoughMemory: return 8;
247 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_u8Z_new(int8_tArray elems) {
248 LDKCVec_u8Z *ret = MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8Z");
249 ret->datalen = *((uint32_t*)elems);
250 if (ret->datalen == 0) {
253 ret->data = MALLOC(sizeof(uint8_t) * ret->datalen, "LDKCVec_u8Z Data");
254 int8_t *java_elems = (int8_t*)(elems + 4);
255 for (size_t i = 0; i < ret->datalen; i++) {
256 ret->data[i] = java_elems[i];
261 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
262 LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
263 memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
266 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_new(int64_t a, int64_t b) {
267 LDKC2Tuple_u64u64Z* ret = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
272 static inline LDKC2Tuple_u64u64Z C2Tuple_u64u64Z_clone(const LDKC2Tuple_u64u64Z *orig) {
273 LDKC2Tuple_u64u64Z ret = {
279 int64_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_get_a(uint32_t ptr) {
280 LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)ptr;
283 int64_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u64u64Z_get_b(uint32_t ptr) {
284 LDKC2Tuple_u64u64Z *tuple = (LDKC2Tuple_u64u64Z*)ptr;
287 uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
288 LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
290 case LDKSpendableOutputDescriptor_StaticOutput: {
291 LDKOutPoint outpoint_var = obj->static_output.outpoint;
292 CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
293 CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
294 long outpoint_ref = (long)outpoint_var.inner & ~1;
295 long output_ref = (long)&obj->static_output.output;
296 return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
298 case LDKSpendableOutputDescriptor_DynamicOutputP2WSH: {
299 LDKOutPoint outpoint_var = obj->dynamic_output_p2wsh.outpoint;
300 CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
301 CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
302 long outpoint_ref = (long)outpoint_var.inner & ~1;
303 int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
304 memcpy((uint8_t*)(per_commitment_point_arr + 4), obj->dynamic_output_p2wsh.per_commitment_point.compressed_form, 33);
305 long output_ref = (long)&obj->dynamic_output_p2wsh.output;
306 long key_derivation_params_ref = (long)&obj->dynamic_output_p2wsh.key_derivation_params;
307 int8_tArray revocation_pubkey_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
308 memcpy((uint8_t*)(revocation_pubkey_arr + 4), obj->dynamic_output_p2wsh.revocation_pubkey.compressed_form, 33);
309 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;
311 case LDKSpendableOutputDescriptor_StaticOutputCounterpartyPayment: {
312 LDKOutPoint outpoint_var = obj->static_output_counterparty_payment.outpoint;
313 CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
314 CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
315 long outpoint_ref = (long)outpoint_var.inner & ~1;
316 long output_ref = (long)&obj->static_output_counterparty_payment.output;
317 long key_derivation_params_ref = (long)&obj->static_output_counterparty_payment.key_derivation_params;
318 return 0 /* LDKSpendableOutputDescriptor - StaticOutputCounterpartyPayment */; (void) outpoint_ref; (void) (long)output_ref; (void) key_derivation_params_ref;
323 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
324 LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
325 ret->datalen = *((uint32_t*)elems);
326 if (ret->datalen == 0) {
329 ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
330 uint32_t *java_elems = (uint32_t*)(elems + 4);
331 for (size_t i = 0; i < ret->datalen; i++) {
332 uint32_t arr_elem = java_elems[i];
333 LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)arr_elem;
334 FREE((void*)arr_elem);
335 ret->data[i] = arr_elem_conv;
340 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
341 LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
342 for (size_t i = 0; i < ret.datalen; i++) {
343 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
347 uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
348 LDKErrorAction *obj = (LDKErrorAction*)ptr;
350 case LDKErrorAction_DisconnectPeer: {
351 LDKErrorMessage msg_var = obj->disconnect_peer.msg;
352 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
353 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
354 long msg_ref = (long)msg_var.inner & ~1;
355 return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
357 case LDKErrorAction_IgnoreError: {
358 return 0 /* LDKErrorAction - IgnoreError */;
360 case LDKErrorAction_SendErrorMessage: {
361 LDKErrorMessage msg_var = obj->send_error_message.msg;
362 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
363 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
364 long msg_ref = (long)msg_var.inner & ~1;
365 return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
370 uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
371 LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
373 case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
374 LDKChannelUpdate msg_var = obj->channel_update_message.msg;
375 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
376 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
377 long msg_ref = (long)msg_var.inner & ~1;
378 return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
380 case LDKHTLCFailChannelUpdate_ChannelClosed: {
381 return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
383 case LDKHTLCFailChannelUpdate_NodeFailure: {
384 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
385 memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
386 return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
391 uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
392 LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
394 case LDKMessageSendEvent_SendAcceptChannel: {
395 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
396 memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
397 LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
398 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
399 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
400 long msg_ref = (long)msg_var.inner & ~1;
401 return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
403 case LDKMessageSendEvent_SendOpenChannel: {
404 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
405 memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
406 LDKOpenChannel msg_var = obj->send_open_channel.msg;
407 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
408 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
409 long msg_ref = (long)msg_var.inner & ~1;
410 return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
412 case LDKMessageSendEvent_SendFundingCreated: {
413 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
414 memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
415 LDKFundingCreated msg_var = obj->send_funding_created.msg;
416 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
417 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
418 long msg_ref = (long)msg_var.inner & ~1;
419 return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
421 case LDKMessageSendEvent_SendFundingSigned: {
422 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
423 memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
424 LDKFundingSigned msg_var = obj->send_funding_signed.msg;
425 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
426 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
427 long msg_ref = (long)msg_var.inner & ~1;
428 return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
430 case LDKMessageSendEvent_SendFundingLocked: {
431 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
432 memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
433 LDKFundingLocked msg_var = obj->send_funding_locked.msg;
434 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
435 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
436 long msg_ref = (long)msg_var.inner & ~1;
437 return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
439 case LDKMessageSendEvent_SendAnnouncementSignatures: {
440 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
441 memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
442 LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
443 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
444 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
445 long msg_ref = (long)msg_var.inner & ~1;
446 return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
448 case LDKMessageSendEvent_UpdateHTLCs: {
449 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
450 memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
451 LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
452 CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
453 CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
454 long updates_ref = (long)updates_var.inner & ~1;
455 return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
457 case LDKMessageSendEvent_SendRevokeAndACK: {
458 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
459 memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
460 LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
461 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
462 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
463 long msg_ref = (long)msg_var.inner & ~1;
464 return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
466 case LDKMessageSendEvent_SendClosingSigned: {
467 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
468 memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
469 LDKClosingSigned msg_var = obj->send_closing_signed.msg;
470 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
471 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
472 long msg_ref = (long)msg_var.inner & ~1;
473 return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
475 case LDKMessageSendEvent_SendShutdown: {
476 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
477 memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
478 LDKShutdown msg_var = obj->send_shutdown.msg;
479 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
480 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
481 long msg_ref = (long)msg_var.inner & ~1;
482 return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
484 case LDKMessageSendEvent_SendChannelReestablish: {
485 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
486 memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
487 LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
488 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
489 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
490 long msg_ref = (long)msg_var.inner & ~1;
491 return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
493 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
494 LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
495 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
496 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
497 long msg_ref = (long)msg_var.inner & ~1;
498 LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
499 CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
500 CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
501 long update_msg_ref = (long)update_msg_var.inner & ~1;
502 return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
504 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
505 LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
506 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
507 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
508 long msg_ref = (long)msg_var.inner & ~1;
509 return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
511 case LDKMessageSendEvent_BroadcastChannelUpdate: {
512 LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
513 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
514 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
515 long msg_ref = (long)msg_var.inner & ~1;
516 return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
518 case LDKMessageSendEvent_HandleError: {
519 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
520 memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
521 long action_ref = (long)&obj->handle_error.action;
522 return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
524 case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
525 long update_ref = (long)&obj->payment_failure_network_update.update;
526 return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_ref;
528 case LDKMessageSendEvent_SendChannelRangeQuery: {
529 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
530 memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
531 LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
532 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
533 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
534 long msg_ref = (long)msg_var.inner & ~1;
535 return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
537 case LDKMessageSendEvent_SendShortIdsQuery: {
538 int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
539 memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
540 LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
541 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
542 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
543 long msg_ref = (long)msg_var.inner & ~1;
544 return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
549 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
550 LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
551 ret->datalen = *((uint32_t*)elems);
552 if (ret->datalen == 0) {
555 ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
556 uint32_t *java_elems = (uint32_t*)(elems + 4);
557 for (size_t i = 0; i < ret->datalen; i++) {
558 uint32_t arr_elem = java_elems[i];
559 LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)arr_elem;
560 FREE((void*)arr_elem);
561 ret->data[i] = arr_elem_conv;
566 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
567 LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
568 for (size_t i = 0; i < ret.datalen; i++) {
569 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
573 uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
574 LDKEvent *obj = (LDKEvent*)ptr;
576 case LDKEvent_FundingGenerationReady: {
577 int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
578 memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
579 LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
580 int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
581 memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
582 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;
584 case LDKEvent_FundingBroadcastSafe: {
585 LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
586 CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
587 CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
588 long funding_txo_ref = (long)funding_txo_var.inner & ~1;
589 return 0 /* LDKEvent - FundingBroadcastSafe */; (void) funding_txo_ref; (void) obj->funding_broadcast_safe.user_channel_id;
591 case LDKEvent_PaymentReceived: {
592 int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
593 memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
594 int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
595 memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
596 return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
598 case LDKEvent_PaymentSent: {
599 int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
600 memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
601 return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
603 case LDKEvent_PaymentFailed: {
604 int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
605 memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
606 return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
608 case LDKEvent_PendingHTLCsForwardable: {
609 return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
611 case LDKEvent_SpendableOutputs: {
612 LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
613 uint32_tArray outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
614 uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
615 for (size_t b = 0; b < outputs_var.datalen; b++) {
616 long arr_conv_27_ref = (long)&outputs_var.data[b];
617 outputs_arr_ptr[b] = arr_conv_27_ref;
619 return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
624 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
625 LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
626 ret->datalen = *((uint32_t*)elems);
627 if (ret->datalen == 0) {
630 ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
631 uint32_t *java_elems = (uint32_t*)(elems + 4);
632 for (size_t i = 0; i < ret->datalen; i++) {
633 uint32_t arr_elem = java_elems[i];
634 LDKEvent arr_elem_conv = *(LDKEvent*)arr_elem;
635 FREE((void*)arr_elem);
636 ret->data[i] = arr_elem_conv;
641 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
642 LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
643 for (size_t i = 0; i < ret.datalen; i++) {
644 ret.data[i] = Event_clone(&orig->data[i]);
648 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(intptr_t a, int8_tArray b) {
649 LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
651 LDKTransaction b_ref;
652 b_ref.datalen = *((uint32_t*)b);
653 b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
654 memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
655 b_ref.data_is_owned = false;
659 intptr_t __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
660 LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)ptr;
663 int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
664 LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)ptr;
665 LDKTransaction b_var = tuple->b;
666 int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
667 memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
670 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
671 LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
672 ret->datalen = *((uint32_t*)elems);
673 if (ret->datalen == 0) {
676 ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ Data");
677 uint32_t *java_elems = (uint32_t*)(elems + 4);
678 for (size_t i = 0; i < ret->datalen; i++) {
679 uint32_t arr_elem = java_elems[i];
680 LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_elem;
681 FREE((void*)arr_elem);
682 ret->data[i] = arr_elem_conv;
687 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
688 return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
690 void __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
691 LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
692 CHECK(val->result_ok);
693 return *val->contents.result;
695 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
696 LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)arg;
697 CHECK(!val->result_ok);
698 uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
701 static inline LDKCResult_NoneChannelMonitorUpdateErrZ CResult_NoneChannelMonitorUpdateErrZ_clone(const LDKCResult_NoneChannelMonitorUpdateErrZ *orig) {
702 LDKCResult_NoneChannelMonitorUpdateErrZ res = { .result_ok = orig->result_ok };
703 if (orig->result_ok) {
704 res.contents.result = NULL;
706 LDKChannelMonitorUpdateErr* contents = MALLOC(sizeof(LDKChannelMonitorUpdateErr), "LDKChannelMonitorUpdateErr result Err clone");
707 *contents = ChannelMonitorUpdateErr_clone(orig->contents.err);
708 res.contents.err = contents;
712 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
713 LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
714 ret->datalen = *((uint32_t*)elems);
715 if (ret->datalen == 0) {
718 ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ Data");
719 uint32_t *java_elems = (uint32_t*)(elems + 4);
720 for (size_t i = 0; i < ret->datalen; i++) {
721 uint32_t arr_elem = java_elems[i];
722 LDKMonitorEvent arr_elem_conv;
723 arr_elem_conv.inner = (void*)(arr_elem & (~1));
724 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
725 if (arr_elem_conv.inner != NULL)
726 arr_elem_conv = MonitorEvent_clone(&arr_elem_conv);
727 ret->data[i] = arr_elem_conv;
732 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
733 LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
734 for (size_t i = 0; i < ret.datalen; i++) {
735 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
739 jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
740 return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
742 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
743 LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg;
744 CHECK(val->result_ok);
745 LDKChannelMonitorUpdate res_var = (*val->contents.result);
746 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
747 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
748 long res_ref = (long)res_var.inner & ~1;
751 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
752 LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg;
753 CHECK(!val->result_ok);
754 LDKDecodeError err_var = (*val->contents.err);
755 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
756 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
757 long err_ref = (long)err_var.inner & ~1;
760 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
761 return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
763 void __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
764 LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
765 CHECK(val->result_ok);
766 return *val->contents.result;
768 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
769 LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)arg;
770 CHECK(!val->result_ok);
771 LDKMonitorUpdateError err_var = (*val->contents.err);
772 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
773 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
774 long err_ref = (long)err_var.inner & ~1;
777 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
778 LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
780 a_conv.inner = (void*)(a & (~1));
781 a_conv.is_owned = (a & 1) || (a == 0);
782 if (a_conv.inner != NULL)
783 a_conv = OutPoint_clone(&a_conv);
786 b_ref.datalen = *((uint32_t*)b);
787 b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
788 memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
792 static inline LDKC2Tuple_OutPointScriptZ C2Tuple_OutPointScriptZ_clone(const LDKC2Tuple_OutPointScriptZ *orig) {
793 LDKC2Tuple_OutPointScriptZ ret = {
794 .a = OutPoint_clone(&orig->a),
795 .b = CVec_u8Z_clone(&orig->b),
799 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
800 LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
801 LDKOutPoint a_var = tuple->a;
802 CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
803 CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
804 long a_ref = (long)a_var.inner & ~1;
807 int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
808 LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)ptr;
809 LDKCVec_u8Z b_var = tuple->b;
810 int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
811 memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
814 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
815 LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
817 LDKTxOut b_conv = *(LDKTxOut*)b;
822 int32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
823 LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
826 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
827 LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)ptr;
828 long b_ref = (long)&tuple->b;
831 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
832 LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
833 ret->datalen = *((uint32_t*)elems);
834 if (ret->datalen == 0) {
837 ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
838 uint32_t *java_elems = (uint32_t*)(elems + 4);
839 for (size_t i = 0; i < ret->datalen; i++) {
840 uint32_t arr_elem = java_elems[i];
841 LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)arr_elem;
842 FREE((void*)arr_elem);
843 ret->data[i] = arr_elem_conv;
848 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
849 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
850 LDKThirtyTwoBytes a_ref;
851 CHECK(*((uint32_t*)a) == 32);
852 memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
854 LDKCVec_C2Tuple_u32TxOutZZ b_constr;
855 b_constr.datalen = *((uint32_t*)b);
856 if (b_constr.datalen > 0)
857 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
859 b_constr.data = NULL;
860 uint32_t* b_vals = (uint32_t*)(b + 4);
861 for (size_t z = 0; z < b_constr.datalen; z++) {
862 uint32_t arr_conv_25 = b_vals[z];
863 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_25;
864 FREE((void*)arr_conv_25);
865 b_constr.data[z] = arr_conv_25_conv;
870 int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
871 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
872 int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
873 memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
876 uint32_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
877 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)ptr;
878 LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
879 uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
880 uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
881 for (size_t z = 0; z < b_var.datalen; z++) {
882 long arr_conv_25_ref = (long)&b_var.data[z];
883 b_arr_ptr[z] = arr_conv_25_ref;
887 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
888 LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
889 ret->datalen = *((uint32_t*)elems);
890 if (ret->datalen == 0) {
893 ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
894 uint32_t *java_elems = (uint32_t*)(elems + 4);
895 for (size_t i = 0; i < ret->datalen; i++) {
896 uint32_t arr_elem = java_elems[i];
897 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)arr_elem;
898 FREE((void*)arr_elem);
899 ret->data[i] = arr_elem_conv;
904 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
905 LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
907 CHECK(*((uint32_t*)a) == 64);
908 memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
910 LDKCVec_SignatureZ b_constr;
911 b_constr.datalen = *((uint32_t*)b);
912 if (b_constr.datalen > 0)
913 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
915 b_constr.data = NULL;
916 int8_tArray* b_vals = (int8_tArray*)(b + 4);
917 for (size_t m = 0; m < b_constr.datalen; m++) {
918 int8_tArray arr_conv_12 = b_vals[m];
919 LDKSignature arr_conv_12_ref;
920 CHECK(*((uint32_t*)arr_conv_12) == 64);
921 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
922 b_constr.data[m] = arr_conv_12_ref;
927 int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
928 LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)ptr;
929 int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
930 memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
933 ptrArray __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
934 LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)ptr;
935 LDKCVec_SignatureZ b_var = tuple->b;
936 ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
937 int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
938 for (size_t m = 0; m < b_var.datalen; m++) {
939 int8_tArray arr_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
940 memcpy((uint8_t*)(arr_conv_12_arr + 4), b_var.data[m].compact_form, 64);
941 b_arr_ptr[m] = arr_conv_12_arr;
945 jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
946 return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
948 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
949 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
950 CHECK(val->result_ok);
951 long res_ref = (long)&(*val->contents.result);
954 void __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
955 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg;
956 CHECK(!val->result_ok);
957 return *val->contents.err;
959 jboolean __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
960 return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
962 int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
963 LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
964 CHECK(val->result_ok);
965 int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
966 memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
969 void __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
970 LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)arg;
971 CHECK(!val->result_ok);
972 return *val->contents.err;
974 jboolean __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_result_ok(uint32_t arg) {
975 return ((LDKCResult_CVec_SignatureZNoneZ*)arg)->result_ok;
977 ptrArray __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_ok(uint32_t arg) {
978 LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
979 CHECK(val->result_ok);
980 LDKCVec_SignatureZ res_var = (*val->contents.result);
981 ptrArray res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
982 int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
983 for (size_t m = 0; m < res_var.datalen; m++) {
984 int8_tArray arr_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
985 memcpy((uint8_t*)(arr_conv_12_arr + 4), res_var.data[m].compact_form, 64);
986 res_arr_ptr[m] = arr_conv_12_arr;
990 void __attribute__((visibility("default"))) TS_LDKCResult_CVec_SignatureZNoneZ_get_err(uint32_t arg) {
991 LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)arg;
992 CHECK(!val->result_ok);
993 return *val->contents.err;
995 typedef struct LDKChannelKeys_JCalls {
996 atomic_size_t refcnt;
997 uint32_t get_per_commitment_point_meth;
998 uint32_t release_commitment_secret_meth;
999 uint32_t key_derivation_params_meth;
1000 uint32_t sign_counterparty_commitment_meth;
1001 uint32_t sign_holder_commitment_meth;
1002 uint32_t sign_holder_commitment_htlc_transactions_meth;
1003 uint32_t sign_justice_transaction_meth;
1004 uint32_t sign_counterparty_htlc_transaction_meth;
1005 uint32_t sign_closing_transaction_meth;
1006 uint32_t sign_channel_announcement_meth;
1007 uint32_t ready_channel_meth;
1008 uint32_t write_meth;
1009 } LDKChannelKeys_JCalls;
1010 static void LDKChannelKeys_JCalls_free(void* this_arg) {
1011 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1012 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1013 js_free(j_calls->get_per_commitment_point_meth);
1014 js_free(j_calls->release_commitment_secret_meth);
1015 js_free(j_calls->key_derivation_params_meth);
1016 js_free(j_calls->sign_counterparty_commitment_meth);
1017 js_free(j_calls->sign_holder_commitment_meth);
1018 js_free(j_calls->sign_holder_commitment_htlc_transactions_meth);
1019 js_free(j_calls->sign_justice_transaction_meth);
1020 js_free(j_calls->sign_counterparty_htlc_transaction_meth);
1021 js_free(j_calls->sign_closing_transaction_meth);
1022 js_free(j_calls->sign_channel_announcement_meth);
1023 js_free(j_calls->ready_channel_meth);
1024 js_free(j_calls->write_meth);
1028 LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
1029 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1030 int8_tArray arg = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
1031 LDKPublicKey arg_ref;
1032 CHECK(*((uint32_t*)arg) == 33);
1033 memcpy(arg_ref.compressed_form, (uint8_t*)(arg + 4), 33);
1036 LDKThirtyTwoBytes release_commitment_secret_jcall(const void* this_arg, uint64_t idx) {
1037 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1038 int8_tArray arg = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
1039 LDKThirtyTwoBytes arg_ref;
1040 CHECK(*((uint32_t*)arg) == 32);
1041 memcpy(arg_ref.data, (uint8_t*)(arg + 4), 32);
1044 LDKC2Tuple_u64u64Z key_derivation_params_jcall(const void* this_arg) {
1045 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1046 LDKC2Tuple_u64u64Z* ret = (LDKC2Tuple_u64u64Z*)js_invoke_function_0(j_calls->key_derivation_params_meth);
1047 LDKC2Tuple_u64u64Z ret_conv = *(LDKC2Tuple_u64u64Z*)ret;
1051 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
1052 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1053 LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
1054 if (commitment_tx->inner != NULL)
1055 commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
1056 CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1057 CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1058 long commitment_tx_ref = (long)commitment_tx_var.inner;
1059 if (commitment_tx_var.is_owned) {
1060 commitment_tx_ref |= 1;
1062 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
1063 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret;
1067 LDKCResult_SignatureNoneZ sign_holder_commitment_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1068 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1069 LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1070 if (commitment_tx->inner != NULL)
1071 commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1072 CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1073 CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1074 long commitment_tx_ref = (long)commitment_tx_var.inner;
1075 if (commitment_tx_var.is_owned) {
1076 commitment_tx_ref |= 1;
1078 LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_meth, commitment_tx_ref);
1079 LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1083 LDKCResult_CVec_SignatureZNoneZ sign_holder_commitment_htlc_transactions_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
1084 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1085 LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
1086 if (commitment_tx->inner != NULL)
1087 commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
1088 CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1089 CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1090 long commitment_tx_ref = (long)commitment_tx_var.inner;
1091 if (commitment_tx_var.is_owned) {
1092 commitment_tx_ref |= 1;
1094 LDKCResult_CVec_SignatureZNoneZ* ret = (LDKCResult_CVec_SignatureZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_htlc_transactions_meth, commitment_tx_ref);
1095 LDKCResult_CVec_SignatureZNoneZ ret_conv = *(LDKCResult_CVec_SignatureZNoneZ*)ret;
1099 LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
1100 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1101 LDKTransaction justice_tx_var = justice_tx;
1102 int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1103 memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
1104 Transaction_free(justice_tx_var);
1105 int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1106 memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
1107 LDKHTLCOutputInCommitment htlc_var = *htlc;
1108 if (htlc->inner != NULL)
1109 htlc_var = HTLCOutputInCommitment_clone(htlc);
1110 CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1111 CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1112 long htlc_ref = (long)htlc_var.inner;
1113 if (htlc_var.is_owned) {
1116 LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
1117 LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1121 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
1122 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1123 LDKTransaction htlc_tx_var = htlc_tx;
1124 int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1125 memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
1126 Transaction_free(htlc_tx_var);
1127 int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1128 memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
1129 LDKHTLCOutputInCommitment htlc_var = *htlc;
1130 if (htlc->inner != NULL)
1131 htlc_var = HTLCOutputInCommitment_clone(htlc);
1132 CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1133 CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1134 long htlc_ref = (long)htlc_var.inner;
1135 if (htlc_var.is_owned) {
1138 LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
1139 LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1143 LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
1144 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1145 LDKTransaction closing_tx_var = closing_tx;
1146 int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1147 memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
1148 Transaction_free(closing_tx_var);
1149 LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
1150 LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1154 LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
1155 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1156 LDKUnsignedChannelAnnouncement msg_var = *msg;
1157 if (msg->inner != NULL)
1158 msg_var = UnsignedChannelAnnouncement_clone(msg);
1159 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1160 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1161 long msg_ref = (long)msg_var.inner;
1162 if (msg_var.is_owned) {
1165 LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
1166 LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)ret;
1170 void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
1171 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1172 LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
1173 if (channel_parameters->inner != NULL)
1174 channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
1175 CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1176 CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1177 long channel_parameters_ref = (long)channel_parameters_var.inner;
1178 if (channel_parameters_var.is_owned) {
1179 channel_parameters_ref |= 1;
1181 js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
1183 LDKCVec_u8Z write_jcall(const void* this_arg) {
1184 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1185 int8_tArray arg = js_invoke_function_0(j_calls->write_meth);
1186 LDKCVec_u8Z arg_ref;
1187 arg_ref.datalen = *((uint32_t*)arg);
1188 arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
1189 memcpy(arg_ref.data, (uint8_t*)(arg + 4), arg_ref.datalen);
1192 static void* LDKChannelKeys_JCalls_clone(const void* this_arg) {
1193 LDKChannelKeys_JCalls *j_calls = (LDKChannelKeys_JCalls*) this_arg;
1194 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1195 return (void*) this_arg;
1197 static inline LDKChannelKeys LDKChannelKeys_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1198 LDKChannelKeys_JCalls *calls = MALLOC(sizeof(LDKChannelKeys_JCalls), "LDKChannelKeys_JCalls");
1199 atomic_init(&calls->refcnt, 1);
1200 //TODO: Assign calls->o from o
1202 LDKChannelPublicKeys pubkeys_conv;
1203 pubkeys_conv.inner = (void*)(pubkeys & (~1));
1204 pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
1205 if (pubkeys_conv.inner != NULL)
1206 pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
1208 LDKChannelKeys ret = {
1209 .this_arg = (void*) calls,
1210 .get_per_commitment_point = get_per_commitment_point_jcall,
1211 .release_commitment_secret = release_commitment_secret_jcall,
1212 .key_derivation_params = key_derivation_params_jcall,
1213 .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
1214 .sign_holder_commitment = sign_holder_commitment_jcall,
1215 .sign_holder_commitment_htlc_transactions = sign_holder_commitment_htlc_transactions_jcall,
1216 .sign_justice_transaction = sign_justice_transaction_jcall,
1217 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,
1218 .sign_closing_transaction = sign_closing_transaction_jcall,
1219 .sign_channel_announcement = sign_channel_announcement_jcall,
1220 .ready_channel = ready_channel_jcall,
1221 .clone = LDKChannelKeys_JCalls_clone,
1222 .write = write_jcall,
1223 .free = LDKChannelKeys_JCalls_free,
1224 .pubkeys = pubkeys_conv,
1225 .set_pubkeys = NULL,
1229 long __attribute__((visibility("default"))) TS_LDKChannelKeys_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
1230 LDKChannelKeys *res_ptr = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1231 *res_ptr = LDKChannelKeys_init(o, pubkeys);
1232 return (long)res_ptr;
1234 int8_tArray __attribute__((visibility("default"))) TS_ChannelKeys_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
1235 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1236 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1237 memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
1241 int8_tArray __attribute__((visibility("default"))) TS_ChannelKeys_release_commitment_secret(uint32_t this_arg, int64_t idx) {
1242 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1243 int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1244 memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
1248 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_key_derivation_params(uint32_t this_arg) {
1249 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1250 LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
1251 *ret_ref = (this_arg_conv->key_derivation_params)(this_arg_conv->this_arg);
1252 return (long)ret_ref;
1255 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1256 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1257 LDKCommitmentTransaction commitment_tx_conv;
1258 commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1259 commitment_tx_conv.is_owned = false;
1260 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
1261 *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1262 return (long)ret_conv;
1265 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_sign_holder_commitment(uint32_t this_arg, uint32_t commitment_tx) {
1266 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1267 LDKHolderCommitmentTransaction commitment_tx_conv;
1268 commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1269 commitment_tx_conv.is_owned = false;
1270 LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1271 *ret_conv = (this_arg_conv->sign_holder_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
1272 return (long)ret_conv;
1275 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_sign_holder_commitment_htlc_transactions(uint32_t this_arg, uint32_t commitment_tx) {
1276 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1277 LDKHolderCommitmentTransaction commitment_tx_conv;
1278 commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
1279 commitment_tx_conv.is_owned = false;
1280 LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
1281 *ret_conv = (this_arg_conv->sign_holder_commitment_htlc_transactions)(this_arg_conv->this_arg, &commitment_tx_conv);
1282 return (long)ret_conv;
1285 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_sign_justice_transaction(uint32_t this_arg, int8_tArray justice_tx, intptr_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
1286 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1287 LDKTransaction justice_tx_ref;
1288 justice_tx_ref.datalen = *((uint32_t*)justice_tx);
1289 justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
1290 memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
1291 justice_tx_ref.data_is_owned = true;
1292 unsigned char per_commitment_key_arr[32];
1293 CHECK(*((uint32_t*)per_commitment_key) == 32);
1294 memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
1295 unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
1296 LDKHTLCOutputInCommitment htlc_conv;
1297 htlc_conv.inner = (void*)(htlc & (~1));
1298 htlc_conv.is_owned = false;
1299 LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1300 *ret_conv = (this_arg_conv->sign_justice_transaction)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
1301 return (long)ret_conv;
1304 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, intptr_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
1305 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1306 LDKTransaction htlc_tx_ref;
1307 htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
1308 htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
1309 memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
1310 htlc_tx_ref.data_is_owned = true;
1311 LDKPublicKey per_commitment_point_ref;
1312 CHECK(*((uint32_t*)per_commitment_point) == 33);
1313 memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
1314 LDKHTLCOutputInCommitment htlc_conv;
1315 htlc_conv.inner = (void*)(htlc & (~1));
1316 htlc_conv.is_owned = false;
1317 LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1318 *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);
1319 return (long)ret_conv;
1322 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_sign_closing_transaction(uint32_t this_arg, int8_tArray closing_tx) {
1323 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1324 LDKTransaction closing_tx_ref;
1325 closing_tx_ref.datalen = *((uint32_t*)closing_tx);
1326 closing_tx_ref.data = MALLOC(closing_tx_ref.datalen, "LDKTransaction Bytes");
1327 memcpy(closing_tx_ref.data, (uint8_t*)(closing_tx + 4), closing_tx_ref.datalen);
1328 closing_tx_ref.data_is_owned = true;
1329 LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1330 *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, closing_tx_ref);
1331 return (long)ret_conv;
1334 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
1335 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1336 LDKUnsignedChannelAnnouncement msg_conv;
1337 msg_conv.inner = (void*)(msg & (~1));
1338 msg_conv.is_owned = false;
1339 LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
1340 *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
1341 return (long)ret_conv;
1344 void __attribute__((visibility("default"))) TS_ChannelKeys_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
1345 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1346 LDKChannelTransactionParameters channel_parameters_conv;
1347 channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
1348 channel_parameters_conv.is_owned = false;
1349 (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
1352 int8_tArray __attribute__((visibility("default"))) TS_ChannelKeys_write(uint32_t this_arg) {
1353 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1354 LDKCVec_u8Z arg_var = (this_arg_conv->write)(this_arg_conv->this_arg);
1355 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1356 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
1357 CVec_u8Z_free(arg_var);
1361 LDKChannelPublicKeys LDKChannelKeys_set_get_pubkeys(LDKChannelKeys* this_arg) {
1362 if (this_arg->set_pubkeys != NULL)
1363 this_arg->set_pubkeys(this_arg);
1364 return this_arg->pubkeys;
1366 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_get_pubkeys(uint32_t this_arg) {
1367 LDKChannelKeys* this_arg_conv = (LDKChannelKeys*)this_arg;
1368 LDKChannelPublicKeys ret_var = LDKChannelKeys_set_get_pubkeys(this_arg_conv);
1369 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1370 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1371 long ret_ref = (long)ret_var.inner;
1372 if (ret_var.is_owned) {
1378 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
1379 LDKC2Tuple_BlockHashChannelMonitorZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
1380 LDKThirtyTwoBytes a_ref;
1381 CHECK(*((uint32_t*)a) == 32);
1382 memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
1384 LDKChannelMonitor b_conv;
1385 b_conv.inner = (void*)(b & (~1));
1386 b_conv.is_owned = (b & 1) || (b == 0);
1387 // Warning: we may need a move here but can't clone!
1391 int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t ptr) {
1392 LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
1393 int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1394 memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
1397 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t ptr) {
1398 LDKC2Tuple_BlockHashChannelMonitorZ *tuple = (LDKC2Tuple_BlockHashChannelMonitorZ*)ptr;
1399 LDKChannelMonitor b_var = tuple->b;
1400 CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1401 CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1402 long b_ref = (long)b_var.inner & ~1;
1405 jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
1406 return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
1408 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
1409 LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
1410 CHECK(val->result_ok);
1411 long res_ref = (long)&(*val->contents.result);
1414 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
1415 LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg;
1416 CHECK(!val->result_ok);
1417 LDKDecodeError err_var = (*val->contents.err);
1418 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1419 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1420 long err_ref = (long)err_var.inner & ~1;
1423 jboolean __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
1424 return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
1426 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
1427 LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
1428 CHECK(val->result_ok);
1429 long res_ref = (long)&(*val->contents.result);
1432 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
1433 LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg;
1434 CHECK(!val->result_ok);
1435 LDKDecodeError err_var = (*val->contents.err);
1436 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1437 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1438 long err_ref = (long)err_var.inner & ~1;
1441 jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_result_ok(uint32_t arg) {
1442 return ((LDKCResult_ChanKeySignerDecodeErrorZ*)arg)->result_ok;
1444 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_get_ok(uint32_t arg) {
1445 LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
1446 CHECK(val->result_ok);
1447 LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1448 *ret = (*val->contents.result);
1451 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChanKeySignerDecodeErrorZ_get_err(uint32_t arg) {
1452 LDKCResult_ChanKeySignerDecodeErrorZ *val = (LDKCResult_ChanKeySignerDecodeErrorZ*)arg;
1453 CHECK(!val->result_ok);
1454 LDKDecodeError err_var = (*val->contents.err);
1455 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1456 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1457 long err_ref = (long)err_var.inner & ~1;
1460 jboolean __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_result_ok(uint32_t arg) {
1461 return ((LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg)->result_ok;
1463 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_get_ok(uint32_t arg) {
1464 LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
1465 CHECK(val->result_ok);
1466 LDKInMemoryChannelKeys res_var = (*val->contents.result);
1467 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1468 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1469 long res_ref = (long)res_var.inner & ~1;
1472 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InMemoryChannelKeysDecodeErrorZ_get_err(uint32_t arg) {
1473 LDKCResult_InMemoryChannelKeysDecodeErrorZ *val = (LDKCResult_InMemoryChannelKeysDecodeErrorZ*)arg;
1474 CHECK(!val->result_ok);
1475 LDKDecodeError err_var = (*val->contents.err);
1476 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1477 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1478 long err_ref = (long)err_var.inner & ~1;
1481 jboolean __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_result_ok(uint32_t arg) {
1482 return ((LDKCResult_TxOutAccessErrorZ*)arg)->result_ok;
1484 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_ok(uint32_t arg) {
1485 LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1486 CHECK(val->result_ok);
1487 long res_ref = (long)&(*val->contents.result);
1488 return (long)res_ref;
1490 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_TxOutAccessErrorZ_get_err(uint32_t arg) {
1491 LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)arg;
1492 CHECK(!val->result_ok);
1493 uint32_t err_conv = LDKAccessError_to_js((*val->contents.err));
1496 uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
1497 LDKAPIError *obj = (LDKAPIError*)ptr;
1499 case LDKAPIError_APIMisuseError: {
1500 LDKCVec_u8Z err_var = obj->api_misuse_error.err;
1501 int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1502 memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1503 return 0 /* LDKAPIError - APIMisuseError */; (void) err_arr;
1505 case LDKAPIError_FeeRateTooHigh: {
1506 LDKCVec_u8Z err_var = obj->fee_rate_too_high.err;
1507 int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1508 memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1509 return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_arr; (void) obj->fee_rate_too_high.feerate;
1511 case LDKAPIError_RouteError: {
1512 LDKStr err_str = obj->route_error.err;
1513 jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
1514 return 0 /* LDKAPIError - RouteError */; (void) err_conv;
1516 case LDKAPIError_ChannelUnavailable: {
1517 LDKCVec_u8Z err_var = obj->channel_unavailable.err;
1518 int8_tArray err_arr = init_arr(err_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1519 memcpy((uint8_t*)(err_arr + 4), err_var.data, err_var.datalen);
1520 return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_arr;
1522 case LDKAPIError_MonitorUpdateFailed: {
1523 return 0 /* LDKAPIError - MonitorUpdateFailed */;
1528 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
1529 return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
1531 void __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
1532 LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
1533 CHECK(val->result_ok);
1534 return *val->contents.result;
1536 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
1537 LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)arg;
1538 CHECK(!val->result_ok);
1539 long err_ref = (long)&(*val->contents.err);
1542 static inline LDKCResult_NoneAPIErrorZ CResult_NoneAPIErrorZ_clone(const LDKCResult_NoneAPIErrorZ *orig) {
1543 LDKCResult_NoneAPIErrorZ res = { .result_ok = orig->result_ok };
1544 if (orig->result_ok) {
1545 res.contents.result = NULL;
1547 LDKAPIError* contents = MALLOC(sizeof(LDKAPIError), "LDKAPIError result Err clone");
1548 *contents = APIError_clone(orig->contents.err);
1549 res.contents.err = contents;
1553 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_ChannelDetailsZ_new(uint32_tArray elems) {
1554 LDKCVec_ChannelDetailsZ *ret = MALLOC(sizeof(LDKCVec_ChannelDetailsZ), "LDKCVec_ChannelDetailsZ");
1555 ret->datalen = *((uint32_t*)elems);
1556 if (ret->datalen == 0) {
1559 ret->data = MALLOC(sizeof(LDKChannelDetails) * ret->datalen, "LDKCVec_ChannelDetailsZ Data");
1560 uint32_t *java_elems = (uint32_t*)(elems + 4);
1561 for (size_t i = 0; i < ret->datalen; i++) {
1562 uint32_t arr_elem = java_elems[i];
1563 LDKChannelDetails arr_elem_conv;
1564 arr_elem_conv.inner = (void*)(arr_elem & (~1));
1565 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1566 if (arr_elem_conv.inner != NULL)
1567 arr_elem_conv = ChannelDetails_clone(&arr_elem_conv);
1568 ret->data[i] = arr_elem_conv;
1573 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1574 LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1575 for (size_t i = 0; i < ret.datalen; i++) {
1576 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1580 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
1581 return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
1583 void __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
1584 LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
1585 CHECK(val->result_ok);
1586 return *val->contents.result;
1588 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
1589 LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)arg;
1590 CHECK(!val->result_ok);
1591 LDKPaymentSendFailure err_var = (*val->contents.err);
1592 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1593 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1594 long err_ref = (long)err_var.inner & ~1;
1597 uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
1598 LDKNetAddress *obj = (LDKNetAddress*)ptr;
1600 case LDKNetAddress_IPv4: {
1601 int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
1602 memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
1603 return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
1605 case LDKNetAddress_IPv6: {
1606 int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
1607 memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
1608 return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
1610 case LDKNetAddress_OnionV2: {
1611 int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
1612 memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
1613 return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
1615 case LDKNetAddress_OnionV3: {
1616 int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1617 memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
1618 return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
1623 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
1624 LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
1625 ret->datalen = *((uint32_t*)elems);
1626 if (ret->datalen == 0) {
1629 ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
1630 uint32_t *java_elems = (uint32_t*)(elems + 4);
1631 for (size_t i = 0; i < ret->datalen; i++) {
1632 uint32_t arr_elem = java_elems[i];
1633 LDKNetAddress arr_elem_conv = *(LDKNetAddress*)arr_elem;
1634 FREE((void*)arr_elem);
1635 ret->data[i] = arr_elem_conv;
1640 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
1641 LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
1642 for (size_t i = 0; i < ret.datalen; i++) {
1643 ret.data[i] = NetAddress_clone(&orig->data[i]);
1647 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
1648 LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
1649 ret->datalen = *((uint32_t*)elems);
1650 if (ret->datalen == 0) {
1653 ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
1654 uint32_t *java_elems = (uint32_t*)(elems + 4);
1655 for (size_t i = 0; i < ret->datalen; i++) {
1656 uint32_t arr_elem = java_elems[i];
1657 LDKChannelMonitor arr_elem_conv;
1658 arr_elem_conv.inner = (void*)(arr_elem & (~1));
1659 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
1660 // Warning: we may need a move here but can't clone!
1661 ret->data[i] = arr_elem_conv;
1666 typedef struct LDKWatch_JCalls {
1667 atomic_size_t refcnt;
1668 uint32_t watch_channel_meth;
1669 uint32_t update_channel_meth;
1670 uint32_t release_pending_monitor_events_meth;
1672 static void LDKWatch_JCalls_free(void* this_arg) {
1673 LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1674 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1675 js_free(j_calls->watch_channel_meth);
1676 js_free(j_calls->update_channel_meth);
1677 js_free(j_calls->release_pending_monitor_events_meth);
1681 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
1682 LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1683 LDKOutPoint funding_txo_var = funding_txo;
1684 CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1685 CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1686 long funding_txo_ref = (long)funding_txo_var.inner;
1687 if (funding_txo_var.is_owned) {
1688 funding_txo_ref |= 1;
1690 LDKChannelMonitor monitor_var = monitor;
1691 CHECK((((long)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1692 CHECK((((long)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1693 long monitor_ref = (long)monitor_var.inner;
1694 if (monitor_var.is_owned) {
1697 LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
1698 LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
1702 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
1703 LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1704 LDKOutPoint funding_txo_var = funding_txo;
1705 CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1706 CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1707 long funding_txo_ref = (long)funding_txo_var.inner;
1708 if (funding_txo_var.is_owned) {
1709 funding_txo_ref |= 1;
1711 LDKChannelMonitorUpdate update_var = update;
1712 CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1713 CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1714 long update_ref = (long)update_var.inner;
1715 if (update_var.is_owned) {
1718 LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
1719 LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
1723 LDKCVec_MonitorEventZ release_pending_monitor_events_jcall(const void* this_arg) {
1724 LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1725 uint32_tArray arg = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
1726 LDKCVec_MonitorEventZ arg_constr;
1727 arg_constr.datalen = *((uint32_t*)arg);
1728 if (arg_constr.datalen > 0)
1729 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
1731 arg_constr.data = NULL;
1732 uint32_t* arg_vals = (uint32_t*)(arg + 4);
1733 for (size_t o = 0; o < arg_constr.datalen; o++) {
1734 uint32_t arr_conv_14 = arg_vals[o];
1735 LDKMonitorEvent arr_conv_14_conv;
1736 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
1737 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
1738 if (arr_conv_14_conv.inner != NULL)
1739 arr_conv_14_conv = MonitorEvent_clone(&arr_conv_14_conv);
1740 arg_constr.data[o] = arr_conv_14_conv;
1744 static void* LDKWatch_JCalls_clone(const void* this_arg) {
1745 LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
1746 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1747 return (void*) this_arg;
1749 static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
1750 LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
1751 atomic_init(&calls->refcnt, 1);
1752 //TODO: Assign calls->o from o
1755 .this_arg = (void*) calls,
1756 .watch_channel = watch_channel_jcall,
1757 .update_channel = update_channel_jcall,
1758 .release_pending_monitor_events = release_pending_monitor_events_jcall,
1759 .free = LDKWatch_JCalls_free,
1763 long __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
1764 LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
1765 *res_ptr = LDKWatch_init(o);
1766 return (long)res_ptr;
1768 uint32_t __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
1769 LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1770 LDKOutPoint funding_txo_conv;
1771 funding_txo_conv.inner = (void*)(funding_txo & (~1));
1772 funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1773 if (funding_txo_conv.inner != NULL)
1774 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1775 LDKChannelMonitor monitor_conv;
1776 monitor_conv.inner = (void*)(monitor & (~1));
1777 monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
1778 // Warning: we may need a move here but can't clone!
1779 LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1780 *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
1781 return (long)ret_conv;
1784 uint32_t __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
1785 LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1786 LDKOutPoint funding_txo_conv;
1787 funding_txo_conv.inner = (void*)(funding_txo & (~1));
1788 funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
1789 if (funding_txo_conv.inner != NULL)
1790 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
1791 LDKChannelMonitorUpdate update_conv;
1792 update_conv.inner = (void*)(update & (~1));
1793 update_conv.is_owned = (update & 1) || (update == 0);
1794 if (update_conv.inner != NULL)
1795 update_conv = ChannelMonitorUpdate_clone(&update_conv);
1796 LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
1797 *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
1798 return (long)ret_conv;
1801 uint32_tArray __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
1802 LDKWatch* this_arg_conv = (LDKWatch*)this_arg;
1803 LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
1804 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
1805 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
1806 for (size_t o = 0; o < ret_var.datalen; o++) {
1807 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
1808 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1809 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1810 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
1811 if (arr_conv_14_var.is_owned) {
1812 arr_conv_14_ref |= 1;
1814 ret_arr_ptr[o] = arr_conv_14_ref;
1820 typedef struct LDKBroadcasterInterface_JCalls {
1821 atomic_size_t refcnt;
1822 uint32_t broadcast_transaction_meth;
1823 } LDKBroadcasterInterface_JCalls;
1824 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
1825 LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1826 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1827 js_free(j_calls->broadcast_transaction_meth);
1831 void broadcast_transaction_jcall(const void* this_arg, LDKTransaction tx) {
1832 LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1833 LDKTransaction tx_var = tx;
1834 int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1835 memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
1836 Transaction_free(tx_var);
1837 js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
1839 static void* LDKBroadcasterInterface_JCalls_clone(const void* this_arg) {
1840 LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
1841 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1842 return (void*) this_arg;
1844 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
1845 LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
1846 atomic_init(&calls->refcnt, 1);
1847 //TODO: Assign calls->o from o
1849 LDKBroadcasterInterface ret = {
1850 .this_arg = (void*) calls,
1851 .broadcast_transaction = broadcast_transaction_jcall,
1852 .free = LDKBroadcasterInterface_JCalls_free,
1856 long __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
1857 LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
1858 *res_ptr = LDKBroadcasterInterface_init(o);
1859 return (long)res_ptr;
1861 void __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
1862 LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg;
1863 LDKTransaction tx_ref;
1864 tx_ref.datalen = *((uint32_t*)tx);
1865 tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
1866 memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
1867 tx_ref.data_is_owned = true;
1868 (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
1871 typedef struct LDKKeysInterface_JCalls {
1872 atomic_size_t refcnt;
1873 uint32_t get_node_secret_meth;
1874 uint32_t get_destination_script_meth;
1875 uint32_t get_shutdown_pubkey_meth;
1876 uint32_t get_channel_keys_meth;
1877 uint32_t get_secure_random_bytes_meth;
1878 uint32_t read_chan_signer_meth;
1879 } LDKKeysInterface_JCalls;
1880 static void LDKKeysInterface_JCalls_free(void* this_arg) {
1881 LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1882 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1883 js_free(j_calls->get_node_secret_meth);
1884 js_free(j_calls->get_destination_script_meth);
1885 js_free(j_calls->get_shutdown_pubkey_meth);
1886 js_free(j_calls->get_channel_keys_meth);
1887 js_free(j_calls->get_secure_random_bytes_meth);
1888 js_free(j_calls->read_chan_signer_meth);
1892 LDKSecretKey get_node_secret_jcall(const void* this_arg) {
1893 LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1894 int8_tArray arg = js_invoke_function_0(j_calls->get_node_secret_meth);
1895 LDKSecretKey arg_ref;
1896 CHECK(*((uint32_t*)arg) == 32);
1897 memcpy(arg_ref.bytes, (uint8_t*)(arg + 4), 32);
1900 LDKCVec_u8Z get_destination_script_jcall(const void* this_arg) {
1901 LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1902 int8_tArray arg = js_invoke_function_0(j_calls->get_destination_script_meth);
1903 LDKCVec_u8Z arg_ref;
1904 arg_ref.datalen = *((uint32_t*)arg);
1905 arg_ref.data = MALLOC(arg_ref.datalen, "LDKCVec_u8Z Bytes");
1906 memcpy(arg_ref.data, (uint8_t*)(arg + 4), arg_ref.datalen);
1909 LDKPublicKey get_shutdown_pubkey_jcall(const void* this_arg) {
1910 LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1911 int8_tArray arg = js_invoke_function_0(j_calls->get_shutdown_pubkey_meth);
1912 LDKPublicKey arg_ref;
1913 CHECK(*((uint32_t*)arg) == 33);
1914 memcpy(arg_ref.compressed_form, (uint8_t*)(arg + 4), 33);
1917 LDKChannelKeys get_channel_keys_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
1918 LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1919 LDKChannelKeys* ret = (LDKChannelKeys*)js_invoke_function_2(j_calls->get_channel_keys_meth, inbound, channel_value_satoshis);
1920 LDKChannelKeys ret_conv = *(LDKChannelKeys*)ret;
1921 ret_conv = ChannelKeys_clone(ret);
1924 LDKThirtyTwoBytes get_secure_random_bytes_jcall(const void* this_arg) {
1925 LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1926 int8_tArray arg = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
1927 LDKThirtyTwoBytes arg_ref;
1928 CHECK(*((uint32_t*)arg) == 32);
1929 memcpy(arg_ref.data, (uint8_t*)(arg + 4), 32);
1932 LDKCResult_ChanKeySignerDecodeErrorZ read_chan_signer_jcall(const void* this_arg, LDKu8slice reader) {
1933 LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1934 LDKu8slice reader_var = reader;
1935 int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1936 memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
1937 LDKCResult_ChanKeySignerDecodeErrorZ* ret = (LDKCResult_ChanKeySignerDecodeErrorZ*)js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
1938 LDKCResult_ChanKeySignerDecodeErrorZ ret_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)ret;
1942 static void* LDKKeysInterface_JCalls_clone(const void* this_arg) {
1943 LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
1944 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1945 return (void*) this_arg;
1947 static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
1948 LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
1949 atomic_init(&calls->refcnt, 1);
1950 //TODO: Assign calls->o from o
1952 LDKKeysInterface ret = {
1953 .this_arg = (void*) calls,
1954 .get_node_secret = get_node_secret_jcall,
1955 .get_destination_script = get_destination_script_jcall,
1956 .get_shutdown_pubkey = get_shutdown_pubkey_jcall,
1957 .get_channel_keys = get_channel_keys_jcall,
1958 .get_secure_random_bytes = get_secure_random_bytes_jcall,
1959 .read_chan_signer = read_chan_signer_jcall,
1960 .free = LDKKeysInterface_JCalls_free,
1964 long __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
1965 LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
1966 *res_ptr = LDKKeysInterface_init(o);
1967 return (long)res_ptr;
1969 int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
1970 LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1971 int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
1972 memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
1976 int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
1977 LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1978 LDKCVec_u8Z arg_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
1979 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
1980 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
1981 CVec_u8Z_free(arg_var);
1985 int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_pubkey(uint32_t this_arg) {
1986 LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1987 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
1988 memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_shutdown_pubkey)(this_arg_conv->this_arg).compressed_form, 33);
1992 uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_channel_keys(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
1993 LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
1994 LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
1995 *ret = (this_arg_conv->get_channel_keys)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
1999 int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
2000 LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2001 int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2002 memcpy((uint8_t*)(arg_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
2006 uint32_t __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
2007 LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg;
2008 LDKu8slice reader_ref;
2009 reader_ref.datalen = *((uint32_t*)reader);
2010 reader_ref.data = (int8_t*)(reader + 4);
2011 LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
2012 *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
2013 return (long)ret_conv;
2016 typedef struct LDKFeeEstimator_JCalls {
2017 atomic_size_t refcnt;
2018 uint32_t get_est_sat_per_1000_weight_meth;
2019 } LDKFeeEstimator_JCalls;
2020 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
2021 LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2022 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2023 js_free(j_calls->get_est_sat_per_1000_weight_meth);
2027 uint32_t get_est_sat_per_1000_weight_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
2028 LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2029 uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
2030 return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
2032 static void* LDKFeeEstimator_JCalls_clone(const void* this_arg) {
2033 LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
2034 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2035 return (void*) this_arg;
2037 static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
2038 LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
2039 atomic_init(&calls->refcnt, 1);
2040 //TODO: Assign calls->o from o
2042 LDKFeeEstimator ret = {
2043 .this_arg = (void*) calls,
2044 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_jcall,
2045 .free = LDKFeeEstimator_JCalls_free,
2049 long __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
2050 LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
2051 *res_ptr = LDKFeeEstimator_init(o);
2052 return (long)res_ptr;
2054 int32_t __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
2055 LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg;
2056 LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
2057 int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
2061 typedef struct LDKLogger_JCalls {
2062 atomic_size_t refcnt;
2065 static void LDKLogger_JCalls_free(void* this_arg) {
2066 LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2067 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2068 js_free(j_calls->log_meth);
2072 void log_jcall(const void* this_arg, const char* record) {
2073 LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2074 const char* record_str = record;
2075 jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
2076 js_invoke_function_1(j_calls->log_meth, record_conv);
2078 static void* LDKLogger_JCalls_clone(const void* this_arg) {
2079 LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
2080 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2081 return (void*) this_arg;
2083 static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
2084 LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
2085 atomic_init(&calls->refcnt, 1);
2086 //TODO: Assign calls->o from o
2089 .this_arg = (void*) calls,
2091 .free = LDKLogger_JCalls_free,
2095 long __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
2096 LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
2097 *res_ptr = LDKLogger_init(o);
2098 return (long)res_ptr;
2100 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
2101 LDKC2Tuple_BlockHashChannelManagerZ* ret = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
2102 LDKThirtyTwoBytes a_ref;
2103 CHECK(*((uint32_t*)a) == 32);
2104 memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
2106 LDKChannelManager b_conv;
2107 b_conv.inner = (void*)(b & (~1));
2108 b_conv.is_owned = (b & 1) || (b == 0);
2109 // Warning: we may need a move here but can't clone!
2113 int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_a(uint32_t ptr) {
2114 LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)ptr;
2115 int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2116 memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
2119 uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_BlockHashChannelManagerZ_get_b(uint32_t ptr) {
2120 LDKC2Tuple_BlockHashChannelManagerZ *tuple = (LDKC2Tuple_BlockHashChannelManagerZ*)ptr;
2121 LDKChannelManager b_var = tuple->b;
2122 CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2123 CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2124 long b_ref = (long)b_var.inner & ~1;
2127 jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
2128 return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
2130 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
2131 LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg;
2132 CHECK(val->result_ok);
2133 long res_ref = (long)&(*val->contents.result);
2136 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
2137 LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg;
2138 CHECK(!val->result_ok);
2139 LDKDecodeError err_var = (*val->contents.err);
2140 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2141 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2142 long err_ref = (long)err_var.inner & ~1;
2145 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_result_ok(uint32_t arg) {
2146 return ((LDKCResult_NetAddressu8Z*)arg)->result_ok;
2148 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_ok(uint32_t arg) {
2149 LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)arg;
2150 CHECK(val->result_ok);
2151 long res_ref = (long)&(*val->contents.result);
2154 int8_t __attribute__((visibility("default"))) TS_LDKCResult_NetAddressu8Z_get_err(uint32_t arg) {
2155 LDKCResult_NetAddressu8Z *val = (LDKCResult_NetAddressu8Z*)arg;
2156 CHECK(!val->result_ok);
2157 return *val->contents.err;
2159 static inline LDKCResult_NetAddressu8Z CResult_NetAddressu8Z_clone(const LDKCResult_NetAddressu8Z *orig) {
2160 LDKCResult_NetAddressu8Z res = { .result_ok = orig->result_ok };
2161 if (orig->result_ok) {
2162 LDKNetAddress* contents = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress result OK clone");
2163 *contents = NetAddress_clone(orig->contents.result);
2164 res.contents.result = contents;
2166 int8_t* contents = MALLOC(sizeof(int8_t), "int8_t result Err clone");
2167 *contents = *orig->contents.err;
2168 res.contents.err = contents;
2172 jboolean __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_result_ok(uint32_t arg) {
2173 return ((LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg)->result_ok;
2175 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_ok(uint32_t arg) {
2176 LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg;
2177 CHECK(val->result_ok);
2178 LDKCResult_NetAddressu8Z* res_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
2179 *res_conv = (*val->contents.result);
2180 *res_conv = CResult_NetAddressu8Z_clone(res_conv);
2181 return (long)res_conv;
2183 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CResult_NetAddressu8ZDecodeErrorZ_get_err(uint32_t arg) {
2184 LDKCResult_CResult_NetAddressu8ZDecodeErrorZ *val = (LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)arg;
2185 CHECK(!val->result_ok);
2186 LDKDecodeError err_var = (*val->contents.err);
2187 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2188 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2189 long err_ref = (long)err_var.inner & ~1;
2192 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
2193 LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
2194 ret->datalen = *((uint32_t*)elems);
2195 if (ret->datalen == 0) {
2198 ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
2199 int64_t *java_elems = (int64_t*)(elems + 4);
2200 for (size_t i = 0; i < ret->datalen; i++) {
2201 ret->data[i] = java_elems[i];
2206 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2207 LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2208 memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2211 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
2212 LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
2213 ret->datalen = *((uint32_t*)elems);
2214 if (ret->datalen == 0) {
2217 ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
2218 uint32_t *java_elems = (uint32_t*)(elems + 4);
2219 for (size_t i = 0; i < ret->datalen; i++) {
2220 uint32_t arr_elem = java_elems[i];
2221 LDKUpdateAddHTLC arr_elem_conv;
2222 arr_elem_conv.inner = (void*)(arr_elem & (~1));
2223 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2224 if (arr_elem_conv.inner != NULL)
2225 arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
2226 ret->data[i] = arr_elem_conv;
2231 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
2232 LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
2233 for (size_t i = 0; i < ret.datalen; i++) {
2234 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
2238 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
2239 LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
2240 ret->datalen = *((uint32_t*)elems);
2241 if (ret->datalen == 0) {
2244 ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
2245 uint32_t *java_elems = (uint32_t*)(elems + 4);
2246 for (size_t i = 0; i < ret->datalen; i++) {
2247 uint32_t arr_elem = java_elems[i];
2248 LDKUpdateFulfillHTLC arr_elem_conv;
2249 arr_elem_conv.inner = (void*)(arr_elem & (~1));
2250 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2251 if (arr_elem_conv.inner != NULL)
2252 arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
2253 ret->data[i] = arr_elem_conv;
2258 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
2259 LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
2260 for (size_t i = 0; i < ret.datalen; i++) {
2261 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
2265 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
2266 LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
2267 ret->datalen = *((uint32_t*)elems);
2268 if (ret->datalen == 0) {
2271 ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
2272 uint32_t *java_elems = (uint32_t*)(elems + 4);
2273 for (size_t i = 0; i < ret->datalen; i++) {
2274 uint32_t arr_elem = java_elems[i];
2275 LDKUpdateFailHTLC arr_elem_conv;
2276 arr_elem_conv.inner = (void*)(arr_elem & (~1));
2277 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2278 if (arr_elem_conv.inner != NULL)
2279 arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
2280 ret->data[i] = arr_elem_conv;
2285 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
2286 LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
2287 for (size_t i = 0; i < ret.datalen; i++) {
2288 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
2292 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
2293 LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
2294 ret->datalen = *((uint32_t*)elems);
2295 if (ret->datalen == 0) {
2298 ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
2299 uint32_t *java_elems = (uint32_t*)(elems + 4);
2300 for (size_t i = 0; i < ret->datalen; i++) {
2301 uint32_t arr_elem = java_elems[i];
2302 LDKUpdateFailMalformedHTLC arr_elem_conv;
2303 arr_elem_conv.inner = (void*)(arr_elem & (~1));
2304 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2305 if (arr_elem_conv.inner != NULL)
2306 arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
2307 ret->data[i] = arr_elem_conv;
2312 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
2313 LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
2314 for (size_t i = 0; i < ret.datalen; i++) {
2315 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
2319 jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
2320 return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
2322 jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
2323 LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
2324 CHECK(val->result_ok);
2325 return *val->contents.result;
2327 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
2328 LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)arg;
2329 CHECK(!val->result_ok);
2330 LDKLightningError err_var = (*val->contents.err);
2331 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2332 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2333 long err_ref = (long)err_var.inner & ~1;
2336 uint32_t __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
2337 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
2338 LDKChannelAnnouncement a_conv;
2339 a_conv.inner = (void*)(a & (~1));
2340 a_conv.is_owned = (a & 1) || (a == 0);
2341 if (a_conv.inner != NULL)
2342 a_conv = ChannelAnnouncement_clone(&a_conv);
2344 LDKChannelUpdate b_conv;
2345 b_conv.inner = (void*)(b & (~1));
2346 b_conv.is_owned = (b & 1) || (b == 0);
2347 if (b_conv.inner != NULL)
2348 b_conv = ChannelUpdate_clone(&b_conv);
2350 LDKChannelUpdate c_conv;
2351 c_conv.inner = (void*)(c & (~1));
2352 c_conv.is_owned = (c & 1) || (c == 0);
2353 if (c_conv.inner != NULL)
2354 c_conv = ChannelUpdate_clone(&c_conv);
2358 static inline LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(const LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *orig) {
2359 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret = {
2360 .a = ChannelAnnouncement_clone(&orig->a),
2361 .b = ChannelUpdate_clone(&orig->b),
2362 .c = ChannelUpdate_clone(&orig->c),
2366 uint32_t __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t ptr) {
2367 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2368 LDKChannelAnnouncement a_var = tuple->a;
2369 CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2370 CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2371 long a_ref = (long)a_var.inner & ~1;
2374 uint32_t __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t ptr) {
2375 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2376 LDKChannelUpdate b_var = tuple->b;
2377 CHECK((((long)b_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2378 CHECK((((long)&b_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2379 long b_ref = (long)b_var.inner & ~1;
2382 uint32_t __attribute__((visibility("default"))) TS_LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t ptr) {
2383 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *tuple = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)ptr;
2384 LDKChannelUpdate c_var = tuple->c;
2385 CHECK((((long)c_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2386 CHECK((((long)&c_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2387 long c_ref = (long)c_var.inner & ~1;
2390 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
2391 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
2392 ret->datalen = *((uint32_t*)elems);
2393 if (ret->datalen == 0) {
2396 ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
2397 uint32_t *java_elems = (uint32_t*)(elems + 4);
2398 for (size_t i = 0; i < ret->datalen; i++) {
2399 uint32_t arr_elem = java_elems[i];
2400 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_elem;
2401 FREE((void*)arr_elem);
2402 ret->data[i] = arr_elem_conv;
2407 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
2408 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
2409 for (size_t i = 0; i < ret.datalen; i++) {
2410 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
2414 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
2415 LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
2416 ret->datalen = *((uint32_t*)elems);
2417 if (ret->datalen == 0) {
2420 ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
2421 uint32_t *java_elems = (uint32_t*)(elems + 4);
2422 for (size_t i = 0; i < ret->datalen; i++) {
2423 uint32_t arr_elem = java_elems[i];
2424 LDKNodeAnnouncement arr_elem_conv;
2425 arr_elem_conv.inner = (void*)(arr_elem & (~1));
2426 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2427 if (arr_elem_conv.inner != NULL)
2428 arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
2429 ret->data[i] = arr_elem_conv;
2434 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
2435 LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
2436 for (size_t i = 0; i < ret.datalen; i++) {
2437 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
2441 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
2442 return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
2444 void __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
2445 LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)arg;
2446 CHECK(val->result_ok);
2447 return *val->contents.result;
2449 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
2450 LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)arg;
2451 CHECK(!val->result_ok);
2452 LDKLightningError err_var = (*val->contents.err);
2453 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2454 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2455 long err_ref = (long)err_var.inner & ~1;
2458 jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
2459 return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
2461 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
2462 LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)arg;
2463 CHECK(val->result_ok);
2464 LDKChannelReestablish res_var = (*val->contents.result);
2465 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2466 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2467 long res_ref = (long)res_var.inner & ~1;
2470 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
2471 LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)arg;
2472 CHECK(!val->result_ok);
2473 LDKDecodeError err_var = (*val->contents.err);
2474 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2475 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2476 long err_ref = (long)err_var.inner & ~1;
2479 jboolean __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
2480 return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
2482 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
2483 LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)arg;
2484 CHECK(val->result_ok);
2485 LDKInit res_var = (*val->contents.result);
2486 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2487 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2488 long res_ref = (long)res_var.inner & ~1;
2491 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
2492 LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)arg;
2493 CHECK(!val->result_ok);
2494 LDKDecodeError err_var = (*val->contents.err);
2495 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2496 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2497 long err_ref = (long)err_var.inner & ~1;
2500 jboolean __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
2501 return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
2503 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
2504 LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)arg;
2505 CHECK(val->result_ok);
2506 LDKPing res_var = (*val->contents.result);
2507 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2508 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2509 long res_ref = (long)res_var.inner & ~1;
2512 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
2513 LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)arg;
2514 CHECK(!val->result_ok);
2515 LDKDecodeError err_var = (*val->contents.err);
2516 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2517 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2518 long err_ref = (long)err_var.inner & ~1;
2521 jboolean __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
2522 return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
2524 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
2525 LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)arg;
2526 CHECK(val->result_ok);
2527 LDKPong res_var = (*val->contents.result);
2528 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2529 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2530 long res_ref = (long)res_var.inner & ~1;
2533 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
2534 LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)arg;
2535 CHECK(!val->result_ok);
2536 LDKDecodeError err_var = (*val->contents.err);
2537 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2538 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2539 long err_ref = (long)err_var.inner & ~1;
2542 jboolean __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
2543 return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
2545 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
2546 LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg;
2547 CHECK(val->result_ok);
2548 LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
2549 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2550 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2551 long res_ref = (long)res_var.inner & ~1;
2554 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
2555 LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg;
2556 CHECK(!val->result_ok);
2557 LDKDecodeError err_var = (*val->contents.err);
2558 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2559 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2560 long err_ref = (long)err_var.inner & ~1;
2563 jboolean __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
2564 return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
2566 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
2567 LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg;
2568 CHECK(val->result_ok);
2569 LDKUnsignedChannelUpdate res_var = (*val->contents.result);
2570 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2571 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2572 long res_ref = (long)res_var.inner & ~1;
2575 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
2576 LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg;
2577 CHECK(!val->result_ok);
2578 LDKDecodeError err_var = (*val->contents.err);
2579 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2580 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2581 long err_ref = (long)err_var.inner & ~1;
2584 jboolean __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
2585 return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
2587 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
2588 LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)arg;
2589 CHECK(val->result_ok);
2590 LDKErrorMessage res_var = (*val->contents.result);
2591 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2592 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2593 long res_ref = (long)res_var.inner & ~1;
2596 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
2597 LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)arg;
2598 CHECK(!val->result_ok);
2599 LDKDecodeError err_var = (*val->contents.err);
2600 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2601 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2602 long err_ref = (long)err_var.inner & ~1;
2605 jboolean __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
2606 return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
2608 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
2609 LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg;
2610 CHECK(val->result_ok);
2611 LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
2612 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2613 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2614 long res_ref = (long)res_var.inner & ~1;
2617 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
2618 LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg;
2619 CHECK(!val->result_ok);
2620 LDKDecodeError err_var = (*val->contents.err);
2621 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2622 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2623 long err_ref = (long)err_var.inner & ~1;
2626 jboolean __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
2627 return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
2629 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
2630 LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg;
2631 CHECK(val->result_ok);
2632 LDKQueryShortChannelIds res_var = (*val->contents.result);
2633 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2634 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2635 long res_ref = (long)res_var.inner & ~1;
2638 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
2639 LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg;
2640 CHECK(!val->result_ok);
2641 LDKDecodeError err_var = (*val->contents.err);
2642 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2643 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2644 long err_ref = (long)err_var.inner & ~1;
2647 jboolean __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
2648 return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
2650 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
2651 LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg;
2652 CHECK(val->result_ok);
2653 LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
2654 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2655 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2656 long res_ref = (long)res_var.inner & ~1;
2659 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
2660 LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg;
2661 CHECK(!val->result_ok);
2662 LDKDecodeError err_var = (*val->contents.err);
2663 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2664 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2665 long err_ref = (long)err_var.inner & ~1;
2668 jboolean __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
2669 return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
2671 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
2672 LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)arg;
2673 CHECK(val->result_ok);
2674 LDKQueryChannelRange res_var = (*val->contents.result);
2675 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2676 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2677 long res_ref = (long)res_var.inner & ~1;
2680 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
2681 LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)arg;
2682 CHECK(!val->result_ok);
2683 LDKDecodeError err_var = (*val->contents.err);
2684 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2685 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2686 long err_ref = (long)err_var.inner & ~1;
2689 jboolean __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
2690 return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
2692 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
2693 LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg;
2694 CHECK(val->result_ok);
2695 LDKReplyChannelRange res_var = (*val->contents.result);
2696 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2697 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2698 long res_ref = (long)res_var.inner & ~1;
2701 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
2702 LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg;
2703 CHECK(!val->result_ok);
2704 LDKDecodeError err_var = (*val->contents.err);
2705 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2706 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2707 long err_ref = (long)err_var.inner & ~1;
2710 jboolean __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
2711 return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
2713 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
2714 LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg;
2715 CHECK(val->result_ok);
2716 LDKGossipTimestampFilter res_var = (*val->contents.result);
2717 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2718 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2719 long res_ref = (long)res_var.inner & ~1;
2722 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
2723 LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg;
2724 CHECK(!val->result_ok);
2725 LDKDecodeError err_var = (*val->contents.err);
2726 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2727 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2728 long err_ref = (long)err_var.inner & ~1;
2731 jboolean __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
2732 return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
2734 int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
2735 LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
2736 CHECK(val->result_ok);
2737 LDKCVec_u8Z res_var = (*val->contents.result);
2738 int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
2739 memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
2742 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
2743 LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg;
2744 CHECK(!val->result_ok);
2745 LDKPeerHandleError err_var = (*val->contents.err);
2746 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2747 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2748 long err_ref = (long)err_var.inner & ~1;
2751 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
2752 return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
2754 void __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
2755 LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
2756 CHECK(val->result_ok);
2757 return *val->contents.result;
2759 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
2760 LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)arg;
2761 CHECK(!val->result_ok);
2762 LDKPeerHandleError err_var = (*val->contents.err);
2763 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2764 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2765 long err_ref = (long)err_var.inner & ~1;
2768 jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
2769 return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
2771 jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
2772 LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
2773 CHECK(val->result_ok);
2774 return *val->contents.result;
2776 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
2777 LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)arg;
2778 CHECK(!val->result_ok);
2779 LDKPeerHandleError err_var = (*val->contents.err);
2780 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2781 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2782 long err_ref = (long)err_var.inner & ~1;
2785 jboolean __attribute__((visibility("default"))) TS_LDKCResult_SecretKeySecpErrorZ_result_ok(uint32_t arg) {
2786 return ((LDKCResult_SecretKeySecpErrorZ*)arg)->result_ok;
2788 int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_SecretKeySecpErrorZ_get_ok(uint32_t arg) {
2789 LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
2790 CHECK(val->result_ok);
2791 int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
2792 memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).bytes, 32);
2795 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SecretKeySecpErrorZ_get_err(uint32_t arg) {
2796 LDKCResult_SecretKeySecpErrorZ *val = (LDKCResult_SecretKeySecpErrorZ*)arg;
2797 CHECK(!val->result_ok);
2798 uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2801 jboolean __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_result_ok(uint32_t arg) {
2802 return ((LDKCResult_PublicKeySecpErrorZ*)arg)->result_ok;
2804 int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_get_ok(uint32_t arg) {
2805 LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
2806 CHECK(val->result_ok);
2807 int8_tArray res_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
2808 memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compressed_form, 33);
2811 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PublicKeySecpErrorZ_get_err(uint32_t arg) {
2812 LDKCResult_PublicKeySecpErrorZ *val = (LDKCResult_PublicKeySecpErrorZ*)arg;
2813 CHECK(!val->result_ok);
2814 uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2817 jboolean __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_result_ok(uint32_t arg) {
2818 return ((LDKCResult_TxCreationKeysSecpErrorZ*)arg)->result_ok;
2820 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_get_ok(uint32_t arg) {
2821 LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
2822 CHECK(val->result_ok);
2823 LDKTxCreationKeys res_var = (*val->contents.result);
2824 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2825 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2826 long res_ref = (long)res_var.inner & ~1;
2829 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_TxCreationKeysSecpErrorZ_get_err(uint32_t arg) {
2830 LDKCResult_TxCreationKeysSecpErrorZ *val = (LDKCResult_TxCreationKeysSecpErrorZ*)arg;
2831 CHECK(!val->result_ok);
2832 uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
2835 jboolean __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_result_ok(uint32_t arg) {
2836 return ((LDKCResult_TrustedCommitmentTransactionNoneZ*)arg)->result_ok;
2838 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_ok(uint32_t arg) {
2839 LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)arg;
2840 CHECK(val->result_ok);
2841 LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
2842 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2843 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2844 long res_ref = (long)res_var.inner & ~1;
2847 void __attribute__((visibility("default"))) TS_LDKCResult_TrustedCommitmentTransactionNoneZ_get_err(uint32_t arg) {
2848 LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)arg;
2849 CHECK(!val->result_ok);
2850 return *val->contents.err;
2852 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_RouteHopZ_new(uint32_tArray elems) {
2853 LDKCVec_RouteHopZ *ret = MALLOC(sizeof(LDKCVec_RouteHopZ), "LDKCVec_RouteHopZ");
2854 ret->datalen = *((uint32_t*)elems);
2855 if (ret->datalen == 0) {
2858 ret->data = MALLOC(sizeof(LDKRouteHop) * ret->datalen, "LDKCVec_RouteHopZ Data");
2859 uint32_t *java_elems = (uint32_t*)(elems + 4);
2860 for (size_t i = 0; i < ret->datalen; i++) {
2861 uint32_t arr_elem = java_elems[i];
2862 LDKRouteHop arr_elem_conv;
2863 arr_elem_conv.inner = (void*)(arr_elem & (~1));
2864 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2865 if (arr_elem_conv.inner != NULL)
2866 arr_elem_conv = RouteHop_clone(&arr_elem_conv);
2867 ret->data[i] = arr_elem_conv;
2872 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
2873 LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
2874 for (size_t i = 0; i < ret.datalen; i++) {
2875 ret.data[i] = RouteHop_clone(&orig->data[i]);
2879 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2880 LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2881 for (size_t i = 0; i < ret.datalen; i++) {
2882 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2886 jboolean __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_result_ok(uint32_t arg) {
2887 return ((LDKCResult_RouteDecodeErrorZ*)arg)->result_ok;
2889 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_ok(uint32_t arg) {
2890 LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)arg;
2891 CHECK(val->result_ok);
2892 LDKRoute res_var = (*val->contents.result);
2893 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2894 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2895 long res_ref = (long)res_var.inner & ~1;
2898 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RouteDecodeErrorZ_get_err(uint32_t arg) {
2899 LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)arg;
2900 CHECK(!val->result_ok);
2901 LDKDecodeError err_var = (*val->contents.err);
2902 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2903 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2904 long err_ref = (long)err_var.inner & ~1;
2907 uint32_t __attribute__((visibility("default"))) TS_LDKCVec_RouteHintZ_new(uint32_tArray elems) {
2908 LDKCVec_RouteHintZ *ret = MALLOC(sizeof(LDKCVec_RouteHintZ), "LDKCVec_RouteHintZ");
2909 ret->datalen = *((uint32_t*)elems);
2910 if (ret->datalen == 0) {
2913 ret->data = MALLOC(sizeof(LDKRouteHint) * ret->datalen, "LDKCVec_RouteHintZ Data");
2914 uint32_t *java_elems = (uint32_t*)(elems + 4);
2915 for (size_t i = 0; i < ret->datalen; i++) {
2916 uint32_t arr_elem = java_elems[i];
2917 LDKRouteHint arr_elem_conv;
2918 arr_elem_conv.inner = (void*)(arr_elem & (~1));
2919 arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
2920 if (arr_elem_conv.inner != NULL)
2921 arr_elem_conv = RouteHint_clone(&arr_elem_conv);
2922 ret->data[i] = arr_elem_conv;
2927 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2928 LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2929 for (size_t i = 0; i < ret.datalen; i++) {
2930 ret.data[i] = RouteHint_clone(&orig->data[i]);
2934 jboolean __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_result_ok(uint32_t arg) {
2935 return ((LDKCResult_RouteLightningErrorZ*)arg)->result_ok;
2937 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_ok(uint32_t arg) {
2938 LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
2939 CHECK(val->result_ok);
2940 LDKRoute res_var = (*val->contents.result);
2941 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2942 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2943 long res_ref = (long)res_var.inner & ~1;
2946 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RouteLightningErrorZ_get_err(uint32_t arg) {
2947 LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)arg;
2948 CHECK(!val->result_ok);
2949 LDKLightningError err_var = (*val->contents.err);
2950 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2951 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2952 long err_ref = (long)err_var.inner & ~1;
2955 jboolean __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
2956 return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
2958 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
2959 LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)arg;
2960 CHECK(val->result_ok);
2961 LDKRoutingFees res_var = (*val->contents.result);
2962 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2963 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2964 long res_ref = (long)res_var.inner & ~1;
2967 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
2968 LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)arg;
2969 CHECK(!val->result_ok);
2970 LDKDecodeError err_var = (*val->contents.err);
2971 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2972 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2973 long err_ref = (long)err_var.inner & ~1;
2976 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
2977 return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
2979 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
2980 LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg;
2981 CHECK(val->result_ok);
2982 LDKNodeAnnouncementInfo res_var = (*val->contents.result);
2983 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2984 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2985 long res_ref = (long)res_var.inner & ~1;
2988 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
2989 LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg;
2990 CHECK(!val->result_ok);
2991 LDKDecodeError err_var = (*val->contents.err);
2992 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2993 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2994 long err_ref = (long)err_var.inner & ~1;
2997 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
2998 return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
3000 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
3001 LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)arg;
3002 CHECK(val->result_ok);
3003 LDKNodeInfo res_var = (*val->contents.result);
3004 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3005 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3006 long res_ref = (long)res_var.inner & ~1;
3009 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
3010 LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)arg;
3011 CHECK(!val->result_ok);
3012 LDKDecodeError err_var = (*val->contents.err);
3013 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3014 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3015 long err_ref = (long)err_var.inner & ~1;
3018 jboolean __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
3019 return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
3021 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
3022 LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)arg;
3023 CHECK(val->result_ok);
3024 LDKNetworkGraph res_var = (*val->contents.result);
3025 CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3026 CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3027 long res_ref = (long)res_var.inner & ~1;
3030 uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
3031 LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)arg;
3032 CHECK(!val->result_ok);
3033 LDKDecodeError err_var = (*val->contents.err);
3034 CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3035 CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3036 long err_ref = (long)err_var.inner & ~1;
3039 typedef struct LDKMessageSendEventsProvider_JCalls {
3040 atomic_size_t refcnt;
3041 uint32_t get_and_clear_pending_msg_events_meth;
3042 } LDKMessageSendEventsProvider_JCalls;
3043 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
3044 LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3045 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3046 js_free(j_calls->get_and_clear_pending_msg_events_meth);
3050 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_jcall(const void* this_arg) {
3051 LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3052 uint32_tArray arg = js_invoke_function_0(j_calls->get_and_clear_pending_msg_events_meth);
3053 LDKCVec_MessageSendEventZ arg_constr;
3054 arg_constr.datalen = *((uint32_t*)arg);
3055 if (arg_constr.datalen > 0)
3056 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
3058 arg_constr.data = NULL;
3059 uint32_t* arg_vals = (uint32_t*)(arg + 4);
3060 for (size_t s = 0; s < arg_constr.datalen; s++) {
3061 uint32_t arr_conv_18 = arg_vals[s];
3062 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
3063 FREE((void*)arr_conv_18);
3064 arg_constr.data[s] = arr_conv_18_conv;
3068 static void* LDKMessageSendEventsProvider_JCalls_clone(const void* this_arg) {
3069 LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
3070 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3071 return (void*) this_arg;
3073 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3074 LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
3075 atomic_init(&calls->refcnt, 1);
3076 //TODO: Assign calls->o from o
3078 LDKMessageSendEventsProvider ret = {
3079 .this_arg = (void*) calls,
3080 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_jcall,
3081 .free = LDKMessageSendEventsProvider_JCalls_free,
3085 long __attribute__((visibility("default"))) TS_LDKMessageSendEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3086 LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
3087 *res_ptr = LDKMessageSendEventsProvider_init(o);
3088 return (long)res_ptr;
3090 uint32_tArray __attribute__((visibility("default"))) TS_MessageSendEventsProvider_get_and_clear_pending_msg_events(uint32_t this_arg) {
3091 LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg;
3092 LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
3093 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3094 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3095 for (size_t s = 0; s < ret_var.datalen; s++) {
3096 LDKMessageSendEvent *arr_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
3097 *arr_conv_18_copy = MessageSendEvent_clone(&ret_var.data[s]);
3098 long arr_conv_18_ref = (long)arr_conv_18_copy;
3099 ret_arr_ptr[s] = arr_conv_18_ref;
3105 typedef struct LDKEventsProvider_JCalls {
3106 atomic_size_t refcnt;
3107 uint32_t get_and_clear_pending_events_meth;
3108 } LDKEventsProvider_JCalls;
3109 static void LDKEventsProvider_JCalls_free(void* this_arg) {
3110 LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3111 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3112 js_free(j_calls->get_and_clear_pending_events_meth);
3116 LDKCVec_EventZ get_and_clear_pending_events_jcall(const void* this_arg) {
3117 LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3118 uint32_tArray arg = js_invoke_function_0(j_calls->get_and_clear_pending_events_meth);
3119 LDKCVec_EventZ arg_constr;
3120 arg_constr.datalen = *((uint32_t*)arg);
3121 if (arg_constr.datalen > 0)
3122 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
3124 arg_constr.data = NULL;
3125 uint32_t* arg_vals = (uint32_t*)(arg + 4);
3126 for (size_t h = 0; h < arg_constr.datalen; h++) {
3127 uint32_t arr_conv_7 = arg_vals[h];
3128 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
3129 FREE((void*)arr_conv_7);
3130 arg_constr.data[h] = arr_conv_7_conv;
3134 static void* LDKEventsProvider_JCalls_clone(const void* this_arg) {
3135 LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
3136 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3137 return (void*) this_arg;
3139 static inline LDKEventsProvider LDKEventsProvider_init (/*TODO: JS Object Reference */void* o) {
3140 LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
3141 atomic_init(&calls->refcnt, 1);
3142 //TODO: Assign calls->o from o
3144 LDKEventsProvider ret = {
3145 .this_arg = (void*) calls,
3146 .get_and_clear_pending_events = get_and_clear_pending_events_jcall,
3147 .free = LDKEventsProvider_JCalls_free,
3151 long __attribute__((visibility("default"))) TS_LDKEventsProvider_new(/*TODO: JS Object Reference */void* o) {
3152 LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
3153 *res_ptr = LDKEventsProvider_init(o);
3154 return (long)res_ptr;
3156 uint32_tArray __attribute__((visibility("default"))) TS_EventsProvider_get_and_clear_pending_events(uint32_t this_arg) {
3157 LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg;
3158 LDKCVec_EventZ ret_var = (this_arg_conv->get_and_clear_pending_events)(this_arg_conv->this_arg);
3159 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
3160 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
3161 for (size_t h = 0; h < ret_var.datalen; h++) {
3162 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
3163 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
3164 long arr_conv_7_ref = (long)arr_conv_7_copy;
3165 ret_arr_ptr[h] = arr_conv_7_ref;
3171 typedef struct LDKAccess_JCalls {
3172 atomic_size_t refcnt;
3173 uint32_t get_utxo_meth;
3175 static void LDKAccess_JCalls_free(void* this_arg) {
3176 LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3177 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3178 js_free(j_calls->get_utxo_meth);
3182 LDKCResult_TxOutAccessErrorZ get_utxo_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
3183 LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3184 int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3185 memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
3186 LDKCResult_TxOutAccessErrorZ* ret = (LDKCResult_TxOutAccessErrorZ*)js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
3187 LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)ret;
3191 static void* LDKAccess_JCalls_clone(const void* this_arg) {
3192 LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
3193 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3194 return (void*) this_arg;
3196 static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
3197 LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
3198 atomic_init(&calls->refcnt, 1);
3199 //TODO: Assign calls->o from o
3202 .this_arg = (void*) calls,
3203 .get_utxo = get_utxo_jcall,
3204 .free = LDKAccess_JCalls_free,
3208 long __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
3209 LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
3210 *res_ptr = LDKAccess_init(o);
3211 return (long)res_ptr;
3213 uint32_t __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
3214 LDKAccess* this_arg_conv = (LDKAccess*)this_arg;
3215 unsigned char genesis_hash_arr[32];
3216 CHECK(*((uint32_t*)genesis_hash) == 32);
3217 memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
3218 unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
3219 LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
3220 *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
3221 return (long)ret_conv;
3224 typedef struct LDKFilter_JCalls {
3225 atomic_size_t refcnt;
3226 uint32_t register_tx_meth;
3227 uint32_t register_output_meth;
3229 static void LDKFilter_JCalls_free(void* this_arg) {
3230 LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3231 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3232 js_free(j_calls->register_tx_meth);
3233 js_free(j_calls->register_output_meth);
3237 void register_tx_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
3238 LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3239 int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
3240 memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
3241 LDKu8slice script_pubkey_var = script_pubkey;
3242 int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3243 memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
3244 js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
3246 void register_output_jcall(const void* this_arg, const LDKOutPoint * outpoint, LDKu8slice script_pubkey) {
3247 LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3248 LDKOutPoint outpoint_var = *outpoint;
3249 if (outpoint->inner != NULL)
3250 outpoint_var = OutPoint_clone(outpoint);
3251 CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3252 CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3253 long outpoint_ref = (long)outpoint_var.inner;
3254 if (outpoint_var.is_owned) {
3257 LDKu8slice script_pubkey_var = script_pubkey;
3258 int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
3259 memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
3260 js_invoke_function_2(j_calls->register_output_meth, outpoint_ref, script_pubkey_arr);
3262 static void* LDKFilter_JCalls_clone(const void* this_arg) {
3263 LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
3264 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3265 return (void*) this_arg;
3267 static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
3268 LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
3269 atomic_init(&calls->refcnt, 1);
3270 //TODO: Assign calls->o from o
3273 .this_arg = (void*) calls,
3274 .register_tx = register_tx_jcall,
3275 .register_output = register_output_jcall,
3276 .free = LDKFilter_JCalls_free,
3280 long __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
3281 LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
3282 *res_ptr = LDKFilter_init(o);
3283 return (long)res_ptr;
3285 void __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
3286 LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
3287 unsigned char txid_arr[32];
3288 CHECK(*((uint32_t*)txid) == 32);
3289 memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
3290 unsigned char (*txid_ref)[32] = &txid_arr;
3291 LDKu8slice script_pubkey_ref;
3292 script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
3293 script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
3294 (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
3297 void __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t outpoint, int8_tArray script_pubkey) {
3298 LDKFilter* this_arg_conv = (LDKFilter*)this_arg;
3299 LDKOutPoint outpoint_conv;
3300 outpoint_conv.inner = (void*)(outpoint & (~1));
3301 outpoint_conv.is_owned = false;
3302 LDKu8slice script_pubkey_ref;
3303 script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
3304 script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
3305 (this_arg_conv->register_output)(this_arg_conv->this_arg, &outpoint_conv, script_pubkey_ref);
3308 typedef struct LDKPersist_JCalls {
3309 atomic_size_t refcnt;
3310 uint32_t persist_new_channel_meth;
3311 uint32_t update_persisted_channel_meth;
3312 } LDKPersist_JCalls;
3313 static void LDKPersist_JCalls_free(void* this_arg) {
3314 LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3315 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3316 js_free(j_calls->persist_new_channel_meth);
3317 js_free(j_calls->update_persisted_channel_meth);
3321 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitor * data) {
3322 LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3323 LDKOutPoint id_var = id;
3324 CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3325 CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3326 long id_ref = (long)id_var.inner;
3327 if (id_var.is_owned) {
3330 LDKChannelMonitor data_var = *data;
3331 // Warning: we may need a move here but can't clone!
3332 CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3333 CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3334 long data_ref = (long)data_var.inner;
3335 if (data_var.is_owned) {
3338 LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_2(j_calls->persist_new_channel_meth, id_ref, data_ref);
3339 LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
3343 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_jcall(const void* this_arg, LDKOutPoint id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data) {
3344 LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3345 LDKOutPoint id_var = id;
3346 CHECK((((long)id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3347 CHECK((((long)&id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3348 long id_ref = (long)id_var.inner;
3349 if (id_var.is_owned) {
3352 LDKChannelMonitorUpdate update_var = *update;
3353 if (update->inner != NULL)
3354 update_var = ChannelMonitorUpdate_clone(update);
3355 CHECK((((long)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3356 CHECK((((long)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3357 long update_ref = (long)update_var.inner;
3358 if (update_var.is_owned) {
3361 LDKChannelMonitor data_var = *data;
3362 // Warning: we may need a move here but can't clone!
3363 CHECK((((long)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3364 CHECK((((long)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3365 long data_ref = (long)data_var.inner;
3366 if (data_var.is_owned) {
3369 LDKCResult_NoneChannelMonitorUpdateErrZ* ret = (LDKCResult_NoneChannelMonitorUpdateErrZ*)js_invoke_function_3(j_calls->update_persisted_channel_meth, id_ref, update_ref, data_ref);
3370 LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)ret;
3374 static void* LDKPersist_JCalls_clone(const void* this_arg) {
3375 LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
3376 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3377 return (void*) this_arg;
3379 static inline LDKPersist LDKPersist_init (/*TODO: JS Object Reference */void* o) {
3380 LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
3381 atomic_init(&calls->refcnt, 1);
3382 //TODO: Assign calls->o from o
3385 .this_arg = (void*) calls,
3386 .persist_new_channel = persist_new_channel_jcall,
3387 .update_persisted_channel = update_persisted_channel_jcall,
3388 .free = LDKPersist_JCalls_free,
3392 long __attribute__((visibility("default"))) TS_LDKPersist_new(/*TODO: JS Object Reference */void* o) {
3393 LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
3394 *res_ptr = LDKPersist_init(o);
3395 return (long)res_ptr;
3397 uint32_t __attribute__((visibility("default"))) TS_Persist_persist_new_channel(uint32_t this_arg, uint32_t id, uint32_t data) {
3398 LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
3399 LDKOutPoint id_conv;
3400 id_conv.inner = (void*)(id & (~1));
3401 id_conv.is_owned = (id & 1) || (id == 0);
3402 if (id_conv.inner != NULL)
3403 id_conv = OutPoint_clone(&id_conv);
3404 LDKChannelMonitor data_conv;
3405 data_conv.inner = (void*)(data & (~1));
3406 data_conv.is_owned = false;
3407 LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3408 *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, id_conv, &data_conv);
3409 return (long)ret_conv;
3412 uint32_t __attribute__((visibility("default"))) TS_Persist_update_persisted_channel(uint32_t this_arg, uint32_t id, uint32_t update, uint32_t data) {
3413 LDKPersist* this_arg_conv = (LDKPersist*)this_arg;
3414 LDKOutPoint id_conv;
3415 id_conv.inner = (void*)(id & (~1));
3416 id_conv.is_owned = (id & 1) || (id == 0);
3417 if (id_conv.inner != NULL)
3418 id_conv = OutPoint_clone(&id_conv);
3419 LDKChannelMonitorUpdate update_conv;
3420 update_conv.inner = (void*)(update & (~1));
3421 update_conv.is_owned = false;
3422 LDKChannelMonitor data_conv;
3423 data_conv.inner = (void*)(data & (~1));
3424 data_conv.is_owned = false;
3425 LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
3426 *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, id_conv, &update_conv, &data_conv);
3427 return (long)ret_conv;
3430 typedef struct LDKChannelMessageHandler_JCalls {
3431 atomic_size_t refcnt;
3432 LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
3433 uint32_t handle_open_channel_meth;
3434 uint32_t handle_accept_channel_meth;
3435 uint32_t handle_funding_created_meth;
3436 uint32_t handle_funding_signed_meth;
3437 uint32_t handle_funding_locked_meth;
3438 uint32_t handle_shutdown_meth;
3439 uint32_t handle_closing_signed_meth;
3440 uint32_t handle_update_add_htlc_meth;
3441 uint32_t handle_update_fulfill_htlc_meth;
3442 uint32_t handle_update_fail_htlc_meth;
3443 uint32_t handle_update_fail_malformed_htlc_meth;
3444 uint32_t handle_commitment_signed_meth;
3445 uint32_t handle_revoke_and_ack_meth;
3446 uint32_t handle_update_fee_meth;
3447 uint32_t handle_announcement_signatures_meth;
3448 uint32_t peer_disconnected_meth;
3449 uint32_t peer_connected_meth;
3450 uint32_t handle_channel_reestablish_meth;
3451 uint32_t handle_error_meth;
3452 } LDKChannelMessageHandler_JCalls;
3453 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
3454 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3455 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3456 js_free(j_calls->handle_open_channel_meth);
3457 js_free(j_calls->handle_accept_channel_meth);
3458 js_free(j_calls->handle_funding_created_meth);
3459 js_free(j_calls->handle_funding_signed_meth);
3460 js_free(j_calls->handle_funding_locked_meth);
3461 js_free(j_calls->handle_shutdown_meth);
3462 js_free(j_calls->handle_closing_signed_meth);
3463 js_free(j_calls->handle_update_add_htlc_meth);
3464 js_free(j_calls->handle_update_fulfill_htlc_meth);
3465 js_free(j_calls->handle_update_fail_htlc_meth);
3466 js_free(j_calls->handle_update_fail_malformed_htlc_meth);
3467 js_free(j_calls->handle_commitment_signed_meth);
3468 js_free(j_calls->handle_revoke_and_ack_meth);
3469 js_free(j_calls->handle_update_fee_meth);
3470 js_free(j_calls->handle_announcement_signatures_meth);
3471 js_free(j_calls->peer_disconnected_meth);
3472 js_free(j_calls->peer_connected_meth);
3473 js_free(j_calls->handle_channel_reestablish_meth);
3474 js_free(j_calls->handle_error_meth);
3478 void handle_open_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
3479 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3480 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3481 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3482 LDKInitFeatures their_features_var = their_features;
3483 CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3484 CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3485 long their_features_ref = (long)their_features_var.inner;
3486 if (their_features_var.is_owned) {
3487 their_features_ref |= 1;
3489 LDKOpenChannel msg_var = *msg;
3490 if (msg->inner != NULL)
3491 msg_var = OpenChannel_clone(msg);
3492 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3493 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3494 long msg_ref = (long)msg_var.inner;
3495 if (msg_var.is_owned) {
3498 js_invoke_function_3(j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
3500 void handle_accept_channel_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
3501 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3502 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3503 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3504 LDKInitFeatures their_features_var = their_features;
3505 CHECK((((long)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3506 CHECK((((long)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3507 long their_features_ref = (long)their_features_var.inner;
3508 if (their_features_var.is_owned) {
3509 their_features_ref |= 1;
3511 LDKAcceptChannel msg_var = *msg;
3512 if (msg->inner != NULL)
3513 msg_var = AcceptChannel_clone(msg);
3514 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3515 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3516 long msg_ref = (long)msg_var.inner;
3517 if (msg_var.is_owned) {
3520 js_invoke_function_3(j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
3522 void handle_funding_created_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
3523 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3524 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3525 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3526 LDKFundingCreated msg_var = *msg;
3527 if (msg->inner != NULL)
3528 msg_var = FundingCreated_clone(msg);
3529 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3530 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3531 long msg_ref = (long)msg_var.inner;
3532 if (msg_var.is_owned) {
3535 js_invoke_function_2(j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
3537 void handle_funding_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
3538 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3539 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3540 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3541 LDKFundingSigned msg_var = *msg;
3542 if (msg->inner != NULL)
3543 msg_var = FundingSigned_clone(msg);
3544 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3545 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3546 long msg_ref = (long)msg_var.inner;
3547 if (msg_var.is_owned) {
3550 js_invoke_function_2(j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
3552 void handle_funding_locked_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
3553 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3554 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3555 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3556 LDKFundingLocked msg_var = *msg;
3557 if (msg->inner != NULL)
3558 msg_var = FundingLocked_clone(msg);
3559 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3560 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3561 long msg_ref = (long)msg_var.inner;
3562 if (msg_var.is_owned) {
3565 js_invoke_function_2(j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
3567 void handle_shutdown_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKShutdown * msg) {
3568 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3569 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3570 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3571 LDKShutdown msg_var = *msg;
3572 if (msg->inner != NULL)
3573 msg_var = Shutdown_clone(msg);
3574 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3575 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3576 long msg_ref = (long)msg_var.inner;
3577 if (msg_var.is_owned) {
3580 js_invoke_function_2(j_calls->handle_shutdown_meth, their_node_id_arr, msg_ref);
3582 void handle_closing_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
3583 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3584 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3585 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3586 LDKClosingSigned msg_var = *msg;
3587 if (msg->inner != NULL)
3588 msg_var = ClosingSigned_clone(msg);
3589 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3590 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3591 long msg_ref = (long)msg_var.inner;
3592 if (msg_var.is_owned) {
3595 js_invoke_function_2(j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
3597 void handle_update_add_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
3598 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3599 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3600 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3601 LDKUpdateAddHTLC msg_var = *msg;
3602 if (msg->inner != NULL)
3603 msg_var = UpdateAddHTLC_clone(msg);
3604 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3605 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3606 long msg_ref = (long)msg_var.inner;
3607 if (msg_var.is_owned) {
3610 js_invoke_function_2(j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
3612 void handle_update_fulfill_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
3613 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3614 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3615 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3616 LDKUpdateFulfillHTLC msg_var = *msg;
3617 if (msg->inner != NULL)
3618 msg_var = UpdateFulfillHTLC_clone(msg);
3619 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3620 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3621 long msg_ref = (long)msg_var.inner;
3622 if (msg_var.is_owned) {
3625 js_invoke_function_2(j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
3627 void handle_update_fail_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
3628 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3629 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3630 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3631 LDKUpdateFailHTLC msg_var = *msg;
3632 if (msg->inner != NULL)
3633 msg_var = UpdateFailHTLC_clone(msg);
3634 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3635 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3636 long msg_ref = (long)msg_var.inner;
3637 if (msg_var.is_owned) {
3640 js_invoke_function_2(j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
3642 void handle_update_fail_malformed_htlc_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
3643 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3644 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3645 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3646 LDKUpdateFailMalformedHTLC msg_var = *msg;
3647 if (msg->inner != NULL)
3648 msg_var = UpdateFailMalformedHTLC_clone(msg);
3649 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3650 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3651 long msg_ref = (long)msg_var.inner;
3652 if (msg_var.is_owned) {
3655 js_invoke_function_2(j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
3657 void handle_commitment_signed_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
3658 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3659 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3660 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3661 LDKCommitmentSigned msg_var = *msg;
3662 if (msg->inner != NULL)
3663 msg_var = CommitmentSigned_clone(msg);
3664 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3665 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3666 long msg_ref = (long)msg_var.inner;
3667 if (msg_var.is_owned) {
3670 js_invoke_function_2(j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
3672 void handle_revoke_and_ack_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
3673 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3674 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3675 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3676 LDKRevokeAndACK msg_var = *msg;
3677 if (msg->inner != NULL)
3678 msg_var = RevokeAndACK_clone(msg);
3679 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3680 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3681 long msg_ref = (long)msg_var.inner;
3682 if (msg_var.is_owned) {
3685 js_invoke_function_2(j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
3687 void handle_update_fee_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
3688 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3689 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3690 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3691 LDKUpdateFee msg_var = *msg;
3692 if (msg->inner != NULL)
3693 msg_var = UpdateFee_clone(msg);
3694 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3695 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3696 long msg_ref = (long)msg_var.inner;
3697 if (msg_var.is_owned) {
3700 js_invoke_function_2(j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
3702 void handle_announcement_signatures_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
3703 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3704 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3705 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3706 LDKAnnouncementSignatures msg_var = *msg;
3707 if (msg->inner != NULL)
3708 msg_var = AnnouncementSignatures_clone(msg);
3709 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3710 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3711 long msg_ref = (long)msg_var.inner;
3712 if (msg_var.is_owned) {
3715 js_invoke_function_2(j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
3717 void peer_disconnected_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
3718 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3719 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3720 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3721 js_invoke_function_2(j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
3723 void peer_connected_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
3724 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3725 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3726 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3727 LDKInit msg_var = *msg;
3728 if (msg->inner != NULL)
3729 msg_var = Init_clone(msg);
3730 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3731 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3732 long msg_ref = (long)msg_var.inner;
3733 if (msg_var.is_owned) {
3736 js_invoke_function_2(j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
3738 void handle_channel_reestablish_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
3739 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3740 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3741 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3742 LDKChannelReestablish msg_var = *msg;
3743 if (msg->inner != NULL)
3744 msg_var = ChannelReestablish_clone(msg);
3745 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3746 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3747 long msg_ref = (long)msg_var.inner;
3748 if (msg_var.is_owned) {
3751 js_invoke_function_2(j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
3753 void handle_error_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
3754 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3755 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
3756 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
3757 LDKErrorMessage msg_var = *msg;
3758 if (msg->inner != NULL)
3759 msg_var = ErrorMessage_clone(msg);
3760 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3761 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3762 long msg_ref = (long)msg_var.inner;
3763 if (msg_var.is_owned) {
3766 js_invoke_function_2(j_calls->handle_error_meth, their_node_id_arr, msg_ref);
3768 static void* LDKChannelMessageHandler_JCalls_clone(const void* this_arg) {
3769 LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
3770 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3771 atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
3772 return (void*) this_arg;
3774 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
3775 LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
3776 atomic_init(&calls->refcnt, 1);
3777 //TODO: Assign calls->o from o
3779 LDKChannelMessageHandler ret = {
3780 .this_arg = (void*) calls,
3781 .handle_open_channel = handle_open_channel_jcall,
3782 .handle_accept_channel = handle_accept_channel_jcall,
3783 .handle_funding_created = handle_funding_created_jcall,
3784 .handle_funding_signed = handle_funding_signed_jcall,
3785 .handle_funding_locked = handle_funding_locked_jcall,
3786 .handle_shutdown = handle_shutdown_jcall,
3787 .handle_closing_signed = handle_closing_signed_jcall,
3788 .handle_update_add_htlc = handle_update_add_htlc_jcall,
3789 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_jcall,
3790 .handle_update_fail_htlc = handle_update_fail_htlc_jcall,
3791 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_jcall,
3792 .handle_commitment_signed = handle_commitment_signed_jcall,
3793 .handle_revoke_and_ack = handle_revoke_and_ack_jcall,
3794 .handle_update_fee = handle_update_fee_jcall,
3795 .handle_announcement_signatures = handle_announcement_signatures_jcall,
3796 .peer_disconnected = peer_disconnected_jcall,
3797 .peer_connected = peer_connected_jcall,
3798 .handle_channel_reestablish = handle_channel_reestablish_jcall,
3799 .handle_error = handle_error_jcall,
3800 .free = LDKChannelMessageHandler_JCalls_free,
3801 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
3803 calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
3806 long __attribute__((visibility("default"))) TS_LDKChannelMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
3807 LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
3808 *res_ptr = LDKChannelMessageHandler_init(o, MessageSendEventsProvider);
3809 return (long)res_ptr;
3811 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_open_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
3812 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3813 LDKPublicKey their_node_id_ref;
3814 CHECK(*((uint32_t*)their_node_id) == 33);
3815 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3816 LDKInitFeatures their_features_conv;
3817 their_features_conv.inner = (void*)(their_features & (~1));
3818 their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3819 // Warning: we may need a move here but can't clone!
3820 LDKOpenChannel msg_conv;
3821 msg_conv.inner = (void*)(msg & (~1));
3822 msg_conv.is_owned = false;
3823 (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3826 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_accept_channel(uint32_t this_arg, int8_tArray their_node_id, uint32_t their_features, uint32_t msg) {
3827 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3828 LDKPublicKey their_node_id_ref;
3829 CHECK(*((uint32_t*)their_node_id) == 33);
3830 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3831 LDKInitFeatures their_features_conv;
3832 their_features_conv.inner = (void*)(their_features & (~1));
3833 their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
3834 // Warning: we may need a move here but can't clone!
3835 LDKAcceptChannel msg_conv;
3836 msg_conv.inner = (void*)(msg & (~1));
3837 msg_conv.is_owned = false;
3838 (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
3841 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_created(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3842 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3843 LDKPublicKey their_node_id_ref;
3844 CHECK(*((uint32_t*)their_node_id) == 33);
3845 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3846 LDKFundingCreated msg_conv;
3847 msg_conv.inner = (void*)(msg & (~1));
3848 msg_conv.is_owned = false;
3849 (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3852 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3853 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3854 LDKPublicKey their_node_id_ref;
3855 CHECK(*((uint32_t*)their_node_id) == 33);
3856 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3857 LDKFundingSigned msg_conv;
3858 msg_conv.inner = (void*)(msg & (~1));
3859 msg_conv.is_owned = false;
3860 (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3863 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_funding_locked(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3864 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3865 LDKPublicKey their_node_id_ref;
3866 CHECK(*((uint32_t*)their_node_id) == 33);
3867 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3868 LDKFundingLocked msg_conv;
3869 msg_conv.inner = (void*)(msg & (~1));
3870 msg_conv.is_owned = false;
3871 (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3874 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_shutdown(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3875 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3876 LDKPublicKey their_node_id_ref;
3877 CHECK(*((uint32_t*)their_node_id) == 33);
3878 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3879 LDKShutdown msg_conv;
3880 msg_conv.inner = (void*)(msg & (~1));
3881 msg_conv.is_owned = false;
3882 (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3885 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_closing_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3886 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3887 LDKPublicKey their_node_id_ref;
3888 CHECK(*((uint32_t*)their_node_id) == 33);
3889 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3890 LDKClosingSigned msg_conv;
3891 msg_conv.inner = (void*)(msg & (~1));
3892 msg_conv.is_owned = false;
3893 (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3896 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_add_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3897 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3898 LDKPublicKey their_node_id_ref;
3899 CHECK(*((uint32_t*)their_node_id) == 33);
3900 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3901 LDKUpdateAddHTLC msg_conv;
3902 msg_conv.inner = (void*)(msg & (~1));
3903 msg_conv.is_owned = false;
3904 (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3907 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fulfill_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3908 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3909 LDKPublicKey their_node_id_ref;
3910 CHECK(*((uint32_t*)their_node_id) == 33);
3911 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3912 LDKUpdateFulfillHTLC msg_conv;
3913 msg_conv.inner = (void*)(msg & (~1));
3914 msg_conv.is_owned = false;
3915 (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3918 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3919 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3920 LDKPublicKey their_node_id_ref;
3921 CHECK(*((uint32_t*)their_node_id) == 33);
3922 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3923 LDKUpdateFailHTLC msg_conv;
3924 msg_conv.inner = (void*)(msg & (~1));
3925 msg_conv.is_owned = false;
3926 (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3929 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fail_malformed_htlc(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3930 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3931 LDKPublicKey their_node_id_ref;
3932 CHECK(*((uint32_t*)their_node_id) == 33);
3933 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3934 LDKUpdateFailMalformedHTLC msg_conv;
3935 msg_conv.inner = (void*)(msg & (~1));
3936 msg_conv.is_owned = false;
3937 (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3940 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_commitment_signed(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3941 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3942 LDKPublicKey their_node_id_ref;
3943 CHECK(*((uint32_t*)their_node_id) == 33);
3944 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3945 LDKCommitmentSigned msg_conv;
3946 msg_conv.inner = (void*)(msg & (~1));
3947 msg_conv.is_owned = false;
3948 (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3951 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_revoke_and_ack(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3952 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3953 LDKPublicKey their_node_id_ref;
3954 CHECK(*((uint32_t*)their_node_id) == 33);
3955 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3956 LDKRevokeAndACK msg_conv;
3957 msg_conv.inner = (void*)(msg & (~1));
3958 msg_conv.is_owned = false;
3959 (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3962 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_update_fee(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3963 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3964 LDKPublicKey their_node_id_ref;
3965 CHECK(*((uint32_t*)their_node_id) == 33);
3966 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3967 LDKUpdateFee msg_conv;
3968 msg_conv.inner = (void*)(msg & (~1));
3969 msg_conv.is_owned = false;
3970 (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3973 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_announcement_signatures(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3974 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3975 LDKPublicKey their_node_id_ref;
3976 CHECK(*((uint32_t*)their_node_id) == 33);
3977 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3978 LDKAnnouncementSignatures msg_conv;
3979 msg_conv.inner = (void*)(msg & (~1));
3980 msg_conv.is_owned = false;
3981 (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
3984 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_disconnected(uint32_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
3985 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3986 LDKPublicKey their_node_id_ref;
3987 CHECK(*((uint32_t*)their_node_id) == 33);
3988 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3989 (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
3992 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_peer_connected(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
3993 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
3994 LDKPublicKey their_node_id_ref;
3995 CHECK(*((uint32_t*)their_node_id) == 33);
3996 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
3998 msg_conv.inner = (void*)(msg & (~1));
3999 msg_conv.is_owned = false;
4000 (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4003 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_channel_reestablish(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4004 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
4005 LDKPublicKey their_node_id_ref;
4006 CHECK(*((uint32_t*)their_node_id) == 33);
4007 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4008 LDKChannelReestablish msg_conv;
4009 msg_conv.inner = (void*)(msg & (~1));
4010 msg_conv.is_owned = false;
4011 (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4014 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_handle_error(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4015 LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg;
4016 LDKPublicKey their_node_id_ref;
4017 CHECK(*((uint32_t*)their_node_id) == 33);
4018 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4019 LDKErrorMessage msg_conv;
4020 msg_conv.inner = (void*)(msg & (~1));
4021 msg_conv.is_owned = false;
4022 (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
4025 typedef struct LDKRoutingMessageHandler_JCalls {
4026 atomic_size_t refcnt;
4027 LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
4028 uint32_t handle_node_announcement_meth;
4029 uint32_t handle_channel_announcement_meth;
4030 uint32_t handle_channel_update_meth;
4031 uint32_t handle_htlc_fail_channel_update_meth;
4032 uint32_t get_next_channel_announcements_meth;
4033 uint32_t get_next_node_announcements_meth;
4034 uint32_t sync_routing_table_meth;
4035 uint32_t handle_reply_channel_range_meth;
4036 uint32_t handle_reply_short_channel_ids_end_meth;
4037 uint32_t handle_query_channel_range_meth;
4038 uint32_t handle_query_short_channel_ids_meth;
4039 } LDKRoutingMessageHandler_JCalls;
4040 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
4041 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4042 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4043 js_free(j_calls->handle_node_announcement_meth);
4044 js_free(j_calls->handle_channel_announcement_meth);
4045 js_free(j_calls->handle_channel_update_meth);
4046 js_free(j_calls->handle_htlc_fail_channel_update_meth);
4047 js_free(j_calls->get_next_channel_announcements_meth);
4048 js_free(j_calls->get_next_node_announcements_meth);
4049 js_free(j_calls->sync_routing_table_meth);
4050 js_free(j_calls->handle_reply_channel_range_meth);
4051 js_free(j_calls->handle_reply_short_channel_ids_end_meth);
4052 js_free(j_calls->handle_query_channel_range_meth);
4053 js_free(j_calls->handle_query_short_channel_ids_meth);
4057 LDKCResult_boolLightningErrorZ handle_node_announcement_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
4058 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4059 LDKNodeAnnouncement msg_var = *msg;
4060 if (msg->inner != NULL)
4061 msg_var = NodeAnnouncement_clone(msg);
4062 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4063 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4064 long msg_ref = (long)msg_var.inner;
4065 if (msg_var.is_owned) {
4068 LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_node_announcement_meth, msg_ref);
4069 LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
4073 LDKCResult_boolLightningErrorZ handle_channel_announcement_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
4074 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4075 LDKChannelAnnouncement msg_var = *msg;
4076 if (msg->inner != NULL)
4077 msg_var = ChannelAnnouncement_clone(msg);
4078 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4079 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4080 long msg_ref = (long)msg_var.inner;
4081 if (msg_var.is_owned) {
4084 LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_announcement_meth, msg_ref);
4085 LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
4089 LDKCResult_boolLightningErrorZ handle_channel_update_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
4090 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4091 LDKChannelUpdate msg_var = *msg;
4092 if (msg->inner != NULL)
4093 msg_var = ChannelUpdate_clone(msg);
4094 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4095 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4096 long msg_ref = (long)msg_var.inner;
4097 if (msg_var.is_owned) {
4100 LDKCResult_boolLightningErrorZ* ret = (LDKCResult_boolLightningErrorZ*)js_invoke_function_1(j_calls->handle_channel_update_meth, msg_ref);
4101 LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)ret;
4105 void handle_htlc_fail_channel_update_jcall(const void* this_arg, const LDKHTLCFailChannelUpdate * update) {
4106 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4107 long ret_update = (long)update;
4108 js_invoke_function_1(j_calls->handle_htlc_fail_channel_update_meth, ret_update);
4110 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
4111 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4112 uint32_tArray arg = js_invoke_function_2(j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
4113 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ arg_constr;
4114 arg_constr.datalen = *((uint32_t*)arg);
4115 if (arg_constr.datalen > 0)
4116 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
4118 arg_constr.data = NULL;
4119 uint32_t* arg_vals = (uint32_t*)(arg + 4);
4120 for (size_t l = 0; l < arg_constr.datalen; l++) {
4121 uint32_t arr_conv_63 = arg_vals[l];
4122 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
4123 FREE((void*)arr_conv_63);
4124 arg_constr.data[l] = arr_conv_63_conv;
4128 LDKCVec_NodeAnnouncementZ get_next_node_announcements_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
4129 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4130 int8_tArray starting_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4131 memcpy((uint8_t*)(starting_point_arr + 4), starting_point.compressed_form, 33);
4132 uint32_tArray arg = js_invoke_function_2(j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
4133 LDKCVec_NodeAnnouncementZ arg_constr;
4134 arg_constr.datalen = *((uint32_t*)arg);
4135 if (arg_constr.datalen > 0)
4136 arg_constr.data = MALLOC(arg_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
4138 arg_constr.data = NULL;
4139 uint32_t* arg_vals = (uint32_t*)(arg + 4);
4140 for (size_t s = 0; s < arg_constr.datalen; s++) {
4141 uint32_t arr_conv_18 = arg_vals[s];
4142 LDKNodeAnnouncement arr_conv_18_conv;
4143 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
4144 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
4145 if (arr_conv_18_conv.inner != NULL)
4146 arr_conv_18_conv = NodeAnnouncement_clone(&arr_conv_18_conv);
4147 arg_constr.data[s] = arr_conv_18_conv;
4151 void sync_routing_table_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
4152 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4153 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4154 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4155 LDKInit init_var = *init;
4156 if (init->inner != NULL)
4157 init_var = Init_clone(init);
4158 CHECK((((long)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4159 CHECK((((long)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4160 long init_ref = (long)init_var.inner;
4161 if (init_var.is_owned) {
4164 js_invoke_function_2(j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
4166 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
4167 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4168 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4169 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4170 LDKReplyChannelRange msg_var = msg;
4171 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4172 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4173 long msg_ref = (long)msg_var.inner;
4174 if (msg_var.is_owned) {
4177 LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
4178 LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
4182 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
4183 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4184 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4185 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4186 LDKReplyShortChannelIdsEnd msg_var = msg;
4187 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4188 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4189 long msg_ref = (long)msg_var.inner;
4190 if (msg_var.is_owned) {
4193 LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
4194 LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
4198 LDKCResult_NoneLightningErrorZ handle_query_channel_range_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
4199 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4200 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4201 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4202 LDKQueryChannelRange msg_var = msg;
4203 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4204 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4205 long msg_ref = (long)msg_var.inner;
4206 if (msg_var.is_owned) {
4209 LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
4210 LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
4214 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
4215 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4216 int8_tArray their_node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
4217 memcpy((uint8_t*)(their_node_id_arr + 4), their_node_id.compressed_form, 33);
4218 LDKQueryShortChannelIds msg_var = msg;
4219 CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4220 CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4221 long msg_ref = (long)msg_var.inner;
4222 if (msg_var.is_owned) {
4225 LDKCResult_NoneLightningErrorZ* ret = (LDKCResult_NoneLightningErrorZ*)js_invoke_function_2(j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
4226 LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)ret;
4230 static void* LDKRoutingMessageHandler_JCalls_clone(const void* this_arg) {
4231 LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
4232 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4233 atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
4234 return (void*) this_arg;
4236 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* MessageSendEventsProvider) {
4237 LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
4238 atomic_init(&calls->refcnt, 1);
4239 //TODO: Assign calls->o from o
4241 LDKRoutingMessageHandler ret = {
4242 .this_arg = (void*) calls,
4243 .handle_node_announcement = handle_node_announcement_jcall,
4244 .handle_channel_announcement = handle_channel_announcement_jcall,
4245 .handle_channel_update = handle_channel_update_jcall,
4246 .handle_htlc_fail_channel_update = handle_htlc_fail_channel_update_jcall,
4247 .get_next_channel_announcements = get_next_channel_announcements_jcall,
4248 .get_next_node_announcements = get_next_node_announcements_jcall,
4249 .sync_routing_table = sync_routing_table_jcall,
4250 .handle_reply_channel_range = handle_reply_channel_range_jcall,
4251 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_jcall,
4252 .handle_query_channel_range = handle_query_channel_range_jcall,
4253 .handle_query_short_channel_ids = handle_query_short_channel_ids_jcall,
4254 .free = LDKRoutingMessageHandler_JCalls_free,
4255 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(MessageSendEventsProvider),
4257 calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
4260 long __attribute__((visibility("default"))) TS_LDKRoutingMessageHandler_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* MessageSendEventsProvider) {
4261 LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
4262 *res_ptr = LDKRoutingMessageHandler_init(o, MessageSendEventsProvider);
4263 return (long)res_ptr;
4265 uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_node_announcement(uint32_t this_arg, uint32_t msg) {
4266 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4267 LDKNodeAnnouncement msg_conv;
4268 msg_conv.inner = (void*)(msg & (~1));
4269 msg_conv.is_owned = false;
4270 LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4271 *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
4272 return (long)ret_conv;
4275 uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_announcement(uint32_t this_arg, uint32_t msg) {
4276 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4277 LDKChannelAnnouncement msg_conv;
4278 msg_conv.inner = (void*)(msg & (~1));
4279 msg_conv.is_owned = false;
4280 LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4281 *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
4282 return (long)ret_conv;
4285 uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_channel_update(uint32_t this_arg, uint32_t msg) {
4286 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4287 LDKChannelUpdate msg_conv;
4288 msg_conv.inner = (void*)(msg & (~1));
4289 msg_conv.is_owned = false;
4290 LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
4291 *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
4292 return (long)ret_conv;
4295 void __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_htlc_fail_channel_update(uint32_t this_arg, uint32_t update) {
4296 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4297 LDKHTLCFailChannelUpdate* update_conv = (LDKHTLCFailChannelUpdate*)update;
4298 (this_arg_conv->handle_htlc_fail_channel_update)(this_arg_conv->this_arg, update_conv);
4301 uint32_tArray __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_channel_announcements(uint32_t this_arg, int64_t starting_point, int8_t batch_amount) {
4302 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4303 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
4304 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4305 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4306 for (size_t l = 0; l < ret_var.datalen; l++) {
4307 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arr_conv_63_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4308 *arr_conv_63_ref = ret_var.data[l];
4309 arr_conv_63_ref->a = ChannelAnnouncement_clone(&arr_conv_63_ref->a);
4310 arr_conv_63_ref->b = ChannelUpdate_clone(&arr_conv_63_ref->b);
4311 arr_conv_63_ref->c = ChannelUpdate_clone(&arr_conv_63_ref->c);
4312 ret_arr_ptr[l] = (long)arr_conv_63_ref;
4318 uint32_tArray __attribute__((visibility("default"))) TS_RoutingMessageHandler_get_next_node_announcements(uint32_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
4319 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4320 LDKPublicKey starting_point_ref;
4321 CHECK(*((uint32_t*)starting_point) == 33);
4322 memcpy(starting_point_ref.compressed_form, (uint8_t*)(starting_point + 4), 33);
4323 LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
4324 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
4325 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
4326 for (size_t s = 0; s < ret_var.datalen; s++) {
4327 LDKNodeAnnouncement arr_conv_18_var = ret_var.data[s];
4328 CHECK((((long)arr_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4329 CHECK((((long)&arr_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4330 long arr_conv_18_ref = (long)arr_conv_18_var.inner;
4331 if (arr_conv_18_var.is_owned) {
4332 arr_conv_18_ref |= 1;
4334 ret_arr_ptr[s] = arr_conv_18_ref;
4340 void __attribute__((visibility("default"))) TS_RoutingMessageHandler_sync_routing_table(uint32_t this_arg, int8_tArray their_node_id, uint32_t init) {
4341 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4342 LDKPublicKey their_node_id_ref;
4343 CHECK(*((uint32_t*)their_node_id) == 33);
4344 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4346 init_conv.inner = (void*)(init & (~1));
4347 init_conv.is_owned = false;
4348 (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
4351 uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4352 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4353 LDKPublicKey their_node_id_ref;
4354 CHECK(*((uint32_t*)their_node_id) == 33);
4355 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4356 LDKReplyChannelRange msg_conv;
4357 msg_conv.inner = (void*)(msg & (~1));
4358 msg_conv.is_owned = (msg & 1) || (msg == 0);
4359 if (msg_conv.inner != NULL)
4360 msg_conv = ReplyChannelRange_clone(&msg_conv);
4361 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4362 *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4363 return (long)ret_conv;
4366 uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_reply_short_channel_ids_end(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4367 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4368 LDKPublicKey their_node_id_ref;
4369 CHECK(*((uint32_t*)their_node_id) == 33);
4370 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4371 LDKReplyShortChannelIdsEnd msg_conv;
4372 msg_conv.inner = (void*)(msg & (~1));
4373 msg_conv.is_owned = (msg & 1) || (msg == 0);
4374 if (msg_conv.inner != NULL)
4375 msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
4376 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4377 *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4378 return (long)ret_conv;
4381 uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_channel_range(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4382 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4383 LDKPublicKey their_node_id_ref;
4384 CHECK(*((uint32_t*)their_node_id) == 33);
4385 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4386 LDKQueryChannelRange msg_conv;
4387 msg_conv.inner = (void*)(msg & (~1));
4388 msg_conv.is_owned = (msg & 1) || (msg == 0);
4389 if (msg_conv.inner != NULL)
4390 msg_conv = QueryChannelRange_clone(&msg_conv);
4391 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4392 *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4393 return (long)ret_conv;
4396 uint32_t __attribute__((visibility("default"))) TS_RoutingMessageHandler_handle_query_short_channel_ids(uint32_t this_arg, int8_tArray their_node_id, uint32_t msg) {
4397 LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg;
4398 LDKPublicKey their_node_id_ref;
4399 CHECK(*((uint32_t*)their_node_id) == 33);
4400 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
4401 LDKQueryShortChannelIds msg_conv;
4402 msg_conv.inner = (void*)(msg & (~1));
4403 msg_conv.is_owned = (msg & 1) || (msg == 0);
4404 if (msg_conv.inner != NULL)
4405 msg_conv = QueryShortChannelIds_clone(&msg_conv);
4406 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
4407 *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
4408 return (long)ret_conv;
4411 typedef struct LDKSocketDescriptor_JCalls {
4412 atomic_size_t refcnt;
4413 uint32_t send_data_meth;
4414 uint32_t disconnect_socket_meth;
4417 } LDKSocketDescriptor_JCalls;
4418 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
4419 LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4420 if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4421 js_free(j_calls->send_data_meth);
4422 js_free(j_calls->disconnect_socket_meth);
4423 js_free(j_calls->eq_meth);
4424 js_free(j_calls->hash_meth);
4428 uintptr_t send_data_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
4429 LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4430 LDKu8slice data_var = data;
4431 int8_tArray data_arr = init_arr(data_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
4432 memcpy((uint8_t*)(data_arr + 4), data_var.data, data_var.datalen);
4433 return js_invoke_function_2(j_calls->send_data_meth, data_arr, resume_read);
4435 void disconnect_socket_jcall(void* this_arg) {
4436 LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4437 js_invoke_function_0(j_calls->disconnect_socket_meth);
4439 bool eq_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
4440 LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4441 LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
4442 *other_arg_clone = SocketDescriptor_clone(other_arg);
4443 return js_invoke_function_1(j_calls->eq_meth, (long)other_arg_clone);
4445 uint64_t hash_jcall(const void* this_arg) {
4446 LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4447 return js_invoke_function_0(j_calls->hash_meth);
4449 static void* LDKSocketDescriptor_JCalls_clone(const void* this_arg) {
4450 LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
4451 atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4452 return (void*) this_arg;
4454 static inline LDKSocketDescriptor LDKSocketDescriptor_init (/*TODO: JS Object Reference */void* o) {
4455 LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
4456 atomic_init(&calls->refcnt, 1);
4457 //TODO: Assign calls->o from o
4459 LDKSocketDescriptor ret = {
4460 .this_arg = (void*) calls,
4461 .send_data = send_data_jcall,
4462 .disconnect_socket = disconnect_socket_jcall,
4465 .clone = LDKSocketDescriptor_JCalls_clone,
4466 .free = LDKSocketDescriptor_JCalls_free,
4470 long __attribute__((visibility("default"))) TS_LDKSocketDescriptor_new(/*TODO: JS Object Reference */void* o) {
4471 LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
4472 *res_ptr = LDKSocketDescriptor_init(o);
4473 return (long)res_ptr;
4475 intptr_t __attribute__((visibility("default"))) TS_SocketDescriptor_send_data(uint32_t this_arg, int8_tArray data, jboolean resume_read) {
4476 LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4477 LDKu8slice data_ref;
4478 data_ref.datalen = *((uint32_t*)data);
4479 data_ref.data = (int8_t*)(data + 4);
4480 intptr_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
4484 void __attribute__((visibility("default"))) TS_SocketDescriptor_disconnect_socket(uint32_t this_arg) {
4485 LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4486 (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
4489 int64_t __attribute__((visibility("default"))) TS_SocketDescriptor_hash(uint32_t this_arg) {
4490 LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg;
4491 int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
4495 void __attribute__((visibility("default"))) TS_Transaction_free(int8_tArray _res) {
4496 LDKTransaction _res_ref;
4497 _res_ref.datalen = *((uint32_t*)_res);
4498 _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
4499 memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
4500 _res_ref.data_is_owned = true;
4501 Transaction_free(_res_ref);
4504 void __attribute__((visibility("default"))) TS_TxOut_free(uint32_t _res) {
4505 LDKTxOut _res_conv = *(LDKTxOut*)_res;
4507 TxOut_free(_res_conv);
4510 void __attribute__((visibility("default"))) TS_CVec_SpendableOutputDescriptorZ_free(uint32_tArray _res) {
4511 LDKCVec_SpendableOutputDescriptorZ _res_constr;
4512 _res_constr.datalen = *((uint32_t*)_res);
4513 if (_res_constr.datalen > 0)
4514 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
4516 _res_constr.data = NULL;
4517 uint32_t* _res_vals = (uint32_t*)(_res + 4);
4518 for (size_t b = 0; b < _res_constr.datalen; b++) {
4519 uint32_t arr_conv_27 = _res_vals[b];
4520 LDKSpendableOutputDescriptor arr_conv_27_conv = *(LDKSpendableOutputDescriptor*)arr_conv_27;
4521 FREE((void*)arr_conv_27);
4522 _res_constr.data[b] = arr_conv_27_conv;
4524 CVec_SpendableOutputDescriptorZ_free(_res_constr);
4527 void __attribute__((visibility("default"))) TS_CVec_MessageSendEventZ_free(uint32_tArray _res) {
4528 LDKCVec_MessageSendEventZ _res_constr;
4529 _res_constr.datalen = *((uint32_t*)_res);
4530 if (_res_constr.datalen > 0)
4531 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
4533 _res_constr.data = NULL;
4534 uint32_t* _res_vals = (uint32_t*)(_res + 4);
4535 for (size_t s = 0; s < _res_constr.datalen; s++) {
4536 uint32_t arr_conv_18 = _res_vals[s];
4537 LDKMessageSendEvent arr_conv_18_conv = *(LDKMessageSendEvent*)arr_conv_18;
4538 FREE((void*)arr_conv_18);
4539 _res_constr.data[s] = arr_conv_18_conv;
4541 CVec_MessageSendEventZ_free(_res_constr);
4544 void __attribute__((visibility("default"))) TS_CVec_EventZ_free(uint32_tArray _res) {
4545 LDKCVec_EventZ _res_constr;
4546 _res_constr.datalen = *((uint32_t*)_res);
4547 if (_res_constr.datalen > 0)
4548 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
4550 _res_constr.data = NULL;
4551 uint32_t* _res_vals = (uint32_t*)(_res + 4);
4552 for (size_t h = 0; h < _res_constr.datalen; h++) {
4553 uint32_t arr_conv_7 = _res_vals[h];
4554 LDKEvent arr_conv_7_conv = *(LDKEvent*)arr_conv_7;
4555 FREE((void*)arr_conv_7);
4556 _res_constr.data[h] = arr_conv_7_conv;
4558 CVec_EventZ_free(_res_constr);
4561 void __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_free(uint32_t _res) {
4562 LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)_res;
4564 C2Tuple_usizeTransactionZ_free(_res_conv);
4567 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_usizeTransactionZ_new(intptr_t a, int8_tArray b) {
4568 LDKTransaction b_ref;
4569 b_ref.datalen = *((uint32_t*)b);
4570 b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
4571 memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
4572 b_ref.data_is_owned = true;
4573 LDKC2Tuple_usizeTransactionZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
4574 *ret_ref = C2Tuple_usizeTransactionZ_new(a, b_ref);
4575 // XXX: We likely need to clone here, but no _clone fn is available for Uint8Array
4576 return (long)ret_ref;
4579 void __attribute__((visibility("default"))) TS_CVec_C2Tuple_usizeTransactionZZ_free(uint32_tArray _res) {
4580 LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
4581 _res_constr.datalen = *((uint32_t*)_res);
4582 if (_res_constr.datalen > 0)
4583 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
4585 _res_constr.data = NULL;
4586 uint32_t* _res_vals = (uint32_t*)(_res + 4);
4587 for (size_t e = 0; e < _res_constr.datalen; e++) {
4588 uint32_t arr_conv_30 = _res_vals[e];
4589 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_30;
4590 FREE((void*)arr_conv_30);
4591 _res_constr.data[e] = arr_conv_30_conv;
4593 CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
4596 uint32_t __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_ok() {
4597 LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4598 *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
4599 return (long)ret_conv;
4602 uint32_t __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_err(uint32_t e) {
4603 LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_js(e);
4604 LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4605 *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
4606 return (long)ret_conv;
4609 void __attribute__((visibility("default"))) TS_CResult_NoneChannelMonitorUpdateErrZ_free(uint32_t _res) {
4610 LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)_res;
4612 CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
4615 void __attribute__((visibility("default"))) TS_CVec_MonitorEventZ_free(uint32_tArray _res) {
4616 LDKCVec_MonitorEventZ _res_constr;
4617 _res_constr.datalen = *((uint32_t*)_res);
4618 if (_res_constr.datalen > 0)
4619 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4621 _res_constr.data = NULL;
4622 uint32_t* _res_vals = (uint32_t*)(_res + 4);
4623 for (size_t o = 0; o < _res_constr.datalen; o++) {
4624 uint32_t arr_conv_14 = _res_vals[o];
4625 LDKMonitorEvent arr_conv_14_conv;
4626 arr_conv_14_conv.inner = (void*)(arr_conv_14 & (~1));
4627 arr_conv_14_conv.is_owned = (arr_conv_14 & 1) || (arr_conv_14 == 0);
4628 _res_constr.data[o] = arr_conv_14_conv;
4630 CVec_MonitorEventZ_free(_res_constr);
4633 uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_ok(uint32_t o) {
4634 LDKChannelMonitorUpdate o_conv;
4635 o_conv.inner = (void*)(o & (~1));
4636 o_conv.is_owned = (o & 1) || (o == 0);
4637 if (o_conv.inner != NULL)
4638 o_conv = ChannelMonitorUpdate_clone(&o_conv);
4639 LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
4640 *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
4641 return (long)ret_conv;
4644 uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_err(uint32_t e) {
4645 LDKDecodeError e_conv;
4646 e_conv.inner = (void*)(e & (~1));
4647 e_conv.is_owned = (e & 1) || (e == 0);
4648 // Warning: we may need a move here but can't clone!
4649 LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
4650 *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
4651 return (long)ret_conv;
4654 void __attribute__((visibility("default"))) TS_CResult_ChannelMonitorUpdateDecodeErrorZ_free(uint32_t _res) {
4655 LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)_res;
4657 CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
4660 uint32_t __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_ok() {
4661 LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4662 *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
4663 return (long)ret_conv;
4666 uint32_t __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_err(uint32_t e) {
4667 LDKMonitorUpdateError e_conv;
4668 e_conv.inner = (void*)(e & (~1));
4669 e_conv.is_owned = (e & 1) || (e == 0);
4670 // Warning: we may need a move here but can't clone!
4671 LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
4672 *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
4673 return (long)ret_conv;
4676 void __attribute__((visibility("default"))) TS_CResult_NoneMonitorUpdateErrorZ_free(uint32_t _res) {
4677 LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)_res;
4679 CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
4682 void __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_free(uint32_t _res) {
4683 LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)_res;
4685 C2Tuple_OutPointScriptZ_free(_res_conv);
4688 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
4690 a_conv.inner = (void*)(a & (~1));
4691 a_conv.is_owned = (a & 1) || (a == 0);
4692 if (a_conv.inner != NULL)
4693 a_conv = OutPoint_clone(&a_conv);
4695 b_ref.datalen = *((uint32_t*)b);
4696 b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
4697 memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
4698 LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
4699 *ret_ref = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
4700 ret_ref->a = OutPoint_clone(&ret_ref->a);
4701 ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
4702 return (long)ret_ref;
4705 void __attribute__((visibility("default"))) TS_CVec_TransactionZ_free(ptrArray _res) {
4706 LDKCVec_TransactionZ _res_constr;
4707 _res_constr.datalen = *((uint32_t*)_res);
4708 if (_res_constr.datalen > 0)
4709 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
4711 _res_constr.data = NULL;
4712 int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
4713 for (size_t m = 0; m < _res_constr.datalen; m++) {
4714 int8_tArray arr_conv_12 = _res_vals[m];
4715 LDKTransaction arr_conv_12_ref;
4716 arr_conv_12_ref.datalen = *((uint32_t*)arr_conv_12);
4717 arr_conv_12_ref.data = MALLOC(arr_conv_12_ref.datalen, "LDKTransaction Bytes");
4718 memcpy(arr_conv_12_ref.data, (uint8_t*)(arr_conv_12 + 4), arr_conv_12_ref.datalen);
4719 arr_conv_12_ref.data_is_owned = true;
4720 _res_constr.data[m] = arr_conv_12_ref;
4722 CVec_TransactionZ_free(_res_constr);
4725 void __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_free(uint32_t _res) {
4726 LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)_res;
4728 C2Tuple_u32TxOutZ_free(_res_conv);
4731 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
4732 LDKTxOut b_conv = *(LDKTxOut*)b;
4734 LDKC2Tuple_u32TxOutZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
4735 *ret_ref = C2Tuple_u32TxOutZ_new(a, b_conv);
4736 // XXX: We likely need to clone here, but no _clone fn is available for TxOut
4737 return (long)ret_ref;
4740 void __attribute__((visibility("default"))) TS_CVec_C2Tuple_u32TxOutZZ_free(uint32_tArray _res) {
4741 LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
4742 _res_constr.datalen = *((uint32_t*)_res);
4743 if (_res_constr.datalen > 0)
4744 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4746 _res_constr.data = NULL;
4747 uint32_t* _res_vals = (uint32_t*)(_res + 4);
4748 for (size_t z = 0; z < _res_constr.datalen; z++) {
4749 uint32_t arr_conv_25 = _res_vals[z];
4750 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_25;
4751 FREE((void*)arr_conv_25);
4752 _res_constr.data[z] = arr_conv_25_conv;
4754 CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
4757 void __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(uint32_t _res) {
4758 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)_res;
4760 C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
4763 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
4764 LDKThirtyTwoBytes a_ref;
4765 CHECK(*((uint32_t*)a) == 32);
4766 memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
4767 LDKCVec_C2Tuple_u32TxOutZZ b_constr;
4768 b_constr.datalen = *((uint32_t*)b);
4769 if (b_constr.datalen > 0)
4770 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
4772 b_constr.data = NULL;
4773 uint32_t* b_vals = (uint32_t*)(b + 4);
4774 for (size_t z = 0; z < b_constr.datalen; z++) {
4775 uint32_t arr_conv_25 = b_vals[z];
4776 LDKC2Tuple_u32TxOutZ arr_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)arr_conv_25;
4777 FREE((void*)arr_conv_25);
4778 b_constr.data[z] = arr_conv_25_conv;
4780 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
4781 *ret_ref = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
4782 ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
4783 // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Number, TxOut>[]
4784 return (long)ret_ref;
4787 void __attribute__((visibility("default"))) TS_CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(uint32_tArray _res) {
4788 LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
4789 _res_constr.datalen = *((uint32_t*)_res);
4790 if (_res_constr.datalen > 0)
4791 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
4793 _res_constr.data = NULL;
4794 uint32_t* _res_vals = (uint32_t*)(_res + 4);
4795 for (size_t x = 0; x < _res_constr.datalen; x++) {
4796 uint32_t arr_conv_49 = _res_vals[x];
4797 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_conv_49_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)arr_conv_49;
4798 FREE((void*)arr_conv_49);
4799 _res_constr.data[x] = arr_conv_49_conv;
4801 CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
4804 void __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_free(uint32_t _res) {
4805 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)_res;
4807 C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
4810 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_new(int8_tArray a, uint32_t b) {
4811 LDKThirtyTwoBytes a_ref;
4812 CHECK(*((uint32_t*)a) == 32);
4813 memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
4814 LDKChannelMonitor b_conv;
4815 b_conv.inner = (void*)(b & (~1));
4816 b_conv.is_owned = (b & 1) || (b == 0);
4817 // Warning: we may need a move here but can't clone!
4818 LDKC2Tuple_BlockHashChannelMonitorZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
4819 *ret_ref = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
4820 ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
4821 // XXX: We likely need to clone here, but no _clone fn is available for ChannelMonitor
4822 return (long)ret_ref;
4825 uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(uint32_t o) {
4826 LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)o;
4828 LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
4829 *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
4830 return (long)ret_conv;
4833 uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(uint32_t e) {
4834 LDKDecodeError e_conv;
4835 e_conv.inner = (void*)(e & (~1));
4836 e_conv.is_owned = (e & 1) || (e == 0);
4837 // Warning: we may need a move here but can't clone!
4838 LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
4839 *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
4840 return (long)ret_conv;
4843 void __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(uint32_t _res) {
4844 LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)_res;
4846 CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
4849 void __attribute__((visibility("default"))) TS_C2Tuple_u64u64Z_free(uint32_t _res) {
4850 LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)_res;
4852 C2Tuple_u64u64Z_free(_res_conv);
4855 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_u64u64Z_new(int64_t a, int64_t b) {
4856 LDKC2Tuple_u64u64Z* ret_ref = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4857 *ret_ref = C2Tuple_u64u64Z_new(a, b);
4858 return (long)ret_ref;
4861 uint32_t __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_ok(uint32_t o) {
4862 LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)o;
4864 LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
4865 *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
4866 return (long)ret_conv;
4869 uint32_t __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_err(uint32_t e) {
4870 LDKDecodeError e_conv;
4871 e_conv.inner = (void*)(e & (~1));
4872 e_conv.is_owned = (e & 1) || (e == 0);
4873 // Warning: we may need a move here but can't clone!
4874 LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
4875 *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
4876 return (long)ret_conv;
4879 void __attribute__((visibility("default"))) TS_CResult_SpendableOutputDescriptorDecodeErrorZ_free(uint32_t _res) {
4880 LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)_res;
4882 CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
4885 void __attribute__((visibility("default"))) TS_CVec_SignatureZ_free(ptrArray _res) {
4886 LDKCVec_SignatureZ _res_constr;
4887 _res_constr.datalen = *((uint32_t*)_res);
4888 if (_res_constr.datalen > 0)
4889 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4891 _res_constr.data = NULL;
4892 int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
4893 for (size_t m = 0; m < _res_constr.datalen; m++) {
4894 int8_tArray arr_conv_12 = _res_vals[m];
4895 LDKSignature arr_conv_12_ref;
4896 CHECK(*((uint32_t*)arr_conv_12) == 64);
4897 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
4898 _res_constr.data[m] = arr_conv_12_ref;
4900 CVec_SignatureZ_free(_res_constr);
4903 void __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_free(uint32_t _res) {
4904 LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)_res;
4906 C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
4909 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
4911 CHECK(*((uint32_t*)a) == 64);
4912 memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
4913 LDKCVec_SignatureZ b_constr;
4914 b_constr.datalen = *((uint32_t*)b);
4915 if (b_constr.datalen > 0)
4916 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4918 b_constr.data = NULL;
4919 int8_tArray* b_vals = (int8_tArray*)(b + 4);
4920 for (size_t m = 0; m < b_constr.datalen; m++) {
4921 int8_tArray arr_conv_12 = b_vals[m];
4922 LDKSignature arr_conv_12_ref;
4923 CHECK(*((uint32_t*)arr_conv_12) == 64);
4924 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
4925 b_constr.data[m] = arr_conv_12_ref;
4927 LDKC2Tuple_SignatureCVec_SignatureZZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
4928 *ret_ref = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
4929 // XXX: We likely need to clone here, but no _clone fn is available for Uint8Array
4930 // XXX: We likely need to clone here, but no _clone fn is available for Uint8Array[]
4931 return (long)ret_ref;
4934 uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(uint32_t o) {
4935 LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)o;
4937 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4938 *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
4939 return (long)ret_conv;
4942 uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() {
4943 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
4944 *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
4945 return (long)ret_conv;
4948 void __attribute__((visibility("default"))) TS_CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(uint32_t _res) {
4949 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)_res;
4951 CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
4954 uint32_t __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_ok(int8_tArray o) {
4956 CHECK(*((uint32_t*)o) == 64);
4957 memcpy(o_ref.compact_form, (uint8_t*)(o + 4), 64);
4958 LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4959 *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
4960 return (long)ret_conv;
4963 uint32_t __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_err() {
4964 LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
4965 *ret_conv = CResult_SignatureNoneZ_err();
4966 return (long)ret_conv;
4969 void __attribute__((visibility("default"))) TS_CResult_SignatureNoneZ_free(uint32_t _res) {
4970 LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)_res;
4972 CResult_SignatureNoneZ_free(_res_conv);
4975 uint32_t __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_ok(ptrArray o) {
4976 LDKCVec_SignatureZ o_constr;
4977 o_constr.datalen = *((uint32_t*)o);
4978 if (o_constr.datalen > 0)
4979 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
4981 o_constr.data = NULL;
4982 int8_tArray* o_vals = (int8_tArray*)(o + 4);
4983 for (size_t m = 0; m < o_constr.datalen; m++) {
4984 int8_tArray arr_conv_12 = o_vals[m];
4985 LDKSignature arr_conv_12_ref;
4986 CHECK(*((uint32_t*)arr_conv_12) == 64);
4987 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
4988 o_constr.data[m] = arr_conv_12_ref;
4990 LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4991 *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
4992 return (long)ret_conv;
4995 uint32_t __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_err() {
4996 LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
4997 *ret_conv = CResult_CVec_SignatureZNoneZ_err();
4998 return (long)ret_conv;
5001 void __attribute__((visibility("default"))) TS_CResult_CVec_SignatureZNoneZ_free(uint32_t _res) {
5002 LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)_res;
5004 CResult_CVec_SignatureZNoneZ_free(_res_conv);
5007 uint32_t __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_ok(uint32_t o) {
5008 LDKChannelKeys o_conv = *(LDKChannelKeys*)o;
5009 LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
5010 *ret_conv = CResult_ChanKeySignerDecodeErrorZ_ok(o_conv);
5011 return (long)ret_conv;
5014 uint32_t __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_err(uint32_t e) {
5015 LDKDecodeError e_conv;
5016 e_conv.inner = (void*)(e & (~1));
5017 e_conv.is_owned = (e & 1) || (e == 0);
5018 // Warning: we may need a move here but can't clone!
5019 LDKCResult_ChanKeySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChanKeySignerDecodeErrorZ), "LDKCResult_ChanKeySignerDecodeErrorZ");
5020 *ret_conv = CResult_ChanKeySignerDecodeErrorZ_err(e_conv);
5021 return (long)ret_conv;
5024 void __attribute__((visibility("default"))) TS_CResult_ChanKeySignerDecodeErrorZ_free(uint32_t _res) {
5025 LDKCResult_ChanKeySignerDecodeErrorZ _res_conv = *(LDKCResult_ChanKeySignerDecodeErrorZ*)_res;
5027 CResult_ChanKeySignerDecodeErrorZ_free(_res_conv);
5030 uint32_t __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_ok(uint32_t o) {
5031 LDKInMemoryChannelKeys o_conv;
5032 o_conv.inner = (void*)(o & (~1));
5033 o_conv.is_owned = (o & 1) || (o == 0);
5034 if (o_conv.inner != NULL)
5035 o_conv = InMemoryChannelKeys_clone(&o_conv);
5036 LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
5037 *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_ok(o_conv);
5038 return (long)ret_conv;
5041 uint32_t __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_err(uint32_t e) {
5042 LDKDecodeError e_conv;
5043 e_conv.inner = (void*)(e & (~1));
5044 e_conv.is_owned = (e & 1) || (e == 0);
5045 // Warning: we may need a move here but can't clone!
5046 LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
5047 *ret_conv = CResult_InMemoryChannelKeysDecodeErrorZ_err(e_conv);
5048 return (long)ret_conv;
5051 void __attribute__((visibility("default"))) TS_CResult_InMemoryChannelKeysDecodeErrorZ_free(uint32_t _res) {
5052 LDKCResult_InMemoryChannelKeysDecodeErrorZ _res_conv = *(LDKCResult_InMemoryChannelKeysDecodeErrorZ*)_res;
5054 CResult_InMemoryChannelKeysDecodeErrorZ_free(_res_conv);
5057 uint32_t __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_ok(uint32_t o) {
5058 LDKTxOut o_conv = *(LDKTxOut*)o;
5060 LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
5061 *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
5062 return (long)ret_conv;
5065 uint32_t __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_err(uint32_t e) {
5066 LDKAccessError e_conv = LDKAccessError_from_js(e);
5067 LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
5068 *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
5069 return (long)ret_conv;
5072 void __attribute__((visibility("default"))) TS_CResult_TxOutAccessErrorZ_free(uint32_t _res) {
5073 LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)_res;
5075 CResult_TxOutAccessErrorZ_free(_res_conv);
5078 uint32_t __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_ok() {
5079 LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5080 *ret_conv = CResult_NoneAPIErrorZ_ok();
5081 return (long)ret_conv;
5084 uint32_t __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_err(uint32_t e) {
5085 LDKAPIError e_conv = *(LDKAPIError*)e;
5087 LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
5088 *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
5089 return (long)ret_conv;
5092 void __attribute__((visibility("default"))) TS_CResult_NoneAPIErrorZ_free(uint32_t _res) {
5093 LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)_res;
5095 CResult_NoneAPIErrorZ_free(_res_conv);
5098 void __attribute__((visibility("default"))) TS_CVec_ChannelDetailsZ_free(uint32_tArray _res) {
5099 LDKCVec_ChannelDetailsZ _res_constr;
5100 _res_constr.datalen = *((uint32_t*)_res);
5101 if (_res_constr.datalen > 0)
5102 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
5104 _res_constr.data = NULL;
5105 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5106 for (size_t q = 0; q < _res_constr.datalen; q++) {
5107 uint32_t arr_conv_16 = _res_vals[q];
5108 LDKChannelDetails arr_conv_16_conv;
5109 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5110 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5111 _res_constr.data[q] = arr_conv_16_conv;
5113 CVec_ChannelDetailsZ_free(_res_constr);
5116 uint32_t __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_ok() {
5117 LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5118 *ret_conv = CResult_NonePaymentSendFailureZ_ok();
5119 return (long)ret_conv;
5122 uint32_t __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_err(uint32_t e) {
5123 LDKPaymentSendFailure e_conv;
5124 e_conv.inner = (void*)(e & (~1));
5125 e_conv.is_owned = (e & 1) || (e == 0);
5126 // Warning: we may need a move here but can't clone!
5127 LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
5128 *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
5129 return (long)ret_conv;
5132 void __attribute__((visibility("default"))) TS_CResult_NonePaymentSendFailureZ_free(uint32_t _res) {
5133 LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)_res;
5135 CResult_NonePaymentSendFailureZ_free(_res_conv);
5138 void __attribute__((visibility("default"))) TS_CVec_NetAddressZ_free(uint32_tArray _res) {
5139 LDKCVec_NetAddressZ _res_constr;
5140 _res_constr.datalen = *((uint32_t*)_res);
5141 if (_res_constr.datalen > 0)
5142 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
5144 _res_constr.data = NULL;
5145 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5146 for (size_t m = 0; m < _res_constr.datalen; m++) {
5147 uint32_t arr_conv_12 = _res_vals[m];
5148 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
5149 FREE((void*)arr_conv_12);
5150 _res_constr.data[m] = arr_conv_12_conv;
5152 CVec_NetAddressZ_free(_res_constr);
5155 void __attribute__((visibility("default"))) TS_CVec_ChannelMonitorZ_free(uint32_tArray _res) {
5156 LDKCVec_ChannelMonitorZ _res_constr;
5157 _res_constr.datalen = *((uint32_t*)_res);
5158 if (_res_constr.datalen > 0)
5159 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
5161 _res_constr.data = NULL;
5162 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5163 for (size_t q = 0; q < _res_constr.datalen; q++) {
5164 uint32_t arr_conv_16 = _res_vals[q];
5165 LDKChannelMonitor arr_conv_16_conv;
5166 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5167 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5168 _res_constr.data[q] = arr_conv_16_conv;
5170 CVec_ChannelMonitorZ_free(_res_constr);
5173 void __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_free(uint32_t _res) {
5174 LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)_res;
5176 C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
5179 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_new(int8_tArray a, uint32_t b) {
5180 LDKThirtyTwoBytes a_ref;
5181 CHECK(*((uint32_t*)a) == 32);
5182 memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
5183 LDKChannelManager b_conv;
5184 b_conv.inner = (void*)(b & (~1));
5185 b_conv.is_owned = (b & 1) || (b == 0);
5186 // Warning: we may need a move here but can't clone!
5187 LDKC2Tuple_BlockHashChannelManagerZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
5188 *ret_ref = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
5189 ret_ref->a = ThirtyTwoBytes_clone(&ret_ref->a);
5190 // XXX: We likely need to clone here, but no _clone fn is available for ChannelManager
5191 return (long)ret_ref;
5194 uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(uint32_t o) {
5195 LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)o;
5197 LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
5198 *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
5199 return (long)ret_conv;
5202 uint32_t __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(uint32_t e) {
5203 LDKDecodeError e_conv;
5204 e_conv.inner = (void*)(e & (~1));
5205 e_conv.is_owned = (e & 1) || (e == 0);
5206 // Warning: we may need a move here but can't clone!
5207 LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
5208 *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
5209 return (long)ret_conv;
5212 void __attribute__((visibility("default"))) TS_CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(uint32_t _res) {
5213 LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)_res;
5215 CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
5218 uint32_t __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_ok(uint32_t o) {
5219 LDKNetAddress o_conv = *(LDKNetAddress*)o;
5221 LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5222 *ret_conv = CResult_NetAddressu8Z_ok(o_conv);
5223 return (long)ret_conv;
5226 uint32_t __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_err(int8_t e) {
5227 LDKCResult_NetAddressu8Z* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressu8Z), "LDKCResult_NetAddressu8Z");
5228 *ret_conv = CResult_NetAddressu8Z_err(e);
5229 return (long)ret_conv;
5232 void __attribute__((visibility("default"))) TS_CResult_NetAddressu8Z_free(uint32_t _res) {
5233 LDKCResult_NetAddressu8Z _res_conv = *(LDKCResult_NetAddressu8Z*)_res;
5235 CResult_NetAddressu8Z_free(_res_conv);
5238 uint32_t __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(uint32_t o) {
5239 LDKCResult_NetAddressu8Z o_conv = *(LDKCResult_NetAddressu8Z*)o;
5241 LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
5242 *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_ok(o_conv);
5243 return (long)ret_conv;
5246 uint32_t __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_err(uint32_t e) {
5247 LDKDecodeError e_conv;
5248 e_conv.inner = (void*)(e & (~1));
5249 e_conv.is_owned = (e & 1) || (e == 0);
5250 // Warning: we may need a move here but can't clone!
5251 LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
5252 *ret_conv = CResult_CResult_NetAddressu8ZDecodeErrorZ_err(e_conv);
5253 return (long)ret_conv;
5256 void __attribute__((visibility("default"))) TS_CResult_CResult_NetAddressu8ZDecodeErrorZ_free(uint32_t _res) {
5257 LDKCResult_CResult_NetAddressu8ZDecodeErrorZ _res_conv = *(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ*)_res;
5259 CResult_CResult_NetAddressu8ZDecodeErrorZ_free(_res_conv);
5262 void __attribute__((visibility("default"))) TS_CVec_u64Z_free(int64_tArray _res) {
5263 LDKCVec_u64Z _res_constr;
5264 _res_constr.datalen = *((uint32_t*)_res);
5265 if (_res_constr.datalen > 0)
5266 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
5268 _res_constr.data = NULL;
5269 int64_t* _res_vals = (int64_t*)(_res + 4);
5270 for (size_t i = 0; i < _res_constr.datalen; i++) {
5271 int64_t arr_conv_8 = _res_vals[i];
5272 _res_constr.data[i] = arr_conv_8;
5274 CVec_u64Z_free(_res_constr);
5277 void __attribute__((visibility("default"))) TS_CVec_UpdateAddHTLCZ_free(uint32_tArray _res) {
5278 LDKCVec_UpdateAddHTLCZ _res_constr;
5279 _res_constr.datalen = *((uint32_t*)_res);
5280 if (_res_constr.datalen > 0)
5281 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
5283 _res_constr.data = NULL;
5284 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5285 for (size_t p = 0; p < _res_constr.datalen; p++) {
5286 uint32_t arr_conv_15 = _res_vals[p];
5287 LDKUpdateAddHTLC arr_conv_15_conv;
5288 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
5289 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
5290 _res_constr.data[p] = arr_conv_15_conv;
5292 CVec_UpdateAddHTLCZ_free(_res_constr);
5295 void __attribute__((visibility("default"))) TS_CVec_UpdateFulfillHTLCZ_free(uint32_tArray _res) {
5296 LDKCVec_UpdateFulfillHTLCZ _res_constr;
5297 _res_constr.datalen = *((uint32_t*)_res);
5298 if (_res_constr.datalen > 0)
5299 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
5301 _res_constr.data = NULL;
5302 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5303 for (size_t t = 0; t < _res_constr.datalen; t++) {
5304 uint32_t arr_conv_19 = _res_vals[t];
5305 LDKUpdateFulfillHTLC arr_conv_19_conv;
5306 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
5307 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
5308 _res_constr.data[t] = arr_conv_19_conv;
5310 CVec_UpdateFulfillHTLCZ_free(_res_constr);
5313 void __attribute__((visibility("default"))) TS_CVec_UpdateFailHTLCZ_free(uint32_tArray _res) {
5314 LDKCVec_UpdateFailHTLCZ _res_constr;
5315 _res_constr.datalen = *((uint32_t*)_res);
5316 if (_res_constr.datalen > 0)
5317 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
5319 _res_constr.data = NULL;
5320 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5321 for (size_t q = 0; q < _res_constr.datalen; q++) {
5322 uint32_t arr_conv_16 = _res_vals[q];
5323 LDKUpdateFailHTLC arr_conv_16_conv;
5324 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
5325 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
5326 _res_constr.data[q] = arr_conv_16_conv;
5328 CVec_UpdateFailHTLCZ_free(_res_constr);
5331 void __attribute__((visibility("default"))) TS_CVec_UpdateFailMalformedHTLCZ_free(uint32_tArray _res) {
5332 LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
5333 _res_constr.datalen = *((uint32_t*)_res);
5334 if (_res_constr.datalen > 0)
5335 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
5337 _res_constr.data = NULL;
5338 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5339 for (size_t z = 0; z < _res_constr.datalen; z++) {
5340 uint32_t arr_conv_25 = _res_vals[z];
5341 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
5342 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
5343 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
5344 _res_constr.data[z] = arr_conv_25_conv;
5346 CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
5349 uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_ok(jboolean o) {
5350 LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5351 *ret_conv = CResult_boolLightningErrorZ_ok(o);
5352 return (long)ret_conv;
5355 uint32_t __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_err(uint32_t e) {
5356 LDKLightningError e_conv;
5357 e_conv.inner = (void*)(e & (~1));
5358 e_conv.is_owned = (e & 1) || (e == 0);
5359 // Warning: we may need a move here but can't clone!
5360 LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
5361 *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
5362 return (long)ret_conv;
5365 void __attribute__((visibility("default"))) TS_CResult_boolLightningErrorZ_free(uint32_t _res) {
5366 LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)_res;
5368 CResult_boolLightningErrorZ_free(_res_conv);
5371 void __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(uint32_t _res) {
5372 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)_res;
5374 C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
5377 uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(uint32_t a, uint32_t b, uint32_t c) {
5378 LDKChannelAnnouncement a_conv;
5379 a_conv.inner = (void*)(a & (~1));
5380 a_conv.is_owned = (a & 1) || (a == 0);
5381 if (a_conv.inner != NULL)
5382 a_conv = ChannelAnnouncement_clone(&a_conv);
5383 LDKChannelUpdate b_conv;
5384 b_conv.inner = (void*)(b & (~1));
5385 b_conv.is_owned = (b & 1) || (b == 0);
5386 if (b_conv.inner != NULL)
5387 b_conv = ChannelUpdate_clone(&b_conv);
5388 LDKChannelUpdate c_conv;
5389 c_conv.inner = (void*)(c & (~1));
5390 c_conv.is_owned = (c & 1) || (c == 0);
5391 if (c_conv.inner != NULL)
5392 c_conv = ChannelUpdate_clone(&c_conv);
5393 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_ref = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
5394 *ret_ref = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
5395 ret_ref->a = ChannelAnnouncement_clone(&ret_ref->a);
5396 ret_ref->b = ChannelUpdate_clone(&ret_ref->b);
5397 ret_ref->c = ChannelUpdate_clone(&ret_ref->c);
5398 return (long)ret_ref;
5401 void __attribute__((visibility("default"))) TS_CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(uint32_tArray _res) {
5402 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
5403 _res_constr.datalen = *((uint32_t*)_res);
5404 if (_res_constr.datalen > 0)
5405 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
5407 _res_constr.data = NULL;
5408 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5409 for (size_t l = 0; l < _res_constr.datalen; l++) {
5410 uint32_t arr_conv_63 = _res_vals[l];
5411 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_conv_63_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)arr_conv_63;
5412 FREE((void*)arr_conv_63);
5413 _res_constr.data[l] = arr_conv_63_conv;
5415 CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
5418 void __attribute__((visibility("default"))) TS_CVec_NodeAnnouncementZ_free(uint32_tArray _res) {
5419 LDKCVec_NodeAnnouncementZ _res_constr;
5420 _res_constr.datalen = *((uint32_t*)_res);
5421 if (_res_constr.datalen > 0)
5422 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
5424 _res_constr.data = NULL;
5425 uint32_t* _res_vals = (uint32_t*)(_res + 4);
5426 for (size_t s = 0; s < _res_constr.datalen; s++) {
5427 uint32_t arr_conv_18 = _res_vals[s];
5428 LDKNodeAnnouncement arr_conv_18_conv;
5429 arr_conv_18_conv.inner = (void*)(arr_conv_18 & (~1));
5430 arr_conv_18_conv.is_owned = (arr_conv_18 & 1) || (arr_conv_18 == 0);
5431 _res_constr.data[s] = arr_conv_18_conv;
5433 CVec_NodeAnnouncementZ_free(_res_constr);
5436 uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_ok() {
5437 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5438 *ret_conv = CResult_NoneLightningErrorZ_ok();
5439 return (long)ret_conv;
5442 uint32_t __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_err(uint32_t e) {
5443 LDKLightningError e_conv;
5444 e_conv.inner = (void*)(e & (~1));
5445 e_conv.is_owned = (e & 1) || (e == 0);
5446 // Warning: we may need a move here but can't clone!
5447 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
5448 *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
5449 return (long)ret_conv;
5452 void __attribute__((visibility("default"))) TS_CResult_NoneLightningErrorZ_free(uint32_t _res) {
5453 LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)_res;
5455 CResult_NoneLightningErrorZ_free(_res_conv);
5458 uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_ok(uint32_t o) {
5459 LDKChannelReestablish o_conv;
5460 o_conv.inner = (void*)(o & (~1));
5461 o_conv.is_owned = (o & 1) || (o == 0);
5462 if (o_conv.inner != NULL)
5463 o_conv = ChannelReestablish_clone(&o_conv);
5464 LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
5465 *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
5466 return (long)ret_conv;
5469 uint32_t __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_err(uint32_t e) {
5470 LDKDecodeError e_conv;
5471 e_conv.inner = (void*)(e & (~1));
5472 e_conv.is_owned = (e & 1) || (e == 0);
5473 // Warning: we may need a move here but can't clone!
5474 LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
5475 *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
5476 return (long)ret_conv;
5479 void __attribute__((visibility("default"))) TS_CResult_ChannelReestablishDecodeErrorZ_free(uint32_t _res) {
5480 LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)_res;
5482 CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
5485 uint32_t __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_ok(uint32_t o) {
5487 o_conv.inner = (void*)(o & (~1));
5488 o_conv.is_owned = (o & 1) || (o == 0);
5489 if (o_conv.inner != NULL)
5490 o_conv = Init_clone(&o_conv);
5491 LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
5492 *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
5493 return (long)ret_conv;
5496 uint32_t __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_err(uint32_t e) {
5497 LDKDecodeError e_conv;
5498 e_conv.inner = (void*)(e & (~1));
5499 e_conv.is_owned = (e & 1) || (e == 0);
5500 // Warning: we may need a move here but can't clone!
5501 LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
5502 *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
5503 return (long)ret_conv;
5506 void __attribute__((visibility("default"))) TS_CResult_InitDecodeErrorZ_free(uint32_t _res) {
5507 LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)_res;
5509 CResult_InitDecodeErrorZ_free(_res_conv);
5512 uint32_t __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_ok(uint32_t o) {
5514 o_conv.inner = (void*)(o & (~1));
5515 o_conv.is_owned = (o & 1) || (o == 0);
5516 if (o_conv.inner != NULL)
5517 o_conv = Ping_clone(&o_conv);
5518 LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
5519 *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
5520 return (long)ret_conv;
5523 uint32_t __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_err(uint32_t e) {
5524 LDKDecodeError e_conv;
5525 e_conv.inner = (void*)(e & (~1));
5526 e_conv.is_owned = (e & 1) || (e == 0);
5527 // Warning: we may need a move here but can't clone!
5528 LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
5529 *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
5530 return (long)ret_conv;
5533 void __attribute__((visibility("default"))) TS_CResult_PingDecodeErrorZ_free(uint32_t _res) {
5534 LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)_res;
5536 CResult_PingDecodeErrorZ_free(_res_conv);
5539 uint32_t __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_ok(uint32_t o) {
5541 o_conv.inner = (void*)(o & (~1));
5542 o_conv.is_owned = (o & 1) || (o == 0);
5543 if (o_conv.inner != NULL)
5544 o_conv = Pong_clone(&o_conv);
5545 LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
5546 *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
5547 return (long)ret_conv;
5550 uint32_t __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_err(uint32_t e) {
5551 LDKDecodeError e_conv;
5552 e_conv.inner = (void*)(e & (~1));
5553 e_conv.is_owned = (e & 1) || (e == 0);
5554 // Warning: we may need a move here but can't clone!
5555 LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
5556 *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
5557 return (long)ret_conv;
5560 void __attribute__((visibility("default"))) TS_CResult_PongDecodeErrorZ_free(uint32_t _res) {
5561 LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)_res;
5563 CResult_PongDecodeErrorZ_free(_res_conv);
5566 uint32_t __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(uint32_t o) {
5567 LDKUnsignedChannelAnnouncement o_conv;
5568 o_conv.inner = (void*)(o & (~1));
5569 o_conv.is_owned = (o & 1) || (o == 0);
5570 if (o_conv.inner != NULL)
5571 o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
5572 LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
5573 *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
5574 return (long)ret_conv;
5577 uint32_t __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(uint32_t e) {
5578 LDKDecodeError e_conv;
5579 e_conv.inner = (void*)(e & (~1));
5580 e_conv.is_owned = (e & 1) || (e == 0);
5581 // Warning: we may need a move here but can't clone!
5582 LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
5583 *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
5584 return (long)ret_conv;
5587 void __attribute__((visibility("default"))) TS_CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(uint32_t _res) {
5588 LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)_res;
5590 CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
5593 uint32_t __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_ok(uint32_t o) {
5594 LDKUnsignedChannelUpdate o_conv;
5595 o_conv.inner = (void*)(o & (~1));
5596 o_conv.is_owned = (o & 1) || (o == 0);
5597 if (o_conv.inner != NULL)
5598 o_conv = UnsignedChannelUpdate_clone(&o_conv);
5599 LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
5600 *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
5601 return (long)ret_conv;
5604 uint32_t __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_err(uint32_t e) {
5605 LDKDecodeError e_conv;
5606 e_conv.inner = (void*)(e & (~1));
5607 e_conv.is_owned = (e & 1) || (e == 0);
5608 // Warning: we may need a move here but can't clone!
5609 LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
5610 *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
5611 return (long)ret_conv;
5614 void __attribute__((visibility("default"))) TS_CResult_UnsignedChannelUpdateDecodeErrorZ_free(uint32_t _res) {
5615 LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)_res;
5617 CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
5620 uint32_t __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_ok(uint32_t o) {
5621 LDKErrorMessage o_conv;
5622 o_conv.inner = (void*)(o & (~1));
5623 o_conv.is_owned = (o & 1) || (o == 0);
5624 if (o_conv.inner != NULL)
5625 o_conv = ErrorMessage_clone(&o_conv);
5626 LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
5627 *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
5628 return (long)ret_conv;
5631 uint32_t __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_err(uint32_t e) {
5632 LDKDecodeError e_conv;
5633 e_conv.inner = (void*)(e & (~1));
5634 e_conv.is_owned = (e & 1) || (e == 0);
5635 // Warning: we may need a move here but can't clone!
5636 LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
5637 *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
5638 return (long)ret_conv;
5641 void __attribute__((visibility("default"))) TS_CResult_ErrorMessageDecodeErrorZ_free(uint32_t _res) {
5642 LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)_res;
5644 CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
5647 uint32_t __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(uint32_t o) {
5648 LDKUnsignedNodeAnnouncement o_conv;
5649 o_conv.inner = (void*)(o & (~1));
5650 o_conv.is_owned = (o & 1) || (o == 0);
5651 if (o_conv.inner != NULL)
5652 o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
5653 LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
5654 *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
5655 return (long)ret_conv;
5658 uint32_t __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(uint32_t e) {
5659 LDKDecodeError e_conv;
5660 e_conv.inner = (void*)(e & (~1));
5661 e_conv.is_owned = (e & 1) || (e == 0);
5662 // Warning: we may need a move here but can't clone!
5663 LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
5664 *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
5665 return (long)ret_conv;
5668 void __attribute__((visibility("default"))) TS_CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(uint32_t _res) {
5669 LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)_res;
5671 CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
5674 uint32_t __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_ok(uint32_t o) {
5675 LDKQueryShortChannelIds o_conv;
5676 o_conv.inner = (void*)(o & (~1));
5677 o_conv.is_owned = (o & 1) || (o == 0);
5678 if (o_conv.inner != NULL)
5679 o_conv = QueryShortChannelIds_clone(&o_conv);
5680 LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
5681 *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
5682 return (long)ret_conv;
5685 uint32_t __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_err(uint32_t e) {
5686 LDKDecodeError e_conv;
5687 e_conv.inner = (void*)(e & (~1));
5688 e_conv.is_owned = (e & 1) || (e == 0);
5689 // Warning: we may need a move here but can't clone!
5690 LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
5691 *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
5692 return (long)ret_conv;
5695 void __attribute__((visibility("default"))) TS_CResult_QueryShortChannelIdsDecodeErrorZ_free(uint32_t _res) {
5696 LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)_res;
5698 CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
5701 uint32_t __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(uint32_t o) {
5702 LDKReplyShortChannelIdsEnd o_conv;
5703 o_conv.inner = (void*)(o & (~1));
5704 o_conv.is_owned = (o & 1) || (o == 0);
5705 if (o_conv.inner != NULL)
5706 o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
5707 LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
5708 *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
5709 return (long)ret_conv;
5712 uint32_t __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(uint32_t e) {
5713 LDKDecodeError e_conv;
5714 e_conv.inner = (void*)(e & (~1));
5715 e_conv.is_owned = (e & 1) || (e == 0);
5716 // Warning: we may need a move here but can't clone!
5717 LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
5718 *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
5719 return (long)ret_conv;
5722 void __attribute__((visibility("default"))) TS_CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(uint32_t _res) {
5723 LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)_res;
5725 CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
5728 uint32_t __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_ok(uint32_t o) {
5729 LDKQueryChannelRange o_conv;
5730 o_conv.inner = (void*)(o & (~1));
5731 o_conv.is_owned = (o & 1) || (o == 0);
5732 if (o_conv.inner != NULL)
5733 o_conv = QueryChannelRange_clone(&o_conv);
5734 LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
5735 *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
5736 return (long)ret_conv;
5739 uint32_t __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_err(uint32_t e) {
5740 LDKDecodeError e_conv;
5741 e_conv.inner = (void*)(e & (~1));
5742 e_conv.is_owned = (e & 1) || (e == 0);
5743 // Warning: we may need a move here but can't clone!
5744 LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
5745 *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
5746 return (long)ret_conv;
5749 void __attribute__((visibility("default"))) TS_CResult_QueryChannelRangeDecodeErrorZ_free(uint32_t _res) {
5750 LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)_res;
5752 CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
5755 uint32_t __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_ok(uint32_t o) {
5756 LDKReplyChannelRange o_conv;
5757 o_conv.inner = (void*)(o & (~1));
5758 o_conv.is_owned = (o & 1) || (o == 0);
5759 if (o_conv.inner != NULL)
5760 o_conv = ReplyChannelRange_clone(&o_conv);
5761 LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
5762 *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
5763 return (long)ret_conv;
5766 uint32_t __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_err(uint32_t e) {
5767 LDKDecodeError e_conv;
5768 e_conv.inner = (void*)(e & (~1));
5769 e_conv.is_owned = (e & 1) || (e == 0);
5770 // Warning: we may need a move here but can't clone!
5771 LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
5772 *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
5773 return (long)ret_conv;
5776 void __attribute__((visibility("default"))) TS_CResult_ReplyChannelRangeDecodeErrorZ_free(uint32_t _res) {
5777 LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)_res;
5779 CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
5782 uint32_t __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_ok(uint32_t o) {
5783 LDKGossipTimestampFilter o_conv;
5784 o_conv.inner = (void*)(o & (~1));
5785 o_conv.is_owned = (o & 1) || (o == 0);
5786 if (o_conv.inner != NULL)
5787 o_conv = GossipTimestampFilter_clone(&o_conv);
5788 LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
5789 *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
5790 return (long)ret_conv;
5793 uint32_t __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_err(uint32_t e) {
5794 LDKDecodeError e_conv;
5795 e_conv.inner = (void*)(e & (~1));
5796 e_conv.is_owned = (e & 1) || (e == 0);
5797 // Warning: we may need a move here but can't clone!
5798 LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
5799 *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
5800 return (long)ret_conv;
5803 void __attribute__((visibility("default"))) TS_CResult_GossipTimestampFilterDecodeErrorZ_free(uint32_t _res) {
5804 LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)_res;
5806 CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
5809 void __attribute__((visibility("default"))) TS_CVec_PublicKeyZ_free(ptrArray _res) {
5810 LDKCVec_PublicKeyZ _res_constr;
5811 _res_constr.datalen = *((uint32_t*)_res);
5812 if (_res_constr.datalen > 0)
5813 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
5815 _res_constr.data = NULL;
5816 int8_tArray* _res_vals = (int8_tArray*)(_res + 4);
5817 for (size_t m = 0; m < _res_constr.datalen; m++) {
5818 int8_tArray arr_conv_12 = _res_vals[m];
5819 LDKPublicKey arr_conv_12_ref;
5820 CHECK(*((uint32_t*)arr_conv_12) == 33);
5821 memcpy(arr_conv_12_ref.compressed_form, (uint8_t*)(arr_conv_12 + 4), 33);
5822 _res_constr.data[m] = arr_conv_12_ref;
5824 CVec_PublicKeyZ_free(_res_constr);
5827 void __attribute__((visibility("default"))) TS_CVec_u8Z_free(int8_tArray _res) {
5828 LDKCVec_u8Z _res_ref;
5829 _res_ref.datalen = *((uint32_t*)_res);
5830 _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
5831 memcpy(_res_ref.data, (uint8_t*)(_res + 4), _res_ref.datalen);
5832 CVec_u8Z_free(_res_ref);
5835 uint32_t __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_ok(int8_tArray o) {
5837 o_ref.datalen = *((uint32_t*)o);
5838 o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
5839 memcpy(o_ref.data, (uint8_t*)(o + 4), o_ref.datalen);
5840 LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5841 *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
5842 return (long)ret_conv;
5845 uint32_t __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_err(uint32_t e) {
5846 LDKPeerHandleError e_conv;
5847 e_conv.inner = (void*)(e & (~1));
5848 e_conv.is_owned = (e & 1) || (e == 0);
5849 // Warning: we may need a move here but can't clone!
5850 LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
5851 *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
5852 return (long)ret_conv;
5855 void __attribute__((visibility("default"))) TS_CResult_CVec_u8ZPeerHandleErrorZ_free(uint32_t _res) {
5856 LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)_res;
5858 CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
5861 uint32_t __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_ok() {
5862 LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5863 *ret_conv = CResult_NonePeerHandleErrorZ_ok();
5864 return (long)ret_conv;
5867 uint32_t __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_err(uint32_t e) {
5868 LDKPeerHandleError e_conv;
5869 e_conv.inner = (void*)(e & (~1));
5870 e_conv.is_owned = (e & 1) || (e == 0);
5871 // Warning: we may need a move here but can't clone!
5872 LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
5873 *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
5874 return (long)ret_conv;
5877 void __attribute__((visibility("default"))) TS_CResult_NonePeerHandleErrorZ_free(uint32_t _res) {
5878 LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)_res;
5880 CResult_NonePeerHandleErrorZ_free(_res_conv);
5883 uint32_t __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_ok(jboolean o) {
5884 LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5885 *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
5886 return (long)ret_conv;
5889 uint32_t __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_err(uint32_t e) {
5890 LDKPeerHandleError e_conv;
5891 e_conv.inner = (void*)(e & (~1));
5892 e_conv.is_owned = (e & 1) || (e == 0);
5893 // Warning: we may need a move here but can't clone!
5894 LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
5895 *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
5896 return (long)ret_conv;
5899 void __attribute__((visibility("default"))) TS_CResult_boolPeerHandleErrorZ_free(uint32_t _res) {
5900 LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)_res;
5902 CResult_boolPeerHandleErrorZ_free(_res_conv);
5905 uint32_t __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_ok(int8_tArray o) {
5907 CHECK(*((uint32_t*)o) == 32);
5908 memcpy(o_ref.bytes, (uint8_t*)(o + 4), 32);
5909 LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
5910 *ret_conv = CResult_SecretKeySecpErrorZ_ok(o_ref);
5911 return (long)ret_conv;
5914 uint32_t __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_err(uint32_t e) {
5915 LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5916 LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
5917 *ret_conv = CResult_SecretKeySecpErrorZ_err(e_conv);
5918 return (long)ret_conv;
5921 void __attribute__((visibility("default"))) TS_CResult_SecretKeySecpErrorZ_free(uint32_t _res) {
5922 LDKCResult_SecretKeySecpErrorZ _res_conv = *(LDKCResult_SecretKeySecpErrorZ*)_res;
5924 CResult_SecretKeySecpErrorZ_free(_res_conv);
5927 uint32_t __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_ok(int8_tArray o) {
5929 CHECK(*((uint32_t*)o) == 33);
5930 memcpy(o_ref.compressed_form, (uint8_t*)(o + 4), 33);
5931 LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
5932 *ret_conv = CResult_PublicKeySecpErrorZ_ok(o_ref);
5933 return (long)ret_conv;
5936 uint32_t __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_err(uint32_t e) {
5937 LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5938 LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
5939 *ret_conv = CResult_PublicKeySecpErrorZ_err(e_conv);
5940 return (long)ret_conv;
5943 void __attribute__((visibility("default"))) TS_CResult_PublicKeySecpErrorZ_free(uint32_t _res) {
5944 LDKCResult_PublicKeySecpErrorZ _res_conv = *(LDKCResult_PublicKeySecpErrorZ*)_res;
5946 CResult_PublicKeySecpErrorZ_free(_res_conv);
5949 uint32_t __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_ok(uint32_t o) {
5950 LDKTxCreationKeys o_conv;
5951 o_conv.inner = (void*)(o & (~1));
5952 o_conv.is_owned = (o & 1) || (o == 0);
5953 if (o_conv.inner != NULL)
5954 o_conv = TxCreationKeys_clone(&o_conv);
5955 LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
5956 *ret_conv = CResult_TxCreationKeysSecpErrorZ_ok(o_conv);
5957 return (long)ret_conv;
5960 uint32_t __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_err(uint32_t e) {
5961 LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_js(e);
5962 LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
5963 *ret_conv = CResult_TxCreationKeysSecpErrorZ_err(e_conv);
5964 return (long)ret_conv;
5967 void __attribute__((visibility("default"))) TS_CResult_TxCreationKeysSecpErrorZ_free(uint32_t _res) {
5968 LDKCResult_TxCreationKeysSecpErrorZ _res_conv = *(LDKCResult_TxCreationKeysSecpErrorZ*)_res;
5970 CResult_TxCreationKeysSecpErrorZ_free(_res_conv);
5973 uint32_t __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_ok(uint32_t o) {
5974 LDKTrustedCommitmentTransaction o_conv;
5975 o_conv.inner = (void*)(o & (~1));
5976 o_conv.is_owned = (o & 1) || (o == 0);
5977 // Warning: we may need a move here but can't clone!
5978 LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5979 *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
5980 return (long)ret_conv;
5983 uint32_t __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_err() {
5984 LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
5985 *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
5986 return (long)ret_conv;
5989 void __attribute__((visibility("default"))) TS_CResult_TrustedCommitmentTransactionNoneZ_free(uint32_t _res) {
5990 LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)_res;
5992 CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
5995 void __attribute__((visibility("default"))) TS_CVec_RouteHopZ_free(uint32_tArray _res) {
5996 LDKCVec_RouteHopZ _res_constr;
5997 _res_constr.datalen = *((uint32_t*)_res);
5998 if (_res_constr.datalen > 0)
5999 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6001 _res_constr.data = NULL;
6002 uint32_t* _res_vals = (uint32_t*)(_res + 4);
6003 for (size_t k = 0; k < _res_constr.datalen; k++) {
6004 uint32_t arr_conv_10 = _res_vals[k];
6005 LDKRouteHop arr_conv_10_conv;
6006 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
6007 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
6008 _res_constr.data[k] = arr_conv_10_conv;
6010 CVec_RouteHopZ_free(_res_constr);
6013 void __attribute__((visibility("default"))) TS_CVec_CVec_RouteHopZZ_free(ptrArray _res) {
6014 LDKCVec_CVec_RouteHopZZ _res_constr;
6015 _res_constr.datalen = *((uint32_t*)_res);
6016 if (_res_constr.datalen > 0)
6017 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
6019 _res_constr.data = NULL;
6020 uint32_tArray* _res_vals = (uint32_tArray*)(_res + 4);
6021 for (size_t m = 0; m < _res_constr.datalen; m++) {
6022 uint32_tArray arr_conv_12 = _res_vals[m];
6023 LDKCVec_RouteHopZ arr_conv_12_constr;
6024 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
6025 if (arr_conv_12_constr.datalen > 0)
6026 arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
6028 arr_conv_12_constr.data = NULL;
6029 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
6030 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
6031 uint32_t arr_conv_10 = arr_conv_12_vals[k];
6032 LDKRouteHop arr_conv_10_conv;
6033 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
6034 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
6035 arr_conv_12_constr.data[k] = arr_conv_10_conv;
6037 _res_constr.data[m] = arr_conv_12_constr;
6039 CVec_CVec_RouteHopZZ_free(_res_constr);
6042 uint32_t __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_ok(uint32_t o) {
6044 o_conv.inner = (void*)(o & (~1));
6045 o_conv.is_owned = (o & 1) || (o == 0);
6046 if (o_conv.inner != NULL)
6047 o_conv = Route_clone(&o_conv);
6048 LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
6049 *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
6050 return (long)ret_conv;
6053 uint32_t __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_err(uint32_t e) {
6054 LDKDecodeError e_conv;
6055 e_conv.inner = (void*)(e & (~1));
6056 e_conv.is_owned = (e & 1) || (e == 0);
6057 // Warning: we may need a move here but can't clone!
6058 LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
6059 *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
6060 return (long)ret_conv;
6063 void __attribute__((visibility("default"))) TS_CResult_RouteDecodeErrorZ_free(uint32_t _res) {
6064 LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)_res;
6066 CResult_RouteDecodeErrorZ_free(_res_conv);
6069 void __attribute__((visibility("default"))) TS_CVec_RouteHintZ_free(uint32_tArray _res) {
6070 LDKCVec_RouteHintZ _res_constr;
6071 _res_constr.datalen = *((uint32_t*)_res);
6072 if (_res_constr.datalen > 0)
6073 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
6075 _res_constr.data = NULL;
6076 uint32_t* _res_vals = (uint32_t*)(_res + 4);
6077 for (size_t l = 0; l < _res_constr.datalen; l++) {
6078 uint32_t arr_conv_11 = _res_vals[l];
6079 LDKRouteHint arr_conv_11_conv;
6080 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
6081 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
6082 _res_constr.data[l] = arr_conv_11_conv;
6084 CVec_RouteHintZ_free(_res_constr);
6087 uint32_t __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_ok(uint32_t o) {
6089 o_conv.inner = (void*)(o & (~1));
6090 o_conv.is_owned = (o & 1) || (o == 0);
6091 if (o_conv.inner != NULL)
6092 o_conv = Route_clone(&o_conv);
6093 LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6094 *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
6095 return (long)ret_conv;
6098 uint32_t __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_err(uint32_t e) {
6099 LDKLightningError e_conv;
6100 e_conv.inner = (void*)(e & (~1));
6101 e_conv.is_owned = (e & 1) || (e == 0);
6102 // Warning: we may need a move here but can't clone!
6103 LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
6104 *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
6105 return (long)ret_conv;
6108 void __attribute__((visibility("default"))) TS_CResult_RouteLightningErrorZ_free(uint32_t _res) {
6109 LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)_res;
6111 CResult_RouteLightningErrorZ_free(_res_conv);
6114 uint32_t __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_ok(uint32_t o) {
6115 LDKRoutingFees o_conv;
6116 o_conv.inner = (void*)(o & (~1));
6117 o_conv.is_owned = (o & 1) || (o == 0);
6118 if (o_conv.inner != NULL)
6119 o_conv = RoutingFees_clone(&o_conv);
6120 LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6121 *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
6122 return (long)ret_conv;
6125 uint32_t __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_err(uint32_t e) {
6126 LDKDecodeError e_conv;
6127 e_conv.inner = (void*)(e & (~1));
6128 e_conv.is_owned = (e & 1) || (e == 0);
6129 // Warning: we may need a move here but can't clone!
6130 LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
6131 *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
6132 return (long)ret_conv;
6135 void __attribute__((visibility("default"))) TS_CResult_RoutingFeesDecodeErrorZ_free(uint32_t _res) {
6136 LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)_res;
6138 CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
6141 uint32_t __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_ok(uint32_t o) {
6142 LDKNodeAnnouncementInfo o_conv;
6143 o_conv.inner = (void*)(o & (~1));
6144 o_conv.is_owned = (o & 1) || (o == 0);
6145 // Warning: we may need a move here but can't clone!
6146 LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6147 *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
6148 return (long)ret_conv;
6151 uint32_t __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_err(uint32_t e) {
6152 LDKDecodeError e_conv;
6153 e_conv.inner = (void*)(e & (~1));
6154 e_conv.is_owned = (e & 1) || (e == 0);
6155 // Warning: we may need a move here but can't clone!
6156 LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
6157 *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
6158 return (long)ret_conv;
6161 void __attribute__((visibility("default"))) TS_CResult_NodeAnnouncementInfoDecodeErrorZ_free(uint32_t _res) {
6162 LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)_res;
6164 CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
6167 uint32_t __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_ok(uint32_t o) {
6169 o_conv.inner = (void*)(o & (~1));
6170 o_conv.is_owned = (o & 1) || (o == 0);
6171 // Warning: we may need a move here but can't clone!
6172 LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6173 *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
6174 return (long)ret_conv;
6177 uint32_t __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_err(uint32_t e) {
6178 LDKDecodeError e_conv;
6179 e_conv.inner = (void*)(e & (~1));
6180 e_conv.is_owned = (e & 1) || (e == 0);
6181 // Warning: we may need a move here but can't clone!
6182 LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
6183 *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
6184 return (long)ret_conv;
6187 void __attribute__((visibility("default"))) TS_CResult_NodeInfoDecodeErrorZ_free(uint32_t _res) {
6188 LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)_res;
6190 CResult_NodeInfoDecodeErrorZ_free(_res_conv);
6193 uint32_t __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_ok(uint32_t o) {
6194 LDKNetworkGraph o_conv;
6195 o_conv.inner = (void*)(o & (~1));
6196 o_conv.is_owned = (o & 1) || (o == 0);
6197 // Warning: we may need a move here but can't clone!
6198 LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6199 *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
6200 return (long)ret_conv;
6203 uint32_t __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_err(uint32_t e) {
6204 LDKDecodeError e_conv;
6205 e_conv.inner = (void*)(e & (~1));
6206 e_conv.is_owned = (e & 1) || (e == 0);
6207 // Warning: we may need a move here but can't clone!
6208 LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
6209 *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
6210 return (long)ret_conv;
6213 void __attribute__((visibility("default"))) TS_CResult_NetworkGraphDecodeErrorZ_free(uint32_t _res) {
6214 LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)_res;
6216 CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
6219 void __attribute__((visibility("default"))) TS_Event_free(uint32_t this_ptr) {
6220 LDKEvent this_ptr_conv = *(LDKEvent*)this_ptr;
6221 FREE((void*)this_ptr);
6222 Event_free(this_ptr_conv);
6225 uint32_t __attribute__((visibility("default"))) TS_Event_clone(uint32_t orig) {
6226 LDKEvent* orig_conv = (LDKEvent*)orig;
6227 LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
6228 *ret_copy = Event_clone(orig_conv);
6229 long ret_ref = (long)ret_copy;
6233 int8_tArray __attribute__((visibility("default"))) TS_Event_write(uint32_t obj) {
6234 LDKEvent* obj_conv = (LDKEvent*)obj;
6235 LDKCVec_u8Z arg_var = Event_write(obj_conv);
6236 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6237 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
6238 CVec_u8Z_free(arg_var);
6242 void __attribute__((visibility("default"))) TS_MessageSendEvent_free(uint32_t this_ptr) {
6243 LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)this_ptr;
6244 FREE((void*)this_ptr);
6245 MessageSendEvent_free(this_ptr_conv);
6248 uint32_t __attribute__((visibility("default"))) TS_MessageSendEvent_clone(uint32_t orig) {
6249 LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
6250 LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
6251 *ret_copy = MessageSendEvent_clone(orig_conv);
6252 long ret_ref = (long)ret_copy;
6256 void __attribute__((visibility("default"))) TS_MessageSendEventsProvider_free(uint32_t this_ptr) {
6257 LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)this_ptr;
6258 FREE((void*)this_ptr);
6259 MessageSendEventsProvider_free(this_ptr_conv);
6262 void __attribute__((visibility("default"))) TS_EventsProvider_free(uint32_t this_ptr) {
6263 LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)this_ptr;
6264 FREE((void*)this_ptr);
6265 EventsProvider_free(this_ptr_conv);
6268 void __attribute__((visibility("default"))) TS_APIError_free(uint32_t this_ptr) {
6269 LDKAPIError this_ptr_conv = *(LDKAPIError*)this_ptr;
6270 FREE((void*)this_ptr);
6271 APIError_free(this_ptr_conv);
6274 uint32_t __attribute__((visibility("default"))) TS_APIError_clone(uint32_t orig) {
6275 LDKAPIError* orig_conv = (LDKAPIError*)orig;
6276 LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6277 *ret_copy = APIError_clone(orig_conv);
6278 long ret_ref = (long)ret_copy;
6282 uint32_t __attribute__((visibility("default"))) TS_Level_clone(uint32_t orig) {
6283 LDKLevel* orig_conv = (LDKLevel*)orig;
6284 uint32_t ret_conv = LDKLevel_to_js(Level_clone(orig_conv));
6288 uint32_t __attribute__((visibility("default"))) TS_Level_max() {
6289 uint32_t ret_conv = LDKLevel_to_js(Level_max());
6293 void __attribute__((visibility("default"))) TS_Logger_free(uint32_t this_ptr) {
6294 LDKLogger this_ptr_conv = *(LDKLogger*)this_ptr;
6295 FREE((void*)this_ptr);
6296 Logger_free(this_ptr_conv);
6299 void __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_free(uint32_t this_ptr) {
6300 LDKChannelHandshakeConfig this_ptr_conv;
6301 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6302 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6303 ChannelHandshakeConfig_free(this_ptr_conv);
6306 uint32_t __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_clone(uint32_t orig) {
6307 LDKChannelHandshakeConfig orig_conv;
6308 orig_conv.inner = (void*)(orig & (~1));
6309 orig_conv.is_owned = false;
6310 LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
6311 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6312 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6313 long ret_ref = (long)ret_var.inner;
6314 if (ret_var.is_owned) {
6320 int32_t __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_minimum_depth(uint32_t this_ptr) {
6321 LDKChannelHandshakeConfig this_ptr_conv;
6322 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6323 this_ptr_conv.is_owned = false;
6324 int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
6328 void __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_minimum_depth(uint32_t this_ptr, int32_t val) {
6329 LDKChannelHandshakeConfig this_ptr_conv;
6330 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6331 this_ptr_conv.is_owned = false;
6332 ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
6335 int16_t __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_to_self_delay(uint32_t this_ptr) {
6336 LDKChannelHandshakeConfig this_ptr_conv;
6337 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6338 this_ptr_conv.is_owned = false;
6339 int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
6343 void __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_to_self_delay(uint32_t this_ptr, int16_t val) {
6344 LDKChannelHandshakeConfig this_ptr_conv;
6345 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6346 this_ptr_conv.is_owned = false;
6347 ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
6350 int64_t __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_get_our_htlc_minimum_msat(uint32_t this_ptr) {
6351 LDKChannelHandshakeConfig this_ptr_conv;
6352 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6353 this_ptr_conv.is_owned = false;
6354 int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
6358 void __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_set_our_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
6359 LDKChannelHandshakeConfig this_ptr_conv;
6360 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6361 this_ptr_conv.is_owned = false;
6362 ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
6365 uint32_t __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_new(int32_t minimum_depth_arg, int16_t our_to_self_delay_arg, int64_t our_htlc_minimum_msat_arg) {
6366 LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
6367 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6368 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6369 long ret_ref = (long)ret_var.inner;
6370 if (ret_var.is_owned) {
6376 uint32_t __attribute__((visibility("default"))) TS_ChannelHandshakeConfig_default() {
6377 LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
6378 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6379 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6380 long ret_ref = (long)ret_var.inner;
6381 if (ret_var.is_owned) {
6387 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_free(uint32_t this_ptr) {
6388 LDKChannelHandshakeLimits this_ptr_conv;
6389 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6390 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6391 ChannelHandshakeLimits_free(this_ptr_conv);
6394 uint32_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_clone(uint32_t orig) {
6395 LDKChannelHandshakeLimits orig_conv;
6396 orig_conv.inner = (void*)(orig & (~1));
6397 orig_conv.is_owned = false;
6398 LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
6399 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6400 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6401 long ret_ref = (long)ret_var.inner;
6402 if (ret_var.is_owned) {
6408 int64_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_funding_satoshis(uint32_t this_ptr) {
6409 LDKChannelHandshakeLimits this_ptr_conv;
6410 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6411 this_ptr_conv.is_owned = false;
6412 int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
6416 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_funding_satoshis(uint32_t this_ptr, int64_t val) {
6417 LDKChannelHandshakeLimits this_ptr_conv;
6418 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6419 this_ptr_conv.is_owned = false;
6420 ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
6423 int64_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_htlc_minimum_msat(uint32_t this_ptr) {
6424 LDKChannelHandshakeLimits this_ptr_conv;
6425 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6426 this_ptr_conv.is_owned = false;
6427 int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
6431 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
6432 LDKChannelHandshakeLimits this_ptr_conv;
6433 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6434 this_ptr_conv.is_owned = false;
6435 ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
6438 int64_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
6439 LDKChannelHandshakeLimits this_ptr_conv;
6440 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6441 this_ptr_conv.is_owned = false;
6442 int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
6446 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
6447 LDKChannelHandshakeLimits this_ptr_conv;
6448 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6449 this_ptr_conv.is_owned = false;
6450 ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
6453 int64_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_channel_reserve_satoshis(uint32_t this_ptr) {
6454 LDKChannelHandshakeLimits this_ptr_conv;
6455 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6456 this_ptr_conv.is_owned = false;
6457 int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
6461 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
6462 LDKChannelHandshakeLimits this_ptr_conv;
6463 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6464 this_ptr_conv.is_owned = false;
6465 ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
6468 int16_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_max_accepted_htlcs(uint32_t this_ptr) {
6469 LDKChannelHandshakeLimits this_ptr_conv;
6470 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6471 this_ptr_conv.is_owned = false;
6472 int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
6476 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
6477 LDKChannelHandshakeLimits this_ptr_conv;
6478 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6479 this_ptr_conv.is_owned = false;
6480 ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
6483 int64_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_min_dust_limit_satoshis(uint32_t this_ptr) {
6484 LDKChannelHandshakeLimits this_ptr_conv;
6485 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6486 this_ptr_conv.is_owned = false;
6487 int64_t ret_val = ChannelHandshakeLimits_get_min_dust_limit_satoshis(&this_ptr_conv);
6491 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_min_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
6492 LDKChannelHandshakeLimits this_ptr_conv;
6493 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6494 this_ptr_conv.is_owned = false;
6495 ChannelHandshakeLimits_set_min_dust_limit_satoshis(&this_ptr_conv, val);
6498 int64_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_dust_limit_satoshis(uint32_t this_ptr) {
6499 LDKChannelHandshakeLimits this_ptr_conv;
6500 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6501 this_ptr_conv.is_owned = false;
6502 int64_t ret_val = ChannelHandshakeLimits_get_max_dust_limit_satoshis(&this_ptr_conv);
6506 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
6507 LDKChannelHandshakeLimits this_ptr_conv;
6508 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6509 this_ptr_conv.is_owned = false;
6510 ChannelHandshakeLimits_set_max_dust_limit_satoshis(&this_ptr_conv, val);
6513 int32_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_max_minimum_depth(uint32_t this_ptr) {
6514 LDKChannelHandshakeLimits this_ptr_conv;
6515 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6516 this_ptr_conv.is_owned = false;
6517 int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
6521 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_max_minimum_depth(uint32_t this_ptr, int32_t val) {
6522 LDKChannelHandshakeLimits this_ptr_conv;
6523 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6524 this_ptr_conv.is_owned = false;
6525 ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
6528 jboolean __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_force_announced_channel_preference(uint32_t this_ptr) {
6529 LDKChannelHandshakeLimits this_ptr_conv;
6530 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6531 this_ptr_conv.is_owned = false;
6532 jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
6536 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_force_announced_channel_preference(uint32_t this_ptr, jboolean val) {
6537 LDKChannelHandshakeLimits this_ptr_conv;
6538 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6539 this_ptr_conv.is_owned = false;
6540 ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
6543 int16_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_get_their_to_self_delay(uint32_t this_ptr) {
6544 LDKChannelHandshakeLimits this_ptr_conv;
6545 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6546 this_ptr_conv.is_owned = false;
6547 int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
6551 void __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_set_their_to_self_delay(uint32_t this_ptr, int16_t val) {
6552 LDKChannelHandshakeLimits this_ptr_conv;
6553 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6554 this_ptr_conv.is_owned = false;
6555 ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
6558 uint32_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_new(int64_t min_funding_satoshis_arg, int64_t max_htlc_minimum_msat_arg, int64_t min_max_htlc_value_in_flight_msat_arg, int64_t max_channel_reserve_satoshis_arg, int16_t min_max_accepted_htlcs_arg, int64_t min_dust_limit_satoshis_arg, int64_t max_dust_limit_satoshis_arg, int32_t max_minimum_depth_arg, jboolean force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
6559 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);
6560 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6561 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6562 long ret_ref = (long)ret_var.inner;
6563 if (ret_var.is_owned) {
6569 uint32_t __attribute__((visibility("default"))) TS_ChannelHandshakeLimits_default() {
6570 LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
6571 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6572 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6573 long ret_ref = (long)ret_var.inner;
6574 if (ret_var.is_owned) {
6580 void __attribute__((visibility("default"))) TS_ChannelConfig_free(uint32_t this_ptr) {
6581 LDKChannelConfig this_ptr_conv;
6582 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6583 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6584 ChannelConfig_free(this_ptr_conv);
6587 uint32_t __attribute__((visibility("default"))) TS_ChannelConfig_clone(uint32_t orig) {
6588 LDKChannelConfig orig_conv;
6589 orig_conv.inner = (void*)(orig & (~1));
6590 orig_conv.is_owned = false;
6591 LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
6592 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6593 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6594 long ret_ref = (long)ret_var.inner;
6595 if (ret_var.is_owned) {
6601 int32_t __attribute__((visibility("default"))) TS_ChannelConfig_get_fee_proportional_millionths(uint32_t this_ptr) {
6602 LDKChannelConfig this_ptr_conv;
6603 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6604 this_ptr_conv.is_owned = false;
6605 int32_t ret_val = ChannelConfig_get_fee_proportional_millionths(&this_ptr_conv);
6609 void __attribute__((visibility("default"))) TS_ChannelConfig_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
6610 LDKChannelConfig this_ptr_conv;
6611 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6612 this_ptr_conv.is_owned = false;
6613 ChannelConfig_set_fee_proportional_millionths(&this_ptr_conv, val);
6616 jboolean __attribute__((visibility("default"))) TS_ChannelConfig_get_announced_channel(uint32_t this_ptr) {
6617 LDKChannelConfig this_ptr_conv;
6618 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6619 this_ptr_conv.is_owned = false;
6620 jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
6624 void __attribute__((visibility("default"))) TS_ChannelConfig_set_announced_channel(uint32_t this_ptr, jboolean val) {
6625 LDKChannelConfig this_ptr_conv;
6626 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6627 this_ptr_conv.is_owned = false;
6628 ChannelConfig_set_announced_channel(&this_ptr_conv, val);
6631 jboolean __attribute__((visibility("default"))) TS_ChannelConfig_get_commit_upfront_shutdown_pubkey(uint32_t this_ptr) {
6632 LDKChannelConfig this_ptr_conv;
6633 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6634 this_ptr_conv.is_owned = false;
6635 jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
6639 void __attribute__((visibility("default"))) TS_ChannelConfig_set_commit_upfront_shutdown_pubkey(uint32_t this_ptr, jboolean val) {
6640 LDKChannelConfig this_ptr_conv;
6641 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6642 this_ptr_conv.is_owned = false;
6643 ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
6646 uint32_t __attribute__((visibility("default"))) TS_ChannelConfig_new(int32_t fee_proportional_millionths_arg, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg) {
6647 LDKChannelConfig ret_var = ChannelConfig_new(fee_proportional_millionths_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg);
6648 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6649 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6650 long ret_ref = (long)ret_var.inner;
6651 if (ret_var.is_owned) {
6657 uint32_t __attribute__((visibility("default"))) TS_ChannelConfig_default() {
6658 LDKChannelConfig ret_var = ChannelConfig_default();
6659 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6660 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6661 long ret_ref = (long)ret_var.inner;
6662 if (ret_var.is_owned) {
6668 int8_tArray __attribute__((visibility("default"))) TS_ChannelConfig_write(uint32_t obj) {
6669 LDKChannelConfig obj_conv;
6670 obj_conv.inner = (void*)(obj & (~1));
6671 obj_conv.is_owned = false;
6672 LDKCVec_u8Z arg_var = ChannelConfig_write(&obj_conv);
6673 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6674 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
6675 CVec_u8Z_free(arg_var);
6679 uint32_t __attribute__((visibility("default"))) TS_ChannelConfig_read(int8_tArray ser) {
6681 ser_ref.datalen = *((uint32_t*)ser);
6682 ser_ref.data = (int8_t*)(ser + 4);
6683 LDKChannelConfig ret_var = ChannelConfig_read(ser_ref);
6684 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6685 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6686 long ret_ref = (long)ret_var.inner;
6687 if (ret_var.is_owned) {
6693 void __attribute__((visibility("default"))) TS_UserConfig_free(uint32_t this_ptr) {
6694 LDKUserConfig this_ptr_conv;
6695 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6696 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6697 UserConfig_free(this_ptr_conv);
6700 uint32_t __attribute__((visibility("default"))) TS_UserConfig_clone(uint32_t orig) {
6701 LDKUserConfig orig_conv;
6702 orig_conv.inner = (void*)(orig & (~1));
6703 orig_conv.is_owned = false;
6704 LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
6705 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6706 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6707 long ret_ref = (long)ret_var.inner;
6708 if (ret_var.is_owned) {
6714 uint32_t __attribute__((visibility("default"))) TS_UserConfig_get_own_channel_config(uint32_t this_ptr) {
6715 LDKUserConfig this_ptr_conv;
6716 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6717 this_ptr_conv.is_owned = false;
6718 LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
6719 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6720 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6721 long ret_ref = (long)ret_var.inner;
6722 if (ret_var.is_owned) {
6728 void __attribute__((visibility("default"))) TS_UserConfig_set_own_channel_config(uint32_t this_ptr, uint32_t val) {
6729 LDKUserConfig this_ptr_conv;
6730 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6731 this_ptr_conv.is_owned = false;
6732 LDKChannelHandshakeConfig val_conv;
6733 val_conv.inner = (void*)(val & (~1));
6734 val_conv.is_owned = (val & 1) || (val == 0);
6735 if (val_conv.inner != NULL)
6736 val_conv = ChannelHandshakeConfig_clone(&val_conv);
6737 UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
6740 uint32_t __attribute__((visibility("default"))) TS_UserConfig_get_peer_channel_config_limits(uint32_t this_ptr) {
6741 LDKUserConfig this_ptr_conv;
6742 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6743 this_ptr_conv.is_owned = false;
6744 LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
6745 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6746 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6747 long ret_ref = (long)ret_var.inner;
6748 if (ret_var.is_owned) {
6754 void __attribute__((visibility("default"))) TS_UserConfig_set_peer_channel_config_limits(uint32_t this_ptr, uint32_t val) {
6755 LDKUserConfig this_ptr_conv;
6756 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6757 this_ptr_conv.is_owned = false;
6758 LDKChannelHandshakeLimits val_conv;
6759 val_conv.inner = (void*)(val & (~1));
6760 val_conv.is_owned = (val & 1) || (val == 0);
6761 if (val_conv.inner != NULL)
6762 val_conv = ChannelHandshakeLimits_clone(&val_conv);
6763 UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
6766 uint32_t __attribute__((visibility("default"))) TS_UserConfig_get_channel_options(uint32_t this_ptr) {
6767 LDKUserConfig this_ptr_conv;
6768 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6769 this_ptr_conv.is_owned = false;
6770 LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
6771 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6772 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6773 long ret_ref = (long)ret_var.inner;
6774 if (ret_var.is_owned) {
6780 void __attribute__((visibility("default"))) TS_UserConfig_set_channel_options(uint32_t this_ptr, uint32_t val) {
6781 LDKUserConfig this_ptr_conv;
6782 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6783 this_ptr_conv.is_owned = false;
6784 LDKChannelConfig val_conv;
6785 val_conv.inner = (void*)(val & (~1));
6786 val_conv.is_owned = (val & 1) || (val == 0);
6787 if (val_conv.inner != NULL)
6788 val_conv = ChannelConfig_clone(&val_conv);
6789 UserConfig_set_channel_options(&this_ptr_conv, val_conv);
6792 uint32_t __attribute__((visibility("default"))) TS_UserConfig_new(uint32_t own_channel_config_arg, uint32_t peer_channel_config_limits_arg, uint32_t channel_options_arg) {
6793 LDKChannelHandshakeConfig own_channel_config_arg_conv;
6794 own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
6795 own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
6796 if (own_channel_config_arg_conv.inner != NULL)
6797 own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
6798 LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
6799 peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
6800 peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
6801 if (peer_channel_config_limits_arg_conv.inner != NULL)
6802 peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
6803 LDKChannelConfig channel_options_arg_conv;
6804 channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
6805 channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
6806 if (channel_options_arg_conv.inner != NULL)
6807 channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
6808 LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv);
6809 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6810 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6811 long ret_ref = (long)ret_var.inner;
6812 if (ret_var.is_owned) {
6818 uint32_t __attribute__((visibility("default"))) TS_UserConfig_default() {
6819 LDKUserConfig ret_var = UserConfig_default();
6820 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6821 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6822 long ret_ref = (long)ret_var.inner;
6823 if (ret_var.is_owned) {
6829 uint32_t __attribute__((visibility("default"))) TS_AccessError_clone(uint32_t orig) {
6830 LDKAccessError* orig_conv = (LDKAccessError*)orig;
6831 uint32_t ret_conv = LDKAccessError_to_js(AccessError_clone(orig_conv));
6835 void __attribute__((visibility("default"))) TS_Access_free(uint32_t this_ptr) {
6836 LDKAccess this_ptr_conv = *(LDKAccess*)this_ptr;
6837 FREE((void*)this_ptr);
6838 Access_free(this_ptr_conv);
6841 void __attribute__((visibility("default"))) TS_Watch_free(uint32_t this_ptr) {
6842 LDKWatch this_ptr_conv = *(LDKWatch*)this_ptr;
6843 FREE((void*)this_ptr);
6844 Watch_free(this_ptr_conv);
6847 void __attribute__((visibility("default"))) TS_Filter_free(uint32_t this_ptr) {
6848 LDKFilter this_ptr_conv = *(LDKFilter*)this_ptr;
6849 FREE((void*)this_ptr);
6850 Filter_free(this_ptr_conv);
6853 void __attribute__((visibility("default"))) TS_BroadcasterInterface_free(uint32_t this_ptr) {
6854 LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)this_ptr;
6855 FREE((void*)this_ptr);
6856 BroadcasterInterface_free(this_ptr_conv);
6859 uint32_t __attribute__((visibility("default"))) TS_ConfirmationTarget_clone(uint32_t orig) {
6860 LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)orig;
6861 uint32_t ret_conv = LDKConfirmationTarget_to_js(ConfirmationTarget_clone(orig_conv));
6865 void __attribute__((visibility("default"))) TS_FeeEstimator_free(uint32_t this_ptr) {
6866 LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)this_ptr;
6867 FREE((void*)this_ptr);
6868 FeeEstimator_free(this_ptr_conv);
6871 void __attribute__((visibility("default"))) TS_ChainMonitor_free(uint32_t this_ptr) {
6872 LDKChainMonitor this_ptr_conv;
6873 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6874 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6875 ChainMonitor_free(this_ptr_conv);
6878 void __attribute__((visibility("default"))) TS_ChainMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
6879 LDKChainMonitor this_arg_conv;
6880 this_arg_conv.inner = (void*)(this_arg & (~1));
6881 this_arg_conv.is_owned = false;
6882 unsigned char header_arr[80];
6883 CHECK(*((uint32_t*)header) == 80);
6884 memcpy(header_arr, (uint8_t*)(header + 4), 80);
6885 unsigned char (*header_ref)[80] = &header_arr;
6886 LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
6887 txdata_constr.datalen = *((uint32_t*)txdata);
6888 if (txdata_constr.datalen > 0)
6889 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
6891 txdata_constr.data = NULL;
6892 uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
6893 for (size_t e = 0; e < txdata_constr.datalen; e++) {
6894 uint32_t arr_conv_30 = txdata_vals[e];
6895 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_30;
6896 FREE((void*)arr_conv_30);
6897 txdata_constr.data[e] = arr_conv_30_conv;
6899 ChainMonitor_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
6902 void __attribute__((visibility("default"))) TS_ChainMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t disconnected_height) {
6903 LDKChainMonitor this_arg_conv;
6904 this_arg_conv.inner = (void*)(this_arg & (~1));
6905 this_arg_conv.is_owned = false;
6906 unsigned char header_arr[80];
6907 CHECK(*((uint32_t*)header) == 80);
6908 memcpy(header_arr, (uint8_t*)(header + 4), 80);
6909 unsigned char (*header_ref)[80] = &header_arr;
6910 ChainMonitor_block_disconnected(&this_arg_conv, header_ref, disconnected_height);
6913 uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_new(uint32_t chain_source, uint32_t broadcaster, uint32_t logger, uint32_t feeest, uint32_t persister) {
6914 LDKFilter* chain_source_conv = (LDKFilter*)chain_source;
6915 LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
6916 LDKLogger logger_conv = *(LDKLogger*)logger;
6917 LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)feeest;
6918 LDKPersist persister_conv = *(LDKPersist*)persister;
6919 LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
6920 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6921 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6922 long ret_ref = (long)ret_var.inner;
6923 if (ret_var.is_owned) {
6929 uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_Watch(uint32_t this_arg) {
6930 LDKChainMonitor this_arg_conv;
6931 this_arg_conv.inner = (void*)(this_arg & (~1));
6932 this_arg_conv.is_owned = false;
6933 LDKWatch* ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
6934 *ret = ChainMonitor_as_Watch(&this_arg_conv);
6938 uint32_t __attribute__((visibility("default"))) TS_ChainMonitor_as_EventsProvider(uint32_t this_arg) {
6939 LDKChainMonitor this_arg_conv;
6940 this_arg_conv.inner = (void*)(this_arg & (~1));
6941 this_arg_conv.is_owned = false;
6942 LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
6943 *ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
6947 void __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_free(uint32_t this_ptr) {
6948 LDKChannelMonitorUpdate this_ptr_conv;
6949 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6950 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
6951 ChannelMonitorUpdate_free(this_ptr_conv);
6954 uint32_t __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_clone(uint32_t orig) {
6955 LDKChannelMonitorUpdate orig_conv;
6956 orig_conv.inner = (void*)(orig & (~1));
6957 orig_conv.is_owned = false;
6958 LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
6959 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6960 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6961 long ret_ref = (long)ret_var.inner;
6962 if (ret_var.is_owned) {
6968 int64_t __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_get_update_id(uint32_t this_ptr) {
6969 LDKChannelMonitorUpdate this_ptr_conv;
6970 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6971 this_ptr_conv.is_owned = false;
6972 int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
6976 void __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_set_update_id(uint32_t this_ptr, int64_t val) {
6977 LDKChannelMonitorUpdate this_ptr_conv;
6978 this_ptr_conv.inner = (void*)(this_ptr & (~1));
6979 this_ptr_conv.is_owned = false;
6980 ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
6983 int8_tArray __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_write(uint32_t obj) {
6984 LDKChannelMonitorUpdate obj_conv;
6985 obj_conv.inner = (void*)(obj & (~1));
6986 obj_conv.is_owned = false;
6987 LDKCVec_u8Z arg_var = ChannelMonitorUpdate_write(&obj_conv);
6988 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
6989 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
6990 CVec_u8Z_free(arg_var);
6994 uint32_t __attribute__((visibility("default"))) TS_ChannelMonitorUpdate_read(int8_tArray ser) {
6996 ser_ref.datalen = *((uint32_t*)ser);
6997 ser_ref.data = (int8_t*)(ser + 4);
6998 LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
6999 *ret_conv = ChannelMonitorUpdate_read(ser_ref);
7000 return (long)ret_conv;
7003 uint32_t __attribute__((visibility("default"))) TS_ChannelMonitorUpdateErr_clone(uint32_t orig) {
7004 LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)orig;
7005 uint32_t ret_conv = LDKChannelMonitorUpdateErr_to_js(ChannelMonitorUpdateErr_clone(orig_conv));
7009 void __attribute__((visibility("default"))) TS_MonitorUpdateError_free(uint32_t this_ptr) {
7010 LDKMonitorUpdateError this_ptr_conv;
7011 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7012 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7013 MonitorUpdateError_free(this_ptr_conv);
7016 void __attribute__((visibility("default"))) TS_MonitorEvent_free(uint32_t this_ptr) {
7017 LDKMonitorEvent this_ptr_conv;
7018 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7019 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7020 MonitorEvent_free(this_ptr_conv);
7023 uint32_t __attribute__((visibility("default"))) TS_MonitorEvent_clone(uint32_t orig) {
7024 LDKMonitorEvent orig_conv;
7025 orig_conv.inner = (void*)(orig & (~1));
7026 orig_conv.is_owned = false;
7027 LDKMonitorEvent ret_var = MonitorEvent_clone(&orig_conv);
7028 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7029 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7030 long ret_ref = (long)ret_var.inner;
7031 if (ret_var.is_owned) {
7037 void __attribute__((visibility("default"))) TS_HTLCUpdate_free(uint32_t this_ptr) {
7038 LDKHTLCUpdate this_ptr_conv;
7039 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7040 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7041 HTLCUpdate_free(this_ptr_conv);
7044 uint32_t __attribute__((visibility("default"))) TS_HTLCUpdate_clone(uint32_t orig) {
7045 LDKHTLCUpdate orig_conv;
7046 orig_conv.inner = (void*)(orig & (~1));
7047 orig_conv.is_owned = false;
7048 LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
7049 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7050 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7051 long ret_ref = (long)ret_var.inner;
7052 if (ret_var.is_owned) {
7058 int8_tArray __attribute__((visibility("default"))) TS_HTLCUpdate_write(uint32_t obj) {
7059 LDKHTLCUpdate obj_conv;
7060 obj_conv.inner = (void*)(obj & (~1));
7061 obj_conv.is_owned = false;
7062 LDKCVec_u8Z arg_var = HTLCUpdate_write(&obj_conv);
7063 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7064 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7065 CVec_u8Z_free(arg_var);
7069 uint32_t __attribute__((visibility("default"))) TS_HTLCUpdate_read(int8_tArray ser) {
7071 ser_ref.datalen = *((uint32_t*)ser);
7072 ser_ref.data = (int8_t*)(ser + 4);
7073 LDKHTLCUpdate ret_var = HTLCUpdate_read(ser_ref);
7074 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7075 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7076 long ret_ref = (long)ret_var.inner;
7077 if (ret_var.is_owned) {
7083 void __attribute__((visibility("default"))) TS_ChannelMonitor_free(uint32_t this_ptr) {
7084 LDKChannelMonitor this_ptr_conv;
7085 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7086 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7087 ChannelMonitor_free(this_ptr_conv);
7090 int8_tArray __attribute__((visibility("default"))) TS_ChannelMonitor_write(uint32_t obj) {
7091 LDKChannelMonitor obj_conv;
7092 obj_conv.inner = (void*)(obj & (~1));
7093 obj_conv.is_owned = false;
7094 LDKCVec_u8Z arg_var = ChannelMonitor_write(&obj_conv);
7095 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7096 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7097 CVec_u8Z_free(arg_var);
7101 uint32_t __attribute__((visibility("default"))) TS_ChannelMonitor_update_monitor(uint32_t this_arg, uint32_t updates, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
7102 LDKChannelMonitor this_arg_conv;
7103 this_arg_conv.inner = (void*)(this_arg & (~1));
7104 this_arg_conv.is_owned = false;
7105 LDKChannelMonitorUpdate updates_conv;
7106 updates_conv.inner = (void*)(updates & (~1));
7107 updates_conv.is_owned = false;
7108 LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster;
7109 LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator;
7110 LDKLogger* logger_conv = (LDKLogger*)logger;
7111 LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
7112 *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
7113 return (long)ret_conv;
7116 int64_t __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_update_id(uint32_t this_arg) {
7117 LDKChannelMonitor this_arg_conv;
7118 this_arg_conv.inner = (void*)(this_arg & (~1));
7119 this_arg_conv.is_owned = false;
7120 int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
7124 uint32_t __attribute__((visibility("default"))) TS_ChannelMonitor_get_funding_txo(uint32_t this_arg) {
7125 LDKChannelMonitor this_arg_conv;
7126 this_arg_conv.inner = (void*)(this_arg & (~1));
7127 this_arg_conv.is_owned = false;
7128 LDKC2Tuple_OutPointScriptZ* ret_ref = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
7129 *ret_ref = ChannelMonitor_get_funding_txo(&this_arg_conv);
7130 ret_ref->a = OutPoint_clone(&ret_ref->a);
7131 ret_ref->b = CVec_u8Z_clone(&ret_ref->b);
7132 return (long)ret_ref;
7135 uint32_tArray __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_monitor_events(uint32_t this_arg) {
7136 LDKChannelMonitor this_arg_conv;
7137 this_arg_conv.inner = (void*)(this_arg & (~1));
7138 this_arg_conv.is_owned = false;
7139 LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
7140 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7141 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7142 for (size_t o = 0; o < ret_var.datalen; o++) {
7143 LDKMonitorEvent arr_conv_14_var = ret_var.data[o];
7144 CHECK((((long)arr_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7145 CHECK((((long)&arr_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7146 long arr_conv_14_ref = (long)arr_conv_14_var.inner;
7147 if (arr_conv_14_var.is_owned) {
7148 arr_conv_14_ref |= 1;
7150 ret_arr_ptr[o] = arr_conv_14_ref;
7156 uint32_tArray __attribute__((visibility("default"))) TS_ChannelMonitor_get_and_clear_pending_events(uint32_t this_arg) {
7157 LDKChannelMonitor this_arg_conv;
7158 this_arg_conv.inner = (void*)(this_arg & (~1));
7159 this_arg_conv.is_owned = false;
7160 LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
7161 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7162 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7163 for (size_t h = 0; h < ret_var.datalen; h++) {
7164 LDKEvent *arr_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
7165 *arr_conv_7_copy = Event_clone(&ret_var.data[h]);
7166 long arr_conv_7_ref = (long)arr_conv_7_copy;
7167 ret_arr_ptr[h] = arr_conv_7_ref;
7173 ptrArray __attribute__((visibility("default"))) TS_ChannelMonitor_get_latest_holder_commitment_txn(uint32_t this_arg, uint32_t logger) {
7174 LDKChannelMonitor this_arg_conv;
7175 this_arg_conv.inner = (void*)(this_arg & (~1));
7176 this_arg_conv.is_owned = false;
7177 LDKLogger* logger_conv = (LDKLogger*)logger;
7178 LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
7179 ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
7180 int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
7181 for (size_t m = 0; m < ret_var.datalen; m++) {
7182 LDKTransaction arr_conv_12_var = ret_var.data[m];
7183 int8_tArray arr_conv_12_arr = init_arr(arr_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7184 memcpy((uint8_t*)(arr_conv_12_arr + 4), arr_conv_12_var.data, arr_conv_12_var.datalen);
7185 Transaction_free(arr_conv_12_var);
7186 ret_arr_ptr[m] = arr_conv_12_arr;
7192 uint32_tArray __attribute__((visibility("default"))) TS_ChannelMonitor_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
7193 LDKChannelMonitor this_arg_conv;
7194 this_arg_conv.inner = (void*)(this_arg & (~1));
7195 this_arg_conv.is_owned = false;
7196 unsigned char header_arr[80];
7197 CHECK(*((uint32_t*)header) == 80);
7198 memcpy(header_arr, (uint8_t*)(header + 4), 80);
7199 unsigned char (*header_ref)[80] = &header_arr;
7200 LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7201 txdata_constr.datalen = *((uint32_t*)txdata);
7202 if (txdata_constr.datalen > 0)
7203 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7205 txdata_constr.data = NULL;
7206 uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
7207 for (size_t e = 0; e < txdata_constr.datalen; e++) {
7208 uint32_t arr_conv_30 = txdata_vals[e];
7209 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_30;
7210 FREE((void*)arr_conv_30);
7211 txdata_constr.data[e] = arr_conv_30_conv;
7213 LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
7214 LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
7215 LDKLogger logger_conv = *(LDKLogger*)logger;
7216 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);
7217 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7218 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7219 for (size_t x = 0; x < ret_var.datalen; x++) {
7220 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arr_conv_49_ref = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
7221 *arr_conv_49_ref = ret_var.data[x];
7222 arr_conv_49_ref->a = ThirtyTwoBytes_clone(&arr_conv_49_ref->a);
7223 // XXX: We likely need to clone here, but no _clone fn is available for TwoTuple<Number, TxOut>[]
7224 ret_arr_ptr[x] = (long)arr_conv_49_ref;
7230 void __attribute__((visibility("default"))) TS_ChannelMonitor_block_disconnected(uint32_t this_arg, int8_tArray header, int32_t height, uint32_t broadcaster, uint32_t fee_estimator, uint32_t logger) {
7231 LDKChannelMonitor this_arg_conv;
7232 this_arg_conv.inner = (void*)(this_arg & (~1));
7233 this_arg_conv.is_owned = false;
7234 unsigned char header_arr[80];
7235 CHECK(*((uint32_t*)header) == 80);
7236 memcpy(header_arr, (uint8_t*)(header + 4), 80);
7237 unsigned char (*header_ref)[80] = &header_arr;
7238 LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)broadcaster;
7239 LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
7240 LDKLogger logger_conv = *(LDKLogger*)logger;
7241 ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
7244 void __attribute__((visibility("default"))) TS_Persist_free(uint32_t this_ptr) {
7245 LDKPersist this_ptr_conv = *(LDKPersist*)this_ptr;
7246 FREE((void*)this_ptr);
7247 Persist_free(this_ptr_conv);
7250 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_read(int8_tArray ser, uint32_t arg) {
7252 ser_ref.datalen = *((uint32_t*)ser);
7253 ser_ref.data = (int8_t*)(ser + 4);
7254 LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg;
7255 LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
7256 *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
7257 return (long)ret_conv;
7260 void __attribute__((visibility("default"))) TS_OutPoint_free(uint32_t this_ptr) {
7261 LDKOutPoint this_ptr_conv;
7262 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7263 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7264 OutPoint_free(this_ptr_conv);
7267 uint32_t __attribute__((visibility("default"))) TS_OutPoint_clone(uint32_t orig) {
7268 LDKOutPoint orig_conv;
7269 orig_conv.inner = (void*)(orig & (~1));
7270 orig_conv.is_owned = false;
7271 LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
7272 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7273 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7274 long ret_ref = (long)ret_var.inner;
7275 if (ret_var.is_owned) {
7281 int8_tArray __attribute__((visibility("default"))) TS_OutPoint_get_txid(uint32_t this_ptr) {
7282 LDKOutPoint this_ptr_conv;
7283 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7284 this_ptr_conv.is_owned = false;
7285 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7286 memcpy((uint8_t*)(ret_arr + 4), *OutPoint_get_txid(&this_ptr_conv), 32);
7290 void __attribute__((visibility("default"))) TS_OutPoint_set_txid(uint32_t this_ptr, int8_tArray val) {
7291 LDKOutPoint this_ptr_conv;
7292 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7293 this_ptr_conv.is_owned = false;
7294 LDKThirtyTwoBytes val_ref;
7295 CHECK(*((uint32_t*)val) == 32);
7296 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7297 OutPoint_set_txid(&this_ptr_conv, val_ref);
7300 int16_t __attribute__((visibility("default"))) TS_OutPoint_get_index(uint32_t this_ptr) {
7301 LDKOutPoint this_ptr_conv;
7302 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7303 this_ptr_conv.is_owned = false;
7304 int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
7308 void __attribute__((visibility("default"))) TS_OutPoint_set_index(uint32_t this_ptr, int16_t val) {
7309 LDKOutPoint this_ptr_conv;
7310 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7311 this_ptr_conv.is_owned = false;
7312 OutPoint_set_index(&this_ptr_conv, val);
7315 uint32_t __attribute__((visibility("default"))) TS_OutPoint_new(int8_tArray txid_arg, int16_t index_arg) {
7316 LDKThirtyTwoBytes txid_arg_ref;
7317 CHECK(*((uint32_t*)txid_arg) == 32);
7318 memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
7319 LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
7320 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7321 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7322 long ret_ref = (long)ret_var.inner;
7323 if (ret_var.is_owned) {
7329 int8_tArray __attribute__((visibility("default"))) TS_OutPoint_to_channel_id(uint32_t this_arg) {
7330 LDKOutPoint this_arg_conv;
7331 this_arg_conv.inner = (void*)(this_arg & (~1));
7332 this_arg_conv.is_owned = false;
7333 int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7334 memcpy((uint8_t*)(arg_arr + 4), OutPoint_to_channel_id(&this_arg_conv).data, 32);
7338 int8_tArray __attribute__((visibility("default"))) TS_OutPoint_write(uint32_t obj) {
7339 LDKOutPoint obj_conv;
7340 obj_conv.inner = (void*)(obj & (~1));
7341 obj_conv.is_owned = false;
7342 LDKCVec_u8Z arg_var = OutPoint_write(&obj_conv);
7343 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7344 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7345 CVec_u8Z_free(arg_var);
7349 uint32_t __attribute__((visibility("default"))) TS_OutPoint_read(int8_tArray ser) {
7351 ser_ref.datalen = *((uint32_t*)ser);
7352 ser_ref.data = (int8_t*)(ser + 4);
7353 LDKOutPoint ret_var = OutPoint_read(ser_ref);
7354 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7355 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7356 long ret_ref = (long)ret_var.inner;
7357 if (ret_var.is_owned) {
7363 void __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_free(uint32_t this_ptr) {
7364 LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)this_ptr;
7365 FREE((void*)this_ptr);
7366 SpendableOutputDescriptor_free(this_ptr_conv);
7369 uint32_t __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_clone(uint32_t orig) {
7370 LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
7371 LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
7372 *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
7373 long ret_ref = (long)ret_copy;
7377 int8_tArray __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_write(uint32_t obj) {
7378 LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
7379 LDKCVec_u8Z arg_var = SpendableOutputDescriptor_write(obj_conv);
7380 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7381 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7382 CVec_u8Z_free(arg_var);
7386 uint32_t __attribute__((visibility("default"))) TS_SpendableOutputDescriptor_read(int8_tArray ser) {
7388 ser_ref.datalen = *((uint32_t*)ser);
7389 ser_ref.data = (int8_t*)(ser + 4);
7390 LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
7391 *ret_conv = SpendableOutputDescriptor_read(ser_ref);
7392 return (long)ret_conv;
7395 uint32_t __attribute__((visibility("default"))) TS_ChannelKeys_clone(uint32_t orig) {
7396 LDKChannelKeys* orig_conv = (LDKChannelKeys*)orig;
7397 LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
7398 *ret = ChannelKeys_clone(orig_conv);
7402 void __attribute__((visibility("default"))) TS_ChannelKeys_free(uint32_t this_ptr) {
7403 LDKChannelKeys this_ptr_conv = *(LDKChannelKeys*)this_ptr;
7404 FREE((void*)this_ptr);
7405 ChannelKeys_free(this_ptr_conv);
7408 void __attribute__((visibility("default"))) TS_KeysInterface_free(uint32_t this_ptr) {
7409 LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)this_ptr;
7410 FREE((void*)this_ptr);
7411 KeysInterface_free(this_ptr_conv);
7414 void __attribute__((visibility("default"))) TS_InMemoryChannelKeys_free(uint32_t this_ptr) {
7415 LDKInMemoryChannelKeys this_ptr_conv;
7416 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7417 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7418 InMemoryChannelKeys_free(this_ptr_conv);
7421 uint32_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_clone(uint32_t orig) {
7422 LDKInMemoryChannelKeys orig_conv;
7423 orig_conv.inner = (void*)(orig & (~1));
7424 orig_conv.is_owned = false;
7425 LDKInMemoryChannelKeys ret_var = InMemoryChannelKeys_clone(&orig_conv);
7426 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7427 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7428 long ret_ref = (long)ret_var.inner;
7429 if (ret_var.is_owned) {
7435 int8_tArray __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_funding_key(uint32_t this_ptr) {
7436 LDKInMemoryChannelKeys this_ptr_conv;
7437 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7438 this_ptr_conv.is_owned = false;
7439 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7440 memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_funding_key(&this_ptr_conv), 32);
7444 void __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_funding_key(uint32_t this_ptr, int8_tArray val) {
7445 LDKInMemoryChannelKeys this_ptr_conv;
7446 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7447 this_ptr_conv.is_owned = false;
7448 LDKSecretKey val_ref;
7449 CHECK(*((uint32_t*)val) == 32);
7450 memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7451 InMemoryChannelKeys_set_funding_key(&this_ptr_conv, val_ref);
7454 int8_tArray __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_revocation_base_key(uint32_t this_ptr) {
7455 LDKInMemoryChannelKeys this_ptr_conv;
7456 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7457 this_ptr_conv.is_owned = false;
7458 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7459 memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_revocation_base_key(&this_ptr_conv), 32);
7463 void __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_revocation_base_key(uint32_t this_ptr, int8_tArray val) {
7464 LDKInMemoryChannelKeys this_ptr_conv;
7465 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7466 this_ptr_conv.is_owned = false;
7467 LDKSecretKey val_ref;
7468 CHECK(*((uint32_t*)val) == 32);
7469 memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7470 InMemoryChannelKeys_set_revocation_base_key(&this_ptr_conv, val_ref);
7473 int8_tArray __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_payment_key(uint32_t this_ptr) {
7474 LDKInMemoryChannelKeys this_ptr_conv;
7475 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7476 this_ptr_conv.is_owned = false;
7477 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7478 memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_payment_key(&this_ptr_conv), 32);
7482 void __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_payment_key(uint32_t this_ptr, int8_tArray val) {
7483 LDKInMemoryChannelKeys this_ptr_conv;
7484 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7485 this_ptr_conv.is_owned = false;
7486 LDKSecretKey val_ref;
7487 CHECK(*((uint32_t*)val) == 32);
7488 memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7489 InMemoryChannelKeys_set_payment_key(&this_ptr_conv, val_ref);
7492 int8_tArray __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_delayed_payment_base_key(uint32_t this_ptr) {
7493 LDKInMemoryChannelKeys this_ptr_conv;
7494 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7495 this_ptr_conv.is_owned = false;
7496 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7497 memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_delayed_payment_base_key(&this_ptr_conv), 32);
7501 void __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_delayed_payment_base_key(uint32_t this_ptr, int8_tArray val) {
7502 LDKInMemoryChannelKeys this_ptr_conv;
7503 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7504 this_ptr_conv.is_owned = false;
7505 LDKSecretKey val_ref;
7506 CHECK(*((uint32_t*)val) == 32);
7507 memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7508 InMemoryChannelKeys_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
7511 int8_tArray __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_htlc_base_key(uint32_t this_ptr) {
7512 LDKInMemoryChannelKeys this_ptr_conv;
7513 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7514 this_ptr_conv.is_owned = false;
7515 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7516 memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_htlc_base_key(&this_ptr_conv), 32);
7520 void __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_htlc_base_key(uint32_t this_ptr, int8_tArray val) {
7521 LDKInMemoryChannelKeys this_ptr_conv;
7522 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7523 this_ptr_conv.is_owned = false;
7524 LDKSecretKey val_ref;
7525 CHECK(*((uint32_t*)val) == 32);
7526 memcpy(val_ref.bytes, (uint8_t*)(val + 4), 32);
7527 InMemoryChannelKeys_set_htlc_base_key(&this_ptr_conv, val_ref);
7530 int8_tArray __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_commitment_seed(uint32_t this_ptr) {
7531 LDKInMemoryChannelKeys this_ptr_conv;
7532 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7533 this_ptr_conv.is_owned = false;
7534 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7535 memcpy((uint8_t*)(ret_arr + 4), *InMemoryChannelKeys_get_commitment_seed(&this_ptr_conv), 32);
7539 void __attribute__((visibility("default"))) TS_InMemoryChannelKeys_set_commitment_seed(uint32_t this_ptr, int8_tArray val) {
7540 LDKInMemoryChannelKeys this_ptr_conv;
7541 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7542 this_ptr_conv.is_owned = false;
7543 LDKThirtyTwoBytes val_ref;
7544 CHECK(*((uint32_t*)val) == 32);
7545 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7546 InMemoryChannelKeys_set_commitment_seed(&this_ptr_conv, val_ref);
7549 uint32_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_new(int8_tArray funding_key, int8_tArray revocation_base_key, int8_tArray payment_key, int8_tArray delayed_payment_base_key, int8_tArray htlc_base_key, int8_tArray commitment_seed, int64_t channel_value_satoshis, uint32_t key_derivation_params) {
7550 LDKSecretKey funding_key_ref;
7551 CHECK(*((uint32_t*)funding_key) == 32);
7552 memcpy(funding_key_ref.bytes, (uint8_t*)(funding_key + 4), 32);
7553 LDKSecretKey revocation_base_key_ref;
7554 CHECK(*((uint32_t*)revocation_base_key) == 32);
7555 memcpy(revocation_base_key_ref.bytes, (uint8_t*)(revocation_base_key + 4), 32);
7556 LDKSecretKey payment_key_ref;
7557 CHECK(*((uint32_t*)payment_key) == 32);
7558 memcpy(payment_key_ref.bytes, (uint8_t*)(payment_key + 4), 32);
7559 LDKSecretKey delayed_payment_base_key_ref;
7560 CHECK(*((uint32_t*)delayed_payment_base_key) == 32);
7561 memcpy(delayed_payment_base_key_ref.bytes, (uint8_t*)(delayed_payment_base_key + 4), 32);
7562 LDKSecretKey htlc_base_key_ref;
7563 CHECK(*((uint32_t*)htlc_base_key) == 32);
7564 memcpy(htlc_base_key_ref.bytes, (uint8_t*)(htlc_base_key + 4), 32);
7565 LDKThirtyTwoBytes commitment_seed_ref;
7566 CHECK(*((uint32_t*)commitment_seed) == 32);
7567 memcpy(commitment_seed_ref.data, (uint8_t*)(commitment_seed + 4), 32);
7568 LDKC2Tuple_u64u64Z key_derivation_params_conv = *(LDKC2Tuple_u64u64Z*)key_derivation_params;
7569 FREE((void*)key_derivation_params);
7570 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);
7571 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7572 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7573 long ret_ref = (long)ret_var.inner;
7574 if (ret_var.is_owned) {
7580 uint32_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_counterparty_pubkeys(uint32_t this_arg) {
7581 LDKInMemoryChannelKeys this_arg_conv;
7582 this_arg_conv.inner = (void*)(this_arg & (~1));
7583 this_arg_conv.is_owned = false;
7584 LDKChannelPublicKeys ret_var = InMemoryChannelKeys_counterparty_pubkeys(&this_arg_conv);
7585 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7586 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7587 long ret_ref = (long)ret_var.inner;
7588 if (ret_var.is_owned) {
7594 int16_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_counterparty_selected_contest_delay(uint32_t this_arg) {
7595 LDKInMemoryChannelKeys this_arg_conv;
7596 this_arg_conv.inner = (void*)(this_arg & (~1));
7597 this_arg_conv.is_owned = false;
7598 int16_t ret_val = InMemoryChannelKeys_counterparty_selected_contest_delay(&this_arg_conv);
7602 int16_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_holder_selected_contest_delay(uint32_t this_arg) {
7603 LDKInMemoryChannelKeys this_arg_conv;
7604 this_arg_conv.inner = (void*)(this_arg & (~1));
7605 this_arg_conv.is_owned = false;
7606 int16_t ret_val = InMemoryChannelKeys_holder_selected_contest_delay(&this_arg_conv);
7610 jboolean __attribute__((visibility("default"))) TS_InMemoryChannelKeys_is_outbound(uint32_t this_arg) {
7611 LDKInMemoryChannelKeys this_arg_conv;
7612 this_arg_conv.inner = (void*)(this_arg & (~1));
7613 this_arg_conv.is_owned = false;
7614 jboolean ret_val = InMemoryChannelKeys_is_outbound(&this_arg_conv);
7618 uint32_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_funding_outpoint(uint32_t this_arg) {
7619 LDKInMemoryChannelKeys this_arg_conv;
7620 this_arg_conv.inner = (void*)(this_arg & (~1));
7621 this_arg_conv.is_owned = false;
7622 LDKOutPoint ret_var = InMemoryChannelKeys_funding_outpoint(&this_arg_conv);
7623 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7624 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7625 long ret_ref = (long)ret_var.inner;
7626 if (ret_var.is_owned) {
7632 uint32_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_get_channel_parameters(uint32_t this_arg) {
7633 LDKInMemoryChannelKeys this_arg_conv;
7634 this_arg_conv.inner = (void*)(this_arg & (~1));
7635 this_arg_conv.is_owned = false;
7636 LDKChannelTransactionParameters ret_var = InMemoryChannelKeys_get_channel_parameters(&this_arg_conv);
7637 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7638 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7639 long ret_ref = (long)ret_var.inner;
7640 if (ret_var.is_owned) {
7646 uint32_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_as_ChannelKeys(uint32_t this_arg) {
7647 LDKInMemoryChannelKeys this_arg_conv;
7648 this_arg_conv.inner = (void*)(this_arg & (~1));
7649 this_arg_conv.is_owned = false;
7650 LDKChannelKeys* ret = MALLOC(sizeof(LDKChannelKeys), "LDKChannelKeys");
7651 *ret = InMemoryChannelKeys_as_ChannelKeys(&this_arg_conv);
7655 int8_tArray __attribute__((visibility("default"))) TS_InMemoryChannelKeys_write(uint32_t obj) {
7656 LDKInMemoryChannelKeys obj_conv;
7657 obj_conv.inner = (void*)(obj & (~1));
7658 obj_conv.is_owned = false;
7659 LDKCVec_u8Z arg_var = InMemoryChannelKeys_write(&obj_conv);
7660 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
7661 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
7662 CVec_u8Z_free(arg_var);
7666 uint32_t __attribute__((visibility("default"))) TS_InMemoryChannelKeys_read(int8_tArray ser) {
7668 ser_ref.datalen = *((uint32_t*)ser);
7669 ser_ref.data = (int8_t*)(ser + 4);
7670 LDKCResult_InMemoryChannelKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemoryChannelKeysDecodeErrorZ), "LDKCResult_InMemoryChannelKeysDecodeErrorZ");
7671 *ret_conv = InMemoryChannelKeys_read(ser_ref);
7672 return (long)ret_conv;
7675 void __attribute__((visibility("default"))) TS_KeysManager_free(uint32_t this_ptr) {
7676 LDKKeysManager this_ptr_conv;
7677 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7678 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7679 KeysManager_free(this_ptr_conv);
7682 uint32_t __attribute__((visibility("default"))) TS_KeysManager_new(int8_tArray seed, uint32_t network, int64_t starting_time_secs, int32_t starting_time_nanos) {
7683 unsigned char seed_arr[32];
7684 CHECK(*((uint32_t*)seed) == 32);
7685 memcpy(seed_arr, (uint8_t*)(seed + 4), 32);
7686 unsigned char (*seed_ref)[32] = &seed_arr;
7687 LDKNetwork network_conv = LDKNetwork_from_js(network);
7688 LDKKeysManager ret_var = KeysManager_new(seed_ref, network_conv, starting_time_secs, starting_time_nanos);
7689 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7690 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7691 long ret_ref = (long)ret_var.inner;
7692 if (ret_var.is_owned) {
7698 uint32_t __attribute__((visibility("default"))) TS_KeysManager_derive_channel_keys(uint32_t this_arg, int64_t channel_value_satoshis, int64_t params_1, int64_t params_2) {
7699 LDKKeysManager this_arg_conv;
7700 this_arg_conv.inner = (void*)(this_arg & (~1));
7701 this_arg_conv.is_owned = false;
7702 LDKInMemoryChannelKeys ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_1, params_2);
7703 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7704 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7705 long ret_ref = (long)ret_var.inner;
7706 if (ret_var.is_owned) {
7712 uint32_t __attribute__((visibility("default"))) TS_KeysManager_as_KeysInterface(uint32_t this_arg) {
7713 LDKKeysManager this_arg_conv;
7714 this_arg_conv.inner = (void*)(this_arg & (~1));
7715 this_arg_conv.is_owned = false;
7716 LDKKeysInterface* ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7717 *ret = KeysManager_as_KeysInterface(&this_arg_conv);
7721 void __attribute__((visibility("default"))) TS_ChannelManager_free(uint32_t this_ptr) {
7722 LDKChannelManager this_ptr_conv;
7723 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7724 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7725 ChannelManager_free(this_ptr_conv);
7728 void __attribute__((visibility("default"))) TS_ChannelDetails_free(uint32_t this_ptr) {
7729 LDKChannelDetails this_ptr_conv;
7730 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7731 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7732 ChannelDetails_free(this_ptr_conv);
7735 uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_clone(uint32_t orig) {
7736 LDKChannelDetails orig_conv;
7737 orig_conv.inner = (void*)(orig & (~1));
7738 orig_conv.is_owned = false;
7739 LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
7740 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7741 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7742 long ret_ref = (long)ret_var.inner;
7743 if (ret_var.is_owned) {
7749 int8_tArray __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_id(uint32_t this_ptr) {
7750 LDKChannelDetails this_ptr_conv;
7751 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7752 this_ptr_conv.is_owned = false;
7753 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
7754 memcpy((uint8_t*)(ret_arr + 4), *ChannelDetails_get_channel_id(&this_ptr_conv), 32);
7758 void __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_id(uint32_t this_ptr, int8_tArray val) {
7759 LDKChannelDetails this_ptr_conv;
7760 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7761 this_ptr_conv.is_owned = false;
7762 LDKThirtyTwoBytes val_ref;
7763 CHECK(*((uint32_t*)val) == 32);
7764 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
7765 ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
7768 int8_tArray __attribute__((visibility("default"))) TS_ChannelDetails_get_remote_network_id(uint32_t this_ptr) {
7769 LDKChannelDetails this_ptr_conv;
7770 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7771 this_ptr_conv.is_owned = false;
7772 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
7773 memcpy((uint8_t*)(arg_arr + 4), ChannelDetails_get_remote_network_id(&this_ptr_conv).compressed_form, 33);
7777 void __attribute__((visibility("default"))) TS_ChannelDetails_set_remote_network_id(uint32_t this_ptr, int8_tArray val) {
7778 LDKChannelDetails this_ptr_conv;
7779 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7780 this_ptr_conv.is_owned = false;
7781 LDKPublicKey val_ref;
7782 CHECK(*((uint32_t*)val) == 33);
7783 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
7784 ChannelDetails_set_remote_network_id(&this_ptr_conv, val_ref);
7787 uint32_t __attribute__((visibility("default"))) TS_ChannelDetails_get_counterparty_features(uint32_t this_ptr) {
7788 LDKChannelDetails this_ptr_conv;
7789 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7790 this_ptr_conv.is_owned = false;
7791 LDKInitFeatures ret_var = ChannelDetails_get_counterparty_features(&this_ptr_conv);
7792 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7793 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7794 long ret_ref = (long)ret_var.inner;
7795 if (ret_var.is_owned) {
7801 void __attribute__((visibility("default"))) TS_ChannelDetails_set_counterparty_features(uint32_t this_ptr, uint32_t val) {
7802 LDKChannelDetails this_ptr_conv;
7803 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7804 this_ptr_conv.is_owned = false;
7805 LDKInitFeatures val_conv;
7806 val_conv.inner = (void*)(val & (~1));
7807 val_conv.is_owned = (val & 1) || (val == 0);
7808 // Warning: we may need a move here but can't clone!
7809 ChannelDetails_set_counterparty_features(&this_ptr_conv, val_conv);
7812 int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_channel_value_satoshis(uint32_t this_ptr) {
7813 LDKChannelDetails this_ptr_conv;
7814 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7815 this_ptr_conv.is_owned = false;
7816 int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
7820 void __attribute__((visibility("default"))) TS_ChannelDetails_set_channel_value_satoshis(uint32_t this_ptr, int64_t val) {
7821 LDKChannelDetails this_ptr_conv;
7822 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7823 this_ptr_conv.is_owned = false;
7824 ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
7827 int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_user_id(uint32_t this_ptr) {
7828 LDKChannelDetails this_ptr_conv;
7829 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7830 this_ptr_conv.is_owned = false;
7831 int64_t ret_val = ChannelDetails_get_user_id(&this_ptr_conv);
7835 void __attribute__((visibility("default"))) TS_ChannelDetails_set_user_id(uint32_t this_ptr, int64_t val) {
7836 LDKChannelDetails this_ptr_conv;
7837 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7838 this_ptr_conv.is_owned = false;
7839 ChannelDetails_set_user_id(&this_ptr_conv, val);
7842 int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_outbound_capacity_msat(uint32_t this_ptr) {
7843 LDKChannelDetails this_ptr_conv;
7844 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7845 this_ptr_conv.is_owned = false;
7846 int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
7850 void __attribute__((visibility("default"))) TS_ChannelDetails_set_outbound_capacity_msat(uint32_t this_ptr, int64_t val) {
7851 LDKChannelDetails this_ptr_conv;
7852 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7853 this_ptr_conv.is_owned = false;
7854 ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
7857 int64_t __attribute__((visibility("default"))) TS_ChannelDetails_get_inbound_capacity_msat(uint32_t this_ptr) {
7858 LDKChannelDetails this_ptr_conv;
7859 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7860 this_ptr_conv.is_owned = false;
7861 int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
7865 void __attribute__((visibility("default"))) TS_ChannelDetails_set_inbound_capacity_msat(uint32_t this_ptr, int64_t val) {
7866 LDKChannelDetails this_ptr_conv;
7867 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7868 this_ptr_conv.is_owned = false;
7869 ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
7872 jboolean __attribute__((visibility("default"))) TS_ChannelDetails_get_is_live(uint32_t this_ptr) {
7873 LDKChannelDetails this_ptr_conv;
7874 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7875 this_ptr_conv.is_owned = false;
7876 jboolean ret_val = ChannelDetails_get_is_live(&this_ptr_conv);
7880 void __attribute__((visibility("default"))) TS_ChannelDetails_set_is_live(uint32_t this_ptr, jboolean val) {
7881 LDKChannelDetails this_ptr_conv;
7882 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7883 this_ptr_conv.is_owned = false;
7884 ChannelDetails_set_is_live(&this_ptr_conv, val);
7887 void __attribute__((visibility("default"))) TS_PaymentSendFailure_free(uint32_t this_ptr) {
7888 LDKPaymentSendFailure this_ptr_conv;
7889 this_ptr_conv.inner = (void*)(this_ptr & (~1));
7890 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
7891 PaymentSendFailure_free(this_ptr_conv);
7894 uint32_t __attribute__((visibility("default"))) TS_ChannelManager_new(uint32_t network, uint32_t fee_est, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t keys_manager, uint32_t config, intptr_t current_blockchain_height) {
7895 LDKNetwork network_conv = LDKNetwork_from_js(network);
7896 LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)fee_est;
7897 LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
7898 LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
7899 LDKLogger logger_conv = *(LDKLogger*)logger;
7900 LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
7901 LDKUserConfig config_conv;
7902 config_conv.inner = (void*)(config & (~1));
7903 config_conv.is_owned = (config & 1) || (config == 0);
7904 if (config_conv.inner != NULL)
7905 config_conv = UserConfig_clone(&config_conv);
7906 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);
7907 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7908 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7909 long ret_ref = (long)ret_var.inner;
7910 if (ret_var.is_owned) {
7916 uint32_t __attribute__((visibility("default"))) TS_ChannelManager_create_channel(uint32_t this_arg, int8_tArray their_network_key, int64_t channel_value_satoshis, int64_t push_msat, int64_t user_id, uint32_t override_config) {
7917 LDKChannelManager this_arg_conv;
7918 this_arg_conv.inner = (void*)(this_arg & (~1));
7919 this_arg_conv.is_owned = false;
7920 LDKPublicKey their_network_key_ref;
7921 CHECK(*((uint32_t*)their_network_key) == 33);
7922 memcpy(their_network_key_ref.compressed_form, (uint8_t*)(their_network_key + 4), 33);
7923 LDKUserConfig override_config_conv;
7924 override_config_conv.inner = (void*)(override_config & (~1));
7925 override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
7926 if (override_config_conv.inner != NULL)
7927 override_config_conv = UserConfig_clone(&override_config_conv);
7928 LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7929 *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_id, override_config_conv);
7930 return (long)ret_conv;
7933 uint32_tArray __attribute__((visibility("default"))) TS_ChannelManager_list_channels(uint32_t this_arg) {
7934 LDKChannelManager this_arg_conv;
7935 this_arg_conv.inner = (void*)(this_arg & (~1));
7936 this_arg_conv.is_owned = false;
7937 LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
7938 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7939 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7940 for (size_t q = 0; q < ret_var.datalen; q++) {
7941 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
7942 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7943 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7944 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
7945 if (arr_conv_16_var.is_owned) {
7946 arr_conv_16_ref |= 1;
7948 ret_arr_ptr[q] = arr_conv_16_ref;
7954 uint32_tArray __attribute__((visibility("default"))) TS_ChannelManager_list_usable_channels(uint32_t this_arg) {
7955 LDKChannelManager this_arg_conv;
7956 this_arg_conv.inner = (void*)(this_arg & (~1));
7957 this_arg_conv.is_owned = false;
7958 LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
7959 uint32_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
7960 uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
7961 for (size_t q = 0; q < ret_var.datalen; q++) {
7962 LDKChannelDetails arr_conv_16_var = ret_var.data[q];
7963 CHECK((((long)arr_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7964 CHECK((((long)&arr_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7965 long arr_conv_16_ref = (long)arr_conv_16_var.inner;
7966 if (arr_conv_16_var.is_owned) {
7967 arr_conv_16_ref |= 1;
7969 ret_arr_ptr[q] = arr_conv_16_ref;
7975 uint32_t __attribute__((visibility("default"))) TS_ChannelManager_close_channel(uint32_t this_arg, int8_tArray channel_id) {
7976 LDKChannelManager this_arg_conv;
7977 this_arg_conv.inner = (void*)(this_arg & (~1));
7978 this_arg_conv.is_owned = false;
7979 unsigned char channel_id_arr[32];
7980 CHECK(*((uint32_t*)channel_id) == 32);
7981 memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
7982 unsigned char (*channel_id_ref)[32] = &channel_id_arr;
7983 LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
7984 *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
7985 return (long)ret_conv;
7988 void __attribute__((visibility("default"))) TS_ChannelManager_force_close_channel(uint32_t this_arg, int8_tArray channel_id) {
7989 LDKChannelManager this_arg_conv;
7990 this_arg_conv.inner = (void*)(this_arg & (~1));
7991 this_arg_conv.is_owned = false;
7992 unsigned char channel_id_arr[32];
7993 CHECK(*((uint32_t*)channel_id) == 32);
7994 memcpy(channel_id_arr, (uint8_t*)(channel_id + 4), 32);
7995 unsigned char (*channel_id_ref)[32] = &channel_id_arr;
7996 ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
7999 void __attribute__((visibility("default"))) TS_ChannelManager_force_close_all_channels(uint32_t this_arg) {
8000 LDKChannelManager this_arg_conv;
8001 this_arg_conv.inner = (void*)(this_arg & (~1));
8002 this_arg_conv.is_owned = false;
8003 ChannelManager_force_close_all_channels(&this_arg_conv);
8006 uint32_t __attribute__((visibility("default"))) TS_ChannelManager_send_payment(uint32_t this_arg, uint32_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
8007 LDKChannelManager this_arg_conv;
8008 this_arg_conv.inner = (void*)(this_arg & (~1));
8009 this_arg_conv.is_owned = false;
8010 LDKRoute route_conv;
8011 route_conv.inner = (void*)(route & (~1));
8012 route_conv.is_owned = false;
8013 LDKThirtyTwoBytes payment_hash_ref;
8014 CHECK(*((uint32_t*)payment_hash) == 32);
8015 memcpy(payment_hash_ref.data, (uint8_t*)(payment_hash + 4), 32);
8016 LDKThirtyTwoBytes payment_secret_ref;
8017 CHECK(*((uint32_t*)payment_secret) == 32);
8018 memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8019 LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
8020 *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
8021 return (long)ret_conv;
8024 void __attribute__((visibility("default"))) TS_ChannelManager_funding_transaction_generated(uint32_t this_arg, int8_tArray temporary_channel_id, uint32_t funding_txo) {
8025 LDKChannelManager this_arg_conv;
8026 this_arg_conv.inner = (void*)(this_arg & (~1));
8027 this_arg_conv.is_owned = false;
8028 unsigned char temporary_channel_id_arr[32];
8029 CHECK(*((uint32_t*)temporary_channel_id) == 32);
8030 memcpy(temporary_channel_id_arr, (uint8_t*)(temporary_channel_id + 4), 32);
8031 unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
8032 LDKOutPoint funding_txo_conv;
8033 funding_txo_conv.inner = (void*)(funding_txo & (~1));
8034 funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
8035 if (funding_txo_conv.inner != NULL)
8036 funding_txo_conv = OutPoint_clone(&funding_txo_conv);
8037 ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_txo_conv);
8040 void __attribute__((visibility("default"))) TS_ChannelManager_broadcast_node_announcement(uint32_t this_arg, int8_tArray rgb, int8_tArray alias, uint32_tArray addresses) {
8041 LDKChannelManager this_arg_conv;
8042 this_arg_conv.inner = (void*)(this_arg & (~1));
8043 this_arg_conv.is_owned = false;
8044 LDKThreeBytes rgb_ref;
8045 CHECK(*((uint32_t*)rgb) == 3);
8046 memcpy(rgb_ref.data, (uint8_t*)(rgb + 4), 3);
8047 LDKThirtyTwoBytes alias_ref;
8048 CHECK(*((uint32_t*)alias) == 32);
8049 memcpy(alias_ref.data, (uint8_t*)(alias + 4), 32);
8050 LDKCVec_NetAddressZ addresses_constr;
8051 addresses_constr.datalen = *((uint32_t*)addresses);
8052 if (addresses_constr.datalen > 0)
8053 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
8055 addresses_constr.data = NULL;
8056 uint32_t* addresses_vals = (uint32_t*)(addresses + 4);
8057 for (size_t m = 0; m < addresses_constr.datalen; m++) {
8058 uint32_t arr_conv_12 = addresses_vals[m];
8059 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
8060 FREE((void*)arr_conv_12);
8061 addresses_constr.data[m] = arr_conv_12_conv;
8063 ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
8066 void __attribute__((visibility("default"))) TS_ChannelManager_process_pending_htlc_forwards(uint32_t this_arg) {
8067 LDKChannelManager this_arg_conv;
8068 this_arg_conv.inner = (void*)(this_arg & (~1));
8069 this_arg_conv.is_owned = false;
8070 ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
8073 void __attribute__((visibility("default"))) TS_ChannelManager_timer_chan_freshness_every_min(uint32_t this_arg) {
8074 LDKChannelManager this_arg_conv;
8075 this_arg_conv.inner = (void*)(this_arg & (~1));
8076 this_arg_conv.is_owned = false;
8077 ChannelManager_timer_chan_freshness_every_min(&this_arg_conv);
8080 jboolean __attribute__((visibility("default"))) TS_ChannelManager_fail_htlc_backwards(uint32_t this_arg, int8_tArray payment_hash, int8_tArray payment_secret) {
8081 LDKChannelManager this_arg_conv;
8082 this_arg_conv.inner = (void*)(this_arg & (~1));
8083 this_arg_conv.is_owned = false;
8084 unsigned char payment_hash_arr[32];
8085 CHECK(*((uint32_t*)payment_hash) == 32);
8086 memcpy(payment_hash_arr, (uint8_t*)(payment_hash + 4), 32);
8087 unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
8088 LDKThirtyTwoBytes payment_secret_ref;
8089 CHECK(*((uint32_t*)payment_secret) == 32);
8090 memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8091 jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref, payment_secret_ref);
8095 jboolean __attribute__((visibility("default"))) TS_ChannelManager_claim_funds(uint32_t this_arg, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t expected_amount) {
8096 LDKChannelManager this_arg_conv;
8097 this_arg_conv.inner = (void*)(this_arg & (~1));
8098 this_arg_conv.is_owned = false;
8099 LDKThirtyTwoBytes payment_preimage_ref;
8100 CHECK(*((uint32_t*)payment_preimage) == 32);
8101 memcpy(payment_preimage_ref.data, (uint8_t*)(payment_preimage + 4), 32);
8102 LDKThirtyTwoBytes payment_secret_ref;
8103 CHECK(*((uint32_t*)payment_secret) == 32);
8104 memcpy(payment_secret_ref.data, (uint8_t*)(payment_secret + 4), 32);
8105 jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref, payment_secret_ref, expected_amount);
8109 int8_tArray __attribute__((visibility("default"))) TS_ChannelManager_get_our_node_id(uint32_t this_arg) {
8110 LDKChannelManager this_arg_conv;
8111 this_arg_conv.inner = (void*)(this_arg & (~1));
8112 this_arg_conv.is_owned = false;
8113 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8114 memcpy((uint8_t*)(arg_arr + 4), ChannelManager_get_our_node_id(&this_arg_conv).compressed_form, 33);
8118 void __attribute__((visibility("default"))) TS_ChannelManager_channel_monitor_updated(uint32_t this_arg, uint32_t funding_txo, int64_t highest_applied_update_id) {
8119 LDKChannelManager this_arg_conv;
8120 this_arg_conv.inner = (void*)(this_arg & (~1));
8121 this_arg_conv.is_owned = false;
8122 LDKOutPoint funding_txo_conv;
8123 funding_txo_conv.inner = (void*)(funding_txo & (~1));
8124 funding_txo_conv.is_owned = false;
8125 ChannelManager_channel_monitor_updated(&this_arg_conv, &funding_txo_conv, highest_applied_update_id);
8128 uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_MessageSendEventsProvider(uint32_t this_arg) {
8129 LDKChannelManager this_arg_conv;
8130 this_arg_conv.inner = (void*)(this_arg & (~1));
8131 this_arg_conv.is_owned = false;
8132 LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
8133 *ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
8137 uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_EventsProvider(uint32_t this_arg) {
8138 LDKChannelManager this_arg_conv;
8139 this_arg_conv.inner = (void*)(this_arg & (~1));
8140 this_arg_conv.is_owned = false;
8141 LDKEventsProvider* ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
8142 *ret = ChannelManager_as_EventsProvider(&this_arg_conv);
8146 void __attribute__((visibility("default"))) TS_ChannelManager_block_connected(uint32_t this_arg, int8_tArray header, uint32_tArray txdata, int32_t height) {
8147 LDKChannelManager this_arg_conv;
8148 this_arg_conv.inner = (void*)(this_arg & (~1));
8149 this_arg_conv.is_owned = false;
8150 unsigned char header_arr[80];
8151 CHECK(*((uint32_t*)header) == 80);
8152 memcpy(header_arr, (uint8_t*)(header + 4), 80);
8153 unsigned char (*header_ref)[80] = &header_arr;
8154 LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
8155 txdata_constr.datalen = *((uint32_t*)txdata);
8156 if (txdata_constr.datalen > 0)
8157 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
8159 txdata_constr.data = NULL;
8160 uint32_t* txdata_vals = (uint32_t*)(txdata + 4);
8161 for (size_t e = 0; e < txdata_constr.datalen; e++) {
8162 uint32_t arr_conv_30 = txdata_vals[e];
8163 LDKC2Tuple_usizeTransactionZ arr_conv_30_conv = *(LDKC2Tuple_usizeTransactionZ*)arr_conv_30;
8164 FREE((void*)arr_conv_30);
8165 txdata_constr.data[e] = arr_conv_30_conv;
8167 ChannelManager_block_connected(&this_arg_conv, header_ref, txdata_constr, height);
8170 void __attribute__((visibility("default"))) TS_ChannelManager_block_disconnected(uint32_t this_arg, int8_tArray header) {
8171 LDKChannelManager this_arg_conv;
8172 this_arg_conv.inner = (void*)(this_arg & (~1));
8173 this_arg_conv.is_owned = false;
8174 unsigned char header_arr[80];
8175 CHECK(*((uint32_t*)header) == 80);
8176 memcpy(header_arr, (uint8_t*)(header + 4), 80);
8177 unsigned char (*header_ref)[80] = &header_arr;
8178 ChannelManager_block_disconnected(&this_arg_conv, header_ref);
8181 uint32_t __attribute__((visibility("default"))) TS_ChannelManager_as_ChannelMessageHandler(uint32_t this_arg) {
8182 LDKChannelManager this_arg_conv;
8183 this_arg_conv.inner = (void*)(this_arg & (~1));
8184 this_arg_conv.is_owned = false;
8185 LDKChannelMessageHandler* ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8186 *ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
8190 int8_tArray __attribute__((visibility("default"))) TS_ChannelManager_write(uint32_t obj) {
8191 LDKChannelManager obj_conv;
8192 obj_conv.inner = (void*)(obj & (~1));
8193 obj_conv.is_owned = false;
8194 LDKCVec_u8Z arg_var = ChannelManager_write(&obj_conv);
8195 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
8196 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
8197 CVec_u8Z_free(arg_var);
8201 void __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_free(uint32_t this_ptr) {
8202 LDKChannelManagerReadArgs this_ptr_conv;
8203 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8204 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8205 ChannelManagerReadArgs_free(this_ptr_conv);
8208 uint32_t __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_keys_manager(uint32_t this_ptr) {
8209 LDKChannelManagerReadArgs this_ptr_conv;
8210 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8211 this_ptr_conv.is_owned = false;
8212 long ret_ret = (long)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv);
8216 void __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_keys_manager(uint32_t this_ptr, uint32_t val) {
8217 LDKChannelManagerReadArgs this_ptr_conv;
8218 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8219 this_ptr_conv.is_owned = false;
8220 LDKKeysInterface val_conv = *(LDKKeysInterface*)val;
8221 ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
8224 uint32_t __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_fee_estimator(uint32_t this_ptr) {
8225 LDKChannelManagerReadArgs this_ptr_conv;
8226 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8227 this_ptr_conv.is_owned = false;
8228 long ret_ret = (long)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv);
8232 void __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_fee_estimator(uint32_t this_ptr, uint32_t val) {
8233 LDKChannelManagerReadArgs this_ptr_conv;
8234 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8235 this_ptr_conv.is_owned = false;
8236 LDKFeeEstimator val_conv = *(LDKFeeEstimator*)val;
8237 ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
8240 uint32_t __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_chain_monitor(uint32_t this_ptr) {
8241 LDKChannelManagerReadArgs this_ptr_conv;
8242 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8243 this_ptr_conv.is_owned = false;
8244 long ret_ret = (long)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv);
8248 void __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_chain_monitor(uint32_t this_ptr, uint32_t val) {
8249 LDKChannelManagerReadArgs this_ptr_conv;
8250 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8251 this_ptr_conv.is_owned = false;
8252 LDKWatch val_conv = *(LDKWatch*)val;
8253 ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
8256 uint32_t __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_tx_broadcaster(uint32_t this_ptr) {
8257 LDKChannelManagerReadArgs this_ptr_conv;
8258 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8259 this_ptr_conv.is_owned = false;
8260 long ret_ret = (long)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv);
8264 void __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_tx_broadcaster(uint32_t this_ptr, uint32_t val) {
8265 LDKChannelManagerReadArgs this_ptr_conv;
8266 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8267 this_ptr_conv.is_owned = false;
8268 LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)val;
8269 ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
8272 uint32_t __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_logger(uint32_t this_ptr) {
8273 LDKChannelManagerReadArgs this_ptr_conv;
8274 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8275 this_ptr_conv.is_owned = false;
8276 long ret_ret = (long)ChannelManagerReadArgs_get_logger(&this_ptr_conv);
8280 void __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_logger(uint32_t this_ptr, uint32_t val) {
8281 LDKChannelManagerReadArgs this_ptr_conv;
8282 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8283 this_ptr_conv.is_owned = false;
8284 LDKLogger val_conv = *(LDKLogger*)val;
8285 ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
8288 uint32_t __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_get_default_config(uint32_t this_ptr) {
8289 LDKChannelManagerReadArgs this_ptr_conv;
8290 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8291 this_ptr_conv.is_owned = false;
8292 LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
8293 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8294 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8295 long ret_ref = (long)ret_var.inner;
8296 if (ret_var.is_owned) {
8302 void __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_set_default_config(uint32_t this_ptr, uint32_t val) {
8303 LDKChannelManagerReadArgs this_ptr_conv;
8304 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8305 this_ptr_conv.is_owned = false;
8306 LDKUserConfig val_conv;
8307 val_conv.inner = (void*)(val & (~1));
8308 val_conv.is_owned = (val & 1) || (val == 0);
8309 if (val_conv.inner != NULL)
8310 val_conv = UserConfig_clone(&val_conv);
8311 ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
8314 uint32_t __attribute__((visibility("default"))) TS_ChannelManagerReadArgs_new(uint32_t keys_manager, uint32_t fee_estimator, uint32_t chain_monitor, uint32_t tx_broadcaster, uint32_t logger, uint32_t default_config, uint32_tArray channel_monitors) {
8315 LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)keys_manager;
8316 LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)fee_estimator;
8317 LDKWatch chain_monitor_conv = *(LDKWatch*)chain_monitor;
8318 LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)tx_broadcaster;
8319 LDKLogger logger_conv = *(LDKLogger*)logger;
8320 LDKUserConfig default_config_conv;
8321 default_config_conv.inner = (void*)(default_config & (~1));
8322 default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
8323 if (default_config_conv.inner != NULL)
8324 default_config_conv = UserConfig_clone(&default_config_conv);
8325 LDKCVec_ChannelMonitorZ channel_monitors_constr;
8326 channel_monitors_constr.datalen = *((uint32_t*)channel_monitors);
8327 if (channel_monitors_constr.datalen > 0)
8328 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
8330 channel_monitors_constr.data = NULL;
8331 uint32_t* channel_monitors_vals = (uint32_t*)(channel_monitors + 4);
8332 for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
8333 uint32_t arr_conv_16 = channel_monitors_vals[q];
8334 LDKChannelMonitor arr_conv_16_conv;
8335 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
8336 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
8337 // Warning: we may need a move here but can't clone!
8338 channel_monitors_constr.data[q] = arr_conv_16_conv;
8340 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);
8341 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8342 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8343 long ret_ref = (long)ret_var.inner;
8344 if (ret_var.is_owned) {
8350 uint32_t __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_read(int8_tArray ser, uint32_t arg) {
8352 ser_ref.datalen = *((uint32_t*)ser);
8353 ser_ref.data = (int8_t*)(ser + 4);
8354 LDKChannelManagerReadArgs arg_conv;
8355 arg_conv.inner = (void*)(arg & (~1));
8356 arg_conv.is_owned = (arg & 1) || (arg == 0);
8357 // Warning: we may need a move here but can't clone!
8358 LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
8359 *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
8360 return (long)ret_conv;
8363 void __attribute__((visibility("default"))) TS_DecodeError_free(uint32_t this_ptr) {
8364 LDKDecodeError this_ptr_conv;
8365 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8366 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8367 DecodeError_free(this_ptr_conv);
8370 void __attribute__((visibility("default"))) TS_Init_free(uint32_t this_ptr) {
8371 LDKInit this_ptr_conv;
8372 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8373 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8374 Init_free(this_ptr_conv);
8377 uint32_t __attribute__((visibility("default"))) TS_Init_clone(uint32_t orig) {
8379 orig_conv.inner = (void*)(orig & (~1));
8380 orig_conv.is_owned = false;
8381 LDKInit ret_var = Init_clone(&orig_conv);
8382 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8383 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8384 long ret_ref = (long)ret_var.inner;
8385 if (ret_var.is_owned) {
8391 void __attribute__((visibility("default"))) TS_ErrorMessage_free(uint32_t this_ptr) {
8392 LDKErrorMessage this_ptr_conv;
8393 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8394 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8395 ErrorMessage_free(this_ptr_conv);
8398 uint32_t __attribute__((visibility("default"))) TS_ErrorMessage_clone(uint32_t orig) {
8399 LDKErrorMessage orig_conv;
8400 orig_conv.inner = (void*)(orig & (~1));
8401 orig_conv.is_owned = false;
8402 LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
8403 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8404 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8405 long ret_ref = (long)ret_var.inner;
8406 if (ret_var.is_owned) {
8412 int8_tArray __attribute__((visibility("default"))) TS_ErrorMessage_get_channel_id(uint32_t this_ptr) {
8413 LDKErrorMessage this_ptr_conv;
8414 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8415 this_ptr_conv.is_owned = false;
8416 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8417 memcpy((uint8_t*)(ret_arr + 4), *ErrorMessage_get_channel_id(&this_ptr_conv), 32);
8421 void __attribute__((visibility("default"))) TS_ErrorMessage_set_channel_id(uint32_t this_ptr, int8_tArray val) {
8422 LDKErrorMessage this_ptr_conv;
8423 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8424 this_ptr_conv.is_owned = false;
8425 LDKThirtyTwoBytes val_ref;
8426 CHECK(*((uint32_t*)val) == 32);
8427 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8428 ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
8431 jstring __attribute__((visibility("default"))) TS_ErrorMessage_get_data(uint32_t this_ptr) {
8432 LDKErrorMessage this_ptr_conv;
8433 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8434 this_ptr_conv.is_owned = false;
8435 LDKStr _str = ErrorMessage_get_data(&this_ptr_conv);
8436 jstring _conv = str_ref_to_ts(_str.chars, _str.len);
8440 void __attribute__((visibility("default"))) TS_ErrorMessage_set_data(uint32_t this_ptr, int8_tArray val) {
8441 LDKErrorMessage this_ptr_conv;
8442 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8443 this_ptr_conv.is_owned = false;
8444 LDKCVec_u8Z val_ref;
8445 val_ref.datalen = *((uint32_t*)val);
8446 val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
8447 memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
8448 ErrorMessage_set_data(&this_ptr_conv, val_ref);
8451 uint32_t __attribute__((visibility("default"))) TS_ErrorMessage_new(int8_tArray channel_id_arg, int8_tArray data_arg) {
8452 LDKThirtyTwoBytes channel_id_arg_ref;
8453 CHECK(*((uint32_t*)channel_id_arg) == 32);
8454 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
8455 LDKCVec_u8Z data_arg_ref;
8456 data_arg_ref.datalen = *((uint32_t*)data_arg);
8457 data_arg_ref.data = MALLOC(data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
8458 memcpy(data_arg_ref.data, (uint8_t*)(data_arg + 4), data_arg_ref.datalen);
8459 LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_ref);
8460 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8461 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8462 long ret_ref = (long)ret_var.inner;
8463 if (ret_var.is_owned) {
8469 void __attribute__((visibility("default"))) TS_Ping_free(uint32_t this_ptr) {
8470 LDKPing this_ptr_conv;
8471 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8472 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8473 Ping_free(this_ptr_conv);
8476 uint32_t __attribute__((visibility("default"))) TS_Ping_clone(uint32_t orig) {
8478 orig_conv.inner = (void*)(orig & (~1));
8479 orig_conv.is_owned = false;
8480 LDKPing ret_var = Ping_clone(&orig_conv);
8481 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8482 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8483 long ret_ref = (long)ret_var.inner;
8484 if (ret_var.is_owned) {
8490 int16_t __attribute__((visibility("default"))) TS_Ping_get_ponglen(uint32_t this_ptr) {
8491 LDKPing this_ptr_conv;
8492 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8493 this_ptr_conv.is_owned = false;
8494 int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
8498 void __attribute__((visibility("default"))) TS_Ping_set_ponglen(uint32_t this_ptr, int16_t val) {
8499 LDKPing this_ptr_conv;
8500 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8501 this_ptr_conv.is_owned = false;
8502 Ping_set_ponglen(&this_ptr_conv, val);
8505 int16_t __attribute__((visibility("default"))) TS_Ping_get_byteslen(uint32_t this_ptr) {
8506 LDKPing this_ptr_conv;
8507 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8508 this_ptr_conv.is_owned = false;
8509 int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
8513 void __attribute__((visibility("default"))) TS_Ping_set_byteslen(uint32_t this_ptr, int16_t val) {
8514 LDKPing this_ptr_conv;
8515 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8516 this_ptr_conv.is_owned = false;
8517 Ping_set_byteslen(&this_ptr_conv, val);
8520 uint32_t __attribute__((visibility("default"))) TS_Ping_new(int16_t ponglen_arg, int16_t byteslen_arg) {
8521 LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
8522 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8523 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8524 long ret_ref = (long)ret_var.inner;
8525 if (ret_var.is_owned) {
8531 void __attribute__((visibility("default"))) TS_Pong_free(uint32_t this_ptr) {
8532 LDKPong this_ptr_conv;
8533 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8534 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8535 Pong_free(this_ptr_conv);
8538 uint32_t __attribute__((visibility("default"))) TS_Pong_clone(uint32_t orig) {
8540 orig_conv.inner = (void*)(orig & (~1));
8541 orig_conv.is_owned = false;
8542 LDKPong ret_var = Pong_clone(&orig_conv);
8543 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8544 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8545 long ret_ref = (long)ret_var.inner;
8546 if (ret_var.is_owned) {
8552 int16_t __attribute__((visibility("default"))) TS_Pong_get_byteslen(uint32_t this_ptr) {
8553 LDKPong this_ptr_conv;
8554 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8555 this_ptr_conv.is_owned = false;
8556 int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
8560 void __attribute__((visibility("default"))) TS_Pong_set_byteslen(uint32_t this_ptr, int16_t val) {
8561 LDKPong this_ptr_conv;
8562 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8563 this_ptr_conv.is_owned = false;
8564 Pong_set_byteslen(&this_ptr_conv, val);
8567 uint32_t __attribute__((visibility("default"))) TS_Pong_new(int16_t byteslen_arg) {
8568 LDKPong ret_var = Pong_new(byteslen_arg);
8569 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8570 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8571 long ret_ref = (long)ret_var.inner;
8572 if (ret_var.is_owned) {
8578 void __attribute__((visibility("default"))) TS_OpenChannel_free(uint32_t this_ptr) {
8579 LDKOpenChannel this_ptr_conv;
8580 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8581 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8582 OpenChannel_free(this_ptr_conv);
8585 uint32_t __attribute__((visibility("default"))) TS_OpenChannel_clone(uint32_t orig) {
8586 LDKOpenChannel orig_conv;
8587 orig_conv.inner = (void*)(orig & (~1));
8588 orig_conv.is_owned = false;
8589 LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
8590 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8591 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8592 long ret_ref = (long)ret_var.inner;
8593 if (ret_var.is_owned) {
8599 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_get_chain_hash(uint32_t this_ptr) {
8600 LDKOpenChannel this_ptr_conv;
8601 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8602 this_ptr_conv.is_owned = false;
8603 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8604 memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_chain_hash(&this_ptr_conv), 32);
8608 void __attribute__((visibility("default"))) TS_OpenChannel_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
8609 LDKOpenChannel this_ptr_conv;
8610 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8611 this_ptr_conv.is_owned = false;
8612 LDKThirtyTwoBytes val_ref;
8613 CHECK(*((uint32_t*)val) == 32);
8614 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8615 OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
8618 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_get_temporary_channel_id(uint32_t this_ptr) {
8619 LDKOpenChannel this_ptr_conv;
8620 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8621 this_ptr_conv.is_owned = false;
8622 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8623 memcpy((uint8_t*)(ret_arr + 4), *OpenChannel_get_temporary_channel_id(&this_ptr_conv), 32);
8627 void __attribute__((visibility("default"))) TS_OpenChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
8628 LDKOpenChannel this_ptr_conv;
8629 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8630 this_ptr_conv.is_owned = false;
8631 LDKThirtyTwoBytes val_ref;
8632 CHECK(*((uint32_t*)val) == 32);
8633 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8634 OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
8637 int64_t __attribute__((visibility("default"))) TS_OpenChannel_get_funding_satoshis(uint32_t this_ptr) {
8638 LDKOpenChannel this_ptr_conv;
8639 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8640 this_ptr_conv.is_owned = false;
8641 int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
8645 void __attribute__((visibility("default"))) TS_OpenChannel_set_funding_satoshis(uint32_t this_ptr, int64_t val) {
8646 LDKOpenChannel this_ptr_conv;
8647 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8648 this_ptr_conv.is_owned = false;
8649 OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
8652 int64_t __attribute__((visibility("default"))) TS_OpenChannel_get_push_msat(uint32_t this_ptr) {
8653 LDKOpenChannel this_ptr_conv;
8654 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8655 this_ptr_conv.is_owned = false;
8656 int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
8660 void __attribute__((visibility("default"))) TS_OpenChannel_set_push_msat(uint32_t this_ptr, int64_t val) {
8661 LDKOpenChannel this_ptr_conv;
8662 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8663 this_ptr_conv.is_owned = false;
8664 OpenChannel_set_push_msat(&this_ptr_conv, val);
8667 int64_t __attribute__((visibility("default"))) TS_OpenChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
8668 LDKOpenChannel this_ptr_conv;
8669 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8670 this_ptr_conv.is_owned = false;
8671 int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
8675 void __attribute__((visibility("default"))) TS_OpenChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8676 LDKOpenChannel this_ptr_conv;
8677 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8678 this_ptr_conv.is_owned = false;
8679 OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
8682 int64_t __attribute__((visibility("default"))) TS_OpenChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
8683 LDKOpenChannel this_ptr_conv;
8684 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8685 this_ptr_conv.is_owned = false;
8686 int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
8690 void __attribute__((visibility("default"))) TS_OpenChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
8691 LDKOpenChannel this_ptr_conv;
8692 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8693 this_ptr_conv.is_owned = false;
8694 OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
8697 int64_t __attribute__((visibility("default"))) TS_OpenChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
8698 LDKOpenChannel this_ptr_conv;
8699 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8700 this_ptr_conv.is_owned = false;
8701 int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
8705 void __attribute__((visibility("default"))) TS_OpenChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
8706 LDKOpenChannel this_ptr_conv;
8707 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8708 this_ptr_conv.is_owned = false;
8709 OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
8712 int64_t __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
8713 LDKOpenChannel this_ptr_conv;
8714 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8715 this_ptr_conv.is_owned = false;
8716 int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
8720 void __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
8721 LDKOpenChannel this_ptr_conv;
8722 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8723 this_ptr_conv.is_owned = false;
8724 OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
8727 int32_t __attribute__((visibility("default"))) TS_OpenChannel_get_feerate_per_kw(uint32_t this_ptr) {
8728 LDKOpenChannel this_ptr_conv;
8729 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8730 this_ptr_conv.is_owned = false;
8731 int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
8735 void __attribute__((visibility("default"))) TS_OpenChannel_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
8736 LDKOpenChannel this_ptr_conv;
8737 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8738 this_ptr_conv.is_owned = false;
8739 OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
8742 int16_t __attribute__((visibility("default"))) TS_OpenChannel_get_to_self_delay(uint32_t this_ptr) {
8743 LDKOpenChannel this_ptr_conv;
8744 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8745 this_ptr_conv.is_owned = false;
8746 int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
8750 void __attribute__((visibility("default"))) TS_OpenChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
8751 LDKOpenChannel this_ptr_conv;
8752 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8753 this_ptr_conv.is_owned = false;
8754 OpenChannel_set_to_self_delay(&this_ptr_conv, val);
8757 int16_t __attribute__((visibility("default"))) TS_OpenChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
8758 LDKOpenChannel this_ptr_conv;
8759 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8760 this_ptr_conv.is_owned = false;
8761 int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
8765 void __attribute__((visibility("default"))) TS_OpenChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
8766 LDKOpenChannel this_ptr_conv;
8767 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8768 this_ptr_conv.is_owned = false;
8769 OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
8772 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_get_funding_pubkey(uint32_t this_ptr) {
8773 LDKOpenChannel this_ptr_conv;
8774 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8775 this_ptr_conv.is_owned = false;
8776 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8777 memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
8781 void __attribute__((visibility("default"))) TS_OpenChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
8782 LDKOpenChannel this_ptr_conv;
8783 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8784 this_ptr_conv.is_owned = false;
8785 LDKPublicKey val_ref;
8786 CHECK(*((uint32_t*)val) == 33);
8787 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8788 OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
8791 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_get_revocation_basepoint(uint32_t this_ptr) {
8792 LDKOpenChannel this_ptr_conv;
8793 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8794 this_ptr_conv.is_owned = false;
8795 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8796 memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
8800 void __attribute__((visibility("default"))) TS_OpenChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
8801 LDKOpenChannel this_ptr_conv;
8802 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8803 this_ptr_conv.is_owned = false;
8804 LDKPublicKey val_ref;
8805 CHECK(*((uint32_t*)val) == 33);
8806 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8807 OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
8810 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_get_payment_point(uint32_t this_ptr) {
8811 LDKOpenChannel this_ptr_conv;
8812 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8813 this_ptr_conv.is_owned = false;
8814 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8815 memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
8819 void __attribute__((visibility("default"))) TS_OpenChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
8820 LDKOpenChannel this_ptr_conv;
8821 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8822 this_ptr_conv.is_owned = false;
8823 LDKPublicKey val_ref;
8824 CHECK(*((uint32_t*)val) == 33);
8825 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8826 OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
8829 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
8830 LDKOpenChannel this_ptr_conv;
8831 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8832 this_ptr_conv.is_owned = false;
8833 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8834 memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
8838 void __attribute__((visibility("default"))) TS_OpenChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
8839 LDKOpenChannel this_ptr_conv;
8840 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8841 this_ptr_conv.is_owned = false;
8842 LDKPublicKey val_ref;
8843 CHECK(*((uint32_t*)val) == 33);
8844 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8845 OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
8848 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_get_htlc_basepoint(uint32_t this_ptr) {
8849 LDKOpenChannel this_ptr_conv;
8850 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8851 this_ptr_conv.is_owned = false;
8852 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8853 memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
8857 void __attribute__((visibility("default"))) TS_OpenChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
8858 LDKOpenChannel this_ptr_conv;
8859 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8860 this_ptr_conv.is_owned = false;
8861 LDKPublicKey val_ref;
8862 CHECK(*((uint32_t*)val) == 33);
8863 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8864 OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
8867 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_get_first_per_commitment_point(uint32_t this_ptr) {
8868 LDKOpenChannel this_ptr_conv;
8869 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8870 this_ptr_conv.is_owned = false;
8871 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
8872 memcpy((uint8_t*)(arg_arr + 4), OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
8876 void __attribute__((visibility("default"))) TS_OpenChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
8877 LDKOpenChannel this_ptr_conv;
8878 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8879 this_ptr_conv.is_owned = false;
8880 LDKPublicKey val_ref;
8881 CHECK(*((uint32_t*)val) == 33);
8882 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
8883 OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
8886 int8_t __attribute__((visibility("default"))) TS_OpenChannel_get_channel_flags(uint32_t this_ptr) {
8887 LDKOpenChannel this_ptr_conv;
8888 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8889 this_ptr_conv.is_owned = false;
8890 int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
8894 void __attribute__((visibility("default"))) TS_OpenChannel_set_channel_flags(uint32_t this_ptr, int8_t val) {
8895 LDKOpenChannel this_ptr_conv;
8896 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8897 this_ptr_conv.is_owned = false;
8898 OpenChannel_set_channel_flags(&this_ptr_conv, val);
8901 void __attribute__((visibility("default"))) TS_AcceptChannel_free(uint32_t this_ptr) {
8902 LDKAcceptChannel this_ptr_conv;
8903 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8904 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
8905 AcceptChannel_free(this_ptr_conv);
8908 uint32_t __attribute__((visibility("default"))) TS_AcceptChannel_clone(uint32_t orig) {
8909 LDKAcceptChannel orig_conv;
8910 orig_conv.inner = (void*)(orig & (~1));
8911 orig_conv.is_owned = false;
8912 LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
8913 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8914 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8915 long ret_ref = (long)ret_var.inner;
8916 if (ret_var.is_owned) {
8922 int8_tArray __attribute__((visibility("default"))) TS_AcceptChannel_get_temporary_channel_id(uint32_t this_ptr) {
8923 LDKAcceptChannel this_ptr_conv;
8924 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8925 this_ptr_conv.is_owned = false;
8926 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
8927 memcpy((uint8_t*)(ret_arr + 4), *AcceptChannel_get_temporary_channel_id(&this_ptr_conv), 32);
8931 void __attribute__((visibility("default"))) TS_AcceptChannel_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
8932 LDKAcceptChannel 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(*((uint32_t*)val) == 32);
8937 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
8938 AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
8941 int64_t __attribute__((visibility("default"))) TS_AcceptChannel_get_dust_limit_satoshis(uint32_t this_ptr) {
8942 LDKAcceptChannel this_ptr_conv;
8943 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8944 this_ptr_conv.is_owned = false;
8945 int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
8949 void __attribute__((visibility("default"))) TS_AcceptChannel_set_dust_limit_satoshis(uint32_t this_ptr, int64_t val) {
8950 LDKAcceptChannel this_ptr_conv;
8951 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8952 this_ptr_conv.is_owned = false;
8953 AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
8956 int64_t __attribute__((visibility("default"))) TS_AcceptChannel_get_max_htlc_value_in_flight_msat(uint32_t this_ptr) {
8957 LDKAcceptChannel this_ptr_conv;
8958 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8959 this_ptr_conv.is_owned = false;
8960 int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
8964 void __attribute__((visibility("default"))) TS_AcceptChannel_set_max_htlc_value_in_flight_msat(uint32_t this_ptr, int64_t val) {
8965 LDKAcceptChannel this_ptr_conv;
8966 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8967 this_ptr_conv.is_owned = false;
8968 AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
8971 int64_t __attribute__((visibility("default"))) TS_AcceptChannel_get_channel_reserve_satoshis(uint32_t this_ptr) {
8972 LDKAcceptChannel this_ptr_conv;
8973 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8974 this_ptr_conv.is_owned = false;
8975 int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
8979 void __attribute__((visibility("default"))) TS_AcceptChannel_set_channel_reserve_satoshis(uint32_t this_ptr, int64_t val) {
8980 LDKAcceptChannel this_ptr_conv;
8981 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8982 this_ptr_conv.is_owned = false;
8983 AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
8986 int64_t __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_minimum_msat(uint32_t this_ptr) {
8987 LDKAcceptChannel this_ptr_conv;
8988 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8989 this_ptr_conv.is_owned = false;
8990 int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
8994 void __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
8995 LDKAcceptChannel this_ptr_conv;
8996 this_ptr_conv.inner = (void*)(this_ptr & (~1));
8997 this_ptr_conv.is_owned = false;
8998 AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
9001 int32_t __attribute__((visibility("default"))) TS_AcceptChannel_get_minimum_depth(uint32_t this_ptr) {
9002 LDKAcceptChannel this_ptr_conv;
9003 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9004 this_ptr_conv.is_owned = false;
9005 int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
9009 void __attribute__((visibility("default"))) TS_AcceptChannel_set_minimum_depth(uint32_t this_ptr, int32_t val) {
9010 LDKAcceptChannel this_ptr_conv;
9011 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9012 this_ptr_conv.is_owned = false;
9013 AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
9016 int16_t __attribute__((visibility("default"))) TS_AcceptChannel_get_to_self_delay(uint32_t this_ptr) {
9017 LDKAcceptChannel this_ptr_conv;
9018 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9019 this_ptr_conv.is_owned = false;
9020 int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
9024 void __attribute__((visibility("default"))) TS_AcceptChannel_set_to_self_delay(uint32_t this_ptr, int16_t val) {
9025 LDKAcceptChannel this_ptr_conv;
9026 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9027 this_ptr_conv.is_owned = false;
9028 AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
9031 int16_t __attribute__((visibility("default"))) TS_AcceptChannel_get_max_accepted_htlcs(uint32_t this_ptr) {
9032 LDKAcceptChannel this_ptr_conv;
9033 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9034 this_ptr_conv.is_owned = false;
9035 int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
9039 void __attribute__((visibility("default"))) TS_AcceptChannel_set_max_accepted_htlcs(uint32_t this_ptr, int16_t val) {
9040 LDKAcceptChannel this_ptr_conv;
9041 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9042 this_ptr_conv.is_owned = false;
9043 AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
9046 int8_tArray __attribute__((visibility("default"))) TS_AcceptChannel_get_funding_pubkey(uint32_t this_ptr) {
9047 LDKAcceptChannel this_ptr_conv;
9048 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9049 this_ptr_conv.is_owned = false;
9050 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9051 memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
9055 void __attribute__((visibility("default"))) TS_AcceptChannel_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
9056 LDKAcceptChannel this_ptr_conv;
9057 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9058 this_ptr_conv.is_owned = false;
9059 LDKPublicKey val_ref;
9060 CHECK(*((uint32_t*)val) == 33);
9061 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9062 AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
9065 int8_tArray __attribute__((visibility("default"))) TS_AcceptChannel_get_revocation_basepoint(uint32_t this_ptr) {
9066 LDKAcceptChannel this_ptr_conv;
9067 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9068 this_ptr_conv.is_owned = false;
9069 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9070 memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
9074 void __attribute__((visibility("default"))) TS_AcceptChannel_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
9075 LDKAcceptChannel this_ptr_conv;
9076 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9077 this_ptr_conv.is_owned = false;
9078 LDKPublicKey val_ref;
9079 CHECK(*((uint32_t*)val) == 33);
9080 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9081 AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
9084 int8_tArray __attribute__((visibility("default"))) TS_AcceptChannel_get_payment_point(uint32_t this_ptr) {
9085 LDKAcceptChannel this_ptr_conv;
9086 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9087 this_ptr_conv.is_owned = false;
9088 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9089 memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form, 33);
9093 void __attribute__((visibility("default"))) TS_AcceptChannel_set_payment_point(uint32_t this_ptr, int8_tArray val) {
9094 LDKAcceptChannel this_ptr_conv;
9095 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9096 this_ptr_conv.is_owned = false;
9097 LDKPublicKey val_ref;
9098 CHECK(*((uint32_t*)val) == 33);
9099 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9100 AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
9103 int8_tArray __attribute__((visibility("default"))) TS_AcceptChannel_get_delayed_payment_basepoint(uint32_t this_ptr) {
9104 LDKAcceptChannel this_ptr_conv;
9105 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9106 this_ptr_conv.is_owned = false;
9107 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9108 memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
9112 void __attribute__((visibility("default"))) TS_AcceptChannel_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
9113 LDKAcceptChannel this_ptr_conv;
9114 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9115 this_ptr_conv.is_owned = false;
9116 LDKPublicKey val_ref;
9117 CHECK(*((uint32_t*)val) == 33);
9118 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9119 AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
9122 int8_tArray __attribute__((visibility("default"))) TS_AcceptChannel_get_htlc_basepoint(uint32_t this_ptr) {
9123 LDKAcceptChannel this_ptr_conv;
9124 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9125 this_ptr_conv.is_owned = false;
9126 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9127 memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
9131 void __attribute__((visibility("default"))) TS_AcceptChannel_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
9132 LDKAcceptChannel this_ptr_conv;
9133 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9134 this_ptr_conv.is_owned = false;
9135 LDKPublicKey val_ref;
9136 CHECK(*((uint32_t*)val) == 33);
9137 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9138 AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
9141 int8_tArray __attribute__((visibility("default"))) TS_AcceptChannel_get_first_per_commitment_point(uint32_t this_ptr) {
9142 LDKAcceptChannel this_ptr_conv;
9143 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9144 this_ptr_conv.is_owned = false;
9145 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9146 memcpy((uint8_t*)(arg_arr + 4), AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9150 void __attribute__((visibility("default"))) TS_AcceptChannel_set_first_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
9151 LDKAcceptChannel this_ptr_conv;
9152 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9153 this_ptr_conv.is_owned = false;
9154 LDKPublicKey val_ref;
9155 CHECK(*((uint32_t*)val) == 33);
9156 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9157 AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
9160 void __attribute__((visibility("default"))) TS_FundingCreated_free(uint32_t this_ptr) {
9161 LDKFundingCreated this_ptr_conv;
9162 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9163 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9164 FundingCreated_free(this_ptr_conv);
9167 uint32_t __attribute__((visibility("default"))) TS_FundingCreated_clone(uint32_t orig) {
9168 LDKFundingCreated orig_conv;
9169 orig_conv.inner = (void*)(orig & (~1));
9170 orig_conv.is_owned = false;
9171 LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
9172 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9173 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9174 long ret_ref = (long)ret_var.inner;
9175 if (ret_var.is_owned) {
9181 int8_tArray __attribute__((visibility("default"))) TS_FundingCreated_get_temporary_channel_id(uint32_t this_ptr) {
9182 LDKFundingCreated this_ptr_conv;
9183 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9184 this_ptr_conv.is_owned = false;
9185 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9186 memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_temporary_channel_id(&this_ptr_conv), 32);
9190 void __attribute__((visibility("default"))) TS_FundingCreated_set_temporary_channel_id(uint32_t this_ptr, int8_tArray val) {
9191 LDKFundingCreated this_ptr_conv;
9192 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9193 this_ptr_conv.is_owned = false;
9194 LDKThirtyTwoBytes val_ref;
9195 CHECK(*((uint32_t*)val) == 32);
9196 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9197 FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
9200 int8_tArray __attribute__((visibility("default"))) TS_FundingCreated_get_funding_txid(uint32_t this_ptr) {
9201 LDKFundingCreated this_ptr_conv;
9202 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9203 this_ptr_conv.is_owned = false;
9204 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9205 memcpy((uint8_t*)(ret_arr + 4), *FundingCreated_get_funding_txid(&this_ptr_conv), 32);
9209 void __attribute__((visibility("default"))) TS_FundingCreated_set_funding_txid(uint32_t this_ptr, int8_tArray val) {
9210 LDKFundingCreated this_ptr_conv;
9211 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9212 this_ptr_conv.is_owned = false;
9213 LDKThirtyTwoBytes val_ref;
9214 CHECK(*((uint32_t*)val) == 32);
9215 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9216 FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
9219 int16_t __attribute__((visibility("default"))) TS_FundingCreated_get_funding_output_index(uint32_t this_ptr) {
9220 LDKFundingCreated this_ptr_conv;
9221 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9222 this_ptr_conv.is_owned = false;
9223 int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
9227 void __attribute__((visibility("default"))) TS_FundingCreated_set_funding_output_index(uint32_t this_ptr, int16_t val) {
9228 LDKFundingCreated this_ptr_conv;
9229 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9230 this_ptr_conv.is_owned = false;
9231 FundingCreated_set_funding_output_index(&this_ptr_conv, val);
9234 int8_tArray __attribute__((visibility("default"))) TS_FundingCreated_get_signature(uint32_t this_ptr) {
9235 LDKFundingCreated this_ptr_conv;
9236 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9237 this_ptr_conv.is_owned = false;
9238 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9239 memcpy((uint8_t*)(arg_arr + 4), FundingCreated_get_signature(&this_ptr_conv).compact_form, 64);
9243 void __attribute__((visibility("default"))) TS_FundingCreated_set_signature(uint32_t this_ptr, int8_tArray val) {
9244 LDKFundingCreated this_ptr_conv;
9245 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9246 this_ptr_conv.is_owned = false;
9247 LDKSignature val_ref;
9248 CHECK(*((uint32_t*)val) == 64);
9249 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9250 FundingCreated_set_signature(&this_ptr_conv, val_ref);
9253 uint32_t __attribute__((visibility("default"))) TS_FundingCreated_new(int8_tArray temporary_channel_id_arg, int8_tArray funding_txid_arg, int16_t funding_output_index_arg, int8_tArray signature_arg) {
9254 LDKThirtyTwoBytes temporary_channel_id_arg_ref;
9255 CHECK(*((uint32_t*)temporary_channel_id_arg) == 32);
9256 memcpy(temporary_channel_id_arg_ref.data, (uint8_t*)(temporary_channel_id_arg + 4), 32);
9257 LDKThirtyTwoBytes funding_txid_arg_ref;
9258 CHECK(*((uint32_t*)funding_txid_arg) == 32);
9259 memcpy(funding_txid_arg_ref.data, (uint8_t*)(funding_txid_arg + 4), 32);
9260 LDKSignature signature_arg_ref;
9261 CHECK(*((uint32_t*)signature_arg) == 64);
9262 memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9263 LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
9264 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9265 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9266 long ret_ref = (long)ret_var.inner;
9267 if (ret_var.is_owned) {
9273 void __attribute__((visibility("default"))) TS_FundingSigned_free(uint32_t this_ptr) {
9274 LDKFundingSigned this_ptr_conv;
9275 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9276 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9277 FundingSigned_free(this_ptr_conv);
9280 uint32_t __attribute__((visibility("default"))) TS_FundingSigned_clone(uint32_t orig) {
9281 LDKFundingSigned orig_conv;
9282 orig_conv.inner = (void*)(orig & (~1));
9283 orig_conv.is_owned = false;
9284 LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
9285 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9286 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9287 long ret_ref = (long)ret_var.inner;
9288 if (ret_var.is_owned) {
9294 int8_tArray __attribute__((visibility("default"))) TS_FundingSigned_get_channel_id(uint32_t this_ptr) {
9295 LDKFundingSigned this_ptr_conv;
9296 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9297 this_ptr_conv.is_owned = false;
9298 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9299 memcpy((uint8_t*)(ret_arr + 4), *FundingSigned_get_channel_id(&this_ptr_conv), 32);
9303 void __attribute__((visibility("default"))) TS_FundingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9304 LDKFundingSigned this_ptr_conv;
9305 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9306 this_ptr_conv.is_owned = false;
9307 LDKThirtyTwoBytes val_ref;
9308 CHECK(*((uint32_t*)val) == 32);
9309 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9310 FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
9313 int8_tArray __attribute__((visibility("default"))) TS_FundingSigned_get_signature(uint32_t this_ptr) {
9314 LDKFundingSigned this_ptr_conv;
9315 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9316 this_ptr_conv.is_owned = false;
9317 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9318 memcpy((uint8_t*)(arg_arr + 4), FundingSigned_get_signature(&this_ptr_conv).compact_form, 64);
9322 void __attribute__((visibility("default"))) TS_FundingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
9323 LDKFundingSigned this_ptr_conv;
9324 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9325 this_ptr_conv.is_owned = false;
9326 LDKSignature val_ref;
9327 CHECK(*((uint32_t*)val) == 64);
9328 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9329 FundingSigned_set_signature(&this_ptr_conv, val_ref);
9332 uint32_t __attribute__((visibility("default"))) TS_FundingSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg) {
9333 LDKThirtyTwoBytes channel_id_arg_ref;
9334 CHECK(*((uint32_t*)channel_id_arg) == 32);
9335 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9336 LDKSignature signature_arg_ref;
9337 CHECK(*((uint32_t*)signature_arg) == 64);
9338 memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9339 LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
9340 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9341 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9342 long ret_ref = (long)ret_var.inner;
9343 if (ret_var.is_owned) {
9349 void __attribute__((visibility("default"))) TS_FundingLocked_free(uint32_t this_ptr) {
9350 LDKFundingLocked this_ptr_conv;
9351 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9352 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9353 FundingLocked_free(this_ptr_conv);
9356 uint32_t __attribute__((visibility("default"))) TS_FundingLocked_clone(uint32_t orig) {
9357 LDKFundingLocked orig_conv;
9358 orig_conv.inner = (void*)(orig & (~1));
9359 orig_conv.is_owned = false;
9360 LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
9361 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9362 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9363 long ret_ref = (long)ret_var.inner;
9364 if (ret_var.is_owned) {
9370 int8_tArray __attribute__((visibility("default"))) TS_FundingLocked_get_channel_id(uint32_t this_ptr) {
9371 LDKFundingLocked this_ptr_conv;
9372 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9373 this_ptr_conv.is_owned = false;
9374 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9375 memcpy((uint8_t*)(ret_arr + 4), *FundingLocked_get_channel_id(&this_ptr_conv), 32);
9379 void __attribute__((visibility("default"))) TS_FundingLocked_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9380 LDKFundingLocked this_ptr_conv;
9381 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9382 this_ptr_conv.is_owned = false;
9383 LDKThirtyTwoBytes val_ref;
9384 CHECK(*((uint32_t*)val) == 32);
9385 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9386 FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
9389 int8_tArray __attribute__((visibility("default"))) TS_FundingLocked_get_next_per_commitment_point(uint32_t this_ptr) {
9390 LDKFundingLocked this_ptr_conv;
9391 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9392 this_ptr_conv.is_owned = false;
9393 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
9394 memcpy((uint8_t*)(arg_arr + 4), FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
9398 void __attribute__((visibility("default"))) TS_FundingLocked_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
9399 LDKFundingLocked this_ptr_conv;
9400 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9401 this_ptr_conv.is_owned = false;
9402 LDKPublicKey val_ref;
9403 CHECK(*((uint32_t*)val) == 33);
9404 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
9405 FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
9408 uint32_t __attribute__((visibility("default"))) TS_FundingLocked_new(int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
9409 LDKThirtyTwoBytes channel_id_arg_ref;
9410 CHECK(*((uint32_t*)channel_id_arg) == 32);
9411 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9412 LDKPublicKey next_per_commitment_point_arg_ref;
9413 CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
9414 memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
9415 LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
9416 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9417 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9418 long ret_ref = (long)ret_var.inner;
9419 if (ret_var.is_owned) {
9425 void __attribute__((visibility("default"))) TS_Shutdown_free(uint32_t this_ptr) {
9426 LDKShutdown this_ptr_conv;
9427 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9428 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9429 Shutdown_free(this_ptr_conv);
9432 uint32_t __attribute__((visibility("default"))) TS_Shutdown_clone(uint32_t orig) {
9433 LDKShutdown orig_conv;
9434 orig_conv.inner = (void*)(orig & (~1));
9435 orig_conv.is_owned = false;
9436 LDKShutdown ret_var = Shutdown_clone(&orig_conv);
9437 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9438 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9439 long ret_ref = (long)ret_var.inner;
9440 if (ret_var.is_owned) {
9446 int8_tArray __attribute__((visibility("default"))) TS_Shutdown_get_channel_id(uint32_t this_ptr) {
9447 LDKShutdown this_ptr_conv;
9448 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9449 this_ptr_conv.is_owned = false;
9450 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9451 memcpy((uint8_t*)(ret_arr + 4), *Shutdown_get_channel_id(&this_ptr_conv), 32);
9455 void __attribute__((visibility("default"))) TS_Shutdown_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9456 LDKShutdown this_ptr_conv;
9457 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9458 this_ptr_conv.is_owned = false;
9459 LDKThirtyTwoBytes val_ref;
9460 CHECK(*((uint32_t*)val) == 32);
9461 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9462 Shutdown_set_channel_id(&this_ptr_conv, val_ref);
9465 int8_tArray __attribute__((visibility("default"))) TS_Shutdown_get_scriptpubkey(uint32_t this_ptr) {
9466 LDKShutdown this_ptr_conv;
9467 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9468 this_ptr_conv.is_owned = false;
9469 LDKu8slice arg_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
9470 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
9471 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
9475 void __attribute__((visibility("default"))) TS_Shutdown_set_scriptpubkey(uint32_t this_ptr, int8_tArray val) {
9476 LDKShutdown this_ptr_conv;
9477 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9478 this_ptr_conv.is_owned = false;
9479 LDKCVec_u8Z val_ref;
9480 val_ref.datalen = *((uint32_t*)val);
9481 val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
9482 memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
9483 Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
9486 uint32_t __attribute__((visibility("default"))) TS_Shutdown_new(int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
9487 LDKThirtyTwoBytes channel_id_arg_ref;
9488 CHECK(*((uint32_t*)channel_id_arg) == 32);
9489 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9490 LDKCVec_u8Z scriptpubkey_arg_ref;
9491 scriptpubkey_arg_ref.datalen = *((uint32_t*)scriptpubkey_arg);
9492 scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
9493 memcpy(scriptpubkey_arg_ref.data, (uint8_t*)(scriptpubkey_arg + 4), scriptpubkey_arg_ref.datalen);
9494 LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
9495 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9496 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9497 long ret_ref = (long)ret_var.inner;
9498 if (ret_var.is_owned) {
9504 void __attribute__((visibility("default"))) TS_ClosingSigned_free(uint32_t this_ptr) {
9505 LDKClosingSigned this_ptr_conv;
9506 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9507 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9508 ClosingSigned_free(this_ptr_conv);
9511 uint32_t __attribute__((visibility("default"))) TS_ClosingSigned_clone(uint32_t orig) {
9512 LDKClosingSigned orig_conv;
9513 orig_conv.inner = (void*)(orig & (~1));
9514 orig_conv.is_owned = false;
9515 LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
9516 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9517 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9518 long ret_ref = (long)ret_var.inner;
9519 if (ret_var.is_owned) {
9525 int8_tArray __attribute__((visibility("default"))) TS_ClosingSigned_get_channel_id(uint32_t this_ptr) {
9526 LDKClosingSigned this_ptr_conv;
9527 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9528 this_ptr_conv.is_owned = false;
9529 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9530 memcpy((uint8_t*)(ret_arr + 4), *ClosingSigned_get_channel_id(&this_ptr_conv), 32);
9534 void __attribute__((visibility("default"))) TS_ClosingSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9535 LDKClosingSigned this_ptr_conv;
9536 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9537 this_ptr_conv.is_owned = false;
9538 LDKThirtyTwoBytes val_ref;
9539 CHECK(*((uint32_t*)val) == 32);
9540 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9541 ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
9544 int64_t __attribute__((visibility("default"))) TS_ClosingSigned_get_fee_satoshis(uint32_t this_ptr) {
9545 LDKClosingSigned this_ptr_conv;
9546 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9547 this_ptr_conv.is_owned = false;
9548 int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
9552 void __attribute__((visibility("default"))) TS_ClosingSigned_set_fee_satoshis(uint32_t this_ptr, int64_t val) {
9553 LDKClosingSigned this_ptr_conv;
9554 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9555 this_ptr_conv.is_owned = false;
9556 ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
9559 int8_tArray __attribute__((visibility("default"))) TS_ClosingSigned_get_signature(uint32_t this_ptr) {
9560 LDKClosingSigned this_ptr_conv;
9561 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9562 this_ptr_conv.is_owned = false;
9563 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9564 memcpy((uint8_t*)(arg_arr + 4), ClosingSigned_get_signature(&this_ptr_conv).compact_form, 64);
9568 void __attribute__((visibility("default"))) TS_ClosingSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
9569 LDKClosingSigned this_ptr_conv;
9570 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9571 this_ptr_conv.is_owned = false;
9572 LDKSignature val_ref;
9573 CHECK(*((uint32_t*)val) == 64);
9574 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9575 ClosingSigned_set_signature(&this_ptr_conv, val_ref);
9578 uint32_t __attribute__((visibility("default"))) TS_ClosingSigned_new(int8_tArray channel_id_arg, int64_t fee_satoshis_arg, int8_tArray signature_arg) {
9579 LDKThirtyTwoBytes channel_id_arg_ref;
9580 CHECK(*((uint32_t*)channel_id_arg) == 32);
9581 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9582 LDKSignature signature_arg_ref;
9583 CHECK(*((uint32_t*)signature_arg) == 64);
9584 memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
9585 LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref);
9586 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9587 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9588 long ret_ref = (long)ret_var.inner;
9589 if (ret_var.is_owned) {
9595 void __attribute__((visibility("default"))) TS_UpdateAddHTLC_free(uint32_t this_ptr) {
9596 LDKUpdateAddHTLC this_ptr_conv;
9597 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9598 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9599 UpdateAddHTLC_free(this_ptr_conv);
9602 uint32_t __attribute__((visibility("default"))) TS_UpdateAddHTLC_clone(uint32_t orig) {
9603 LDKUpdateAddHTLC orig_conv;
9604 orig_conv.inner = (void*)(orig & (~1));
9605 orig_conv.is_owned = false;
9606 LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
9607 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9608 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9609 long ret_ref = (long)ret_var.inner;
9610 if (ret_var.is_owned) {
9616 int8_tArray __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_channel_id(uint32_t this_ptr) {
9617 LDKUpdateAddHTLC this_ptr_conv;
9618 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9619 this_ptr_conv.is_owned = false;
9620 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9621 memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_channel_id(&this_ptr_conv), 32);
9625 void __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9626 LDKUpdateAddHTLC this_ptr_conv;
9627 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9628 this_ptr_conv.is_owned = false;
9629 LDKThirtyTwoBytes val_ref;
9630 CHECK(*((uint32_t*)val) == 32);
9631 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9632 UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
9635 int64_t __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_htlc_id(uint32_t this_ptr) {
9636 LDKUpdateAddHTLC this_ptr_conv;
9637 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9638 this_ptr_conv.is_owned = false;
9639 int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
9643 void __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9644 LDKUpdateAddHTLC this_ptr_conv;
9645 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9646 this_ptr_conv.is_owned = false;
9647 UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
9650 int64_t __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_amount_msat(uint32_t this_ptr) {
9651 LDKUpdateAddHTLC this_ptr_conv;
9652 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9653 this_ptr_conv.is_owned = false;
9654 int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
9658 void __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_amount_msat(uint32_t this_ptr, int64_t val) {
9659 LDKUpdateAddHTLC this_ptr_conv;
9660 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9661 this_ptr_conv.is_owned = false;
9662 UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
9665 int8_tArray __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_payment_hash(uint32_t this_ptr) {
9666 LDKUpdateAddHTLC this_ptr_conv;
9667 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9668 this_ptr_conv.is_owned = false;
9669 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9670 memcpy((uint8_t*)(ret_arr + 4), *UpdateAddHTLC_get_payment_hash(&this_ptr_conv), 32);
9674 void __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
9675 LDKUpdateAddHTLC this_ptr_conv;
9676 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9677 this_ptr_conv.is_owned = false;
9678 LDKThirtyTwoBytes val_ref;
9679 CHECK(*((uint32_t*)val) == 32);
9680 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9681 UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
9684 int32_t __attribute__((visibility("default"))) TS_UpdateAddHTLC_get_cltv_expiry(uint32_t this_ptr) {
9685 LDKUpdateAddHTLC this_ptr_conv;
9686 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9687 this_ptr_conv.is_owned = false;
9688 int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
9692 void __attribute__((visibility("default"))) TS_UpdateAddHTLC_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
9693 LDKUpdateAddHTLC this_ptr_conv;
9694 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9695 this_ptr_conv.is_owned = false;
9696 UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
9699 void __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_free(uint32_t this_ptr) {
9700 LDKUpdateFulfillHTLC this_ptr_conv;
9701 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9702 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9703 UpdateFulfillHTLC_free(this_ptr_conv);
9706 uint32_t __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_clone(uint32_t orig) {
9707 LDKUpdateFulfillHTLC orig_conv;
9708 orig_conv.inner = (void*)(orig & (~1));
9709 orig_conv.is_owned = false;
9710 LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
9711 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9712 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9713 long ret_ref = (long)ret_var.inner;
9714 if (ret_var.is_owned) {
9720 int8_tArray __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_channel_id(uint32_t this_ptr) {
9721 LDKUpdateFulfillHTLC this_ptr_conv;
9722 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9723 this_ptr_conv.is_owned = false;
9724 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9725 memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv), 32);
9729 void __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9730 LDKUpdateFulfillHTLC this_ptr_conv;
9731 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9732 this_ptr_conv.is_owned = false;
9733 LDKThirtyTwoBytes val_ref;
9734 CHECK(*((uint32_t*)val) == 32);
9735 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9736 UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
9739 int64_t __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_htlc_id(uint32_t this_ptr) {
9740 LDKUpdateFulfillHTLC this_ptr_conv;
9741 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9742 this_ptr_conv.is_owned = false;
9743 int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
9747 void __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9748 LDKUpdateFulfillHTLC this_ptr_conv;
9749 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9750 this_ptr_conv.is_owned = false;
9751 UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
9754 int8_tArray __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_get_payment_preimage(uint32_t this_ptr) {
9755 LDKUpdateFulfillHTLC this_ptr_conv;
9756 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9757 this_ptr_conv.is_owned = false;
9758 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9759 memcpy((uint8_t*)(ret_arr + 4), *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv), 32);
9763 void __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_set_payment_preimage(uint32_t this_ptr, int8_tArray val) {
9764 LDKUpdateFulfillHTLC this_ptr_conv;
9765 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9766 this_ptr_conv.is_owned = false;
9767 LDKThirtyTwoBytes val_ref;
9768 CHECK(*((uint32_t*)val) == 32);
9769 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9770 UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
9773 uint32_t __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_new(int8_tArray channel_id_arg, int64_t htlc_id_arg, int8_tArray payment_preimage_arg) {
9774 LDKThirtyTwoBytes channel_id_arg_ref;
9775 CHECK(*((uint32_t*)channel_id_arg) == 32);
9776 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9777 LDKThirtyTwoBytes payment_preimage_arg_ref;
9778 CHECK(*((uint32_t*)payment_preimage_arg) == 32);
9779 memcpy(payment_preimage_arg_ref.data, (uint8_t*)(payment_preimage_arg + 4), 32);
9780 LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
9781 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9782 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9783 long ret_ref = (long)ret_var.inner;
9784 if (ret_var.is_owned) {
9790 void __attribute__((visibility("default"))) TS_UpdateFailHTLC_free(uint32_t this_ptr) {
9791 LDKUpdateFailHTLC 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 UpdateFailHTLC_free(this_ptr_conv);
9797 uint32_t __attribute__((visibility("default"))) TS_UpdateFailHTLC_clone(uint32_t orig) {
9798 LDKUpdateFailHTLC orig_conv;
9799 orig_conv.inner = (void*)(orig & (~1));
9800 orig_conv.is_owned = false;
9801 LDKUpdateFailHTLC ret_var = UpdateFailHTLC_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) {
9811 int8_tArray __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_channel_id(uint32_t this_ptr) {
9812 LDKUpdateFailHTLC this_ptr_conv;
9813 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9814 this_ptr_conv.is_owned = false;
9815 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9816 memcpy((uint8_t*)(ret_arr + 4), *UpdateFailHTLC_get_channel_id(&this_ptr_conv), 32);
9820 void __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9821 LDKUpdateFailHTLC this_ptr_conv;
9822 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9823 this_ptr_conv.is_owned = false;
9824 LDKThirtyTwoBytes val_ref;
9825 CHECK(*((uint32_t*)val) == 32);
9826 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9827 UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
9830 int64_t __attribute__((visibility("default"))) TS_UpdateFailHTLC_get_htlc_id(uint32_t this_ptr) {
9831 LDKUpdateFailHTLC this_ptr_conv;
9832 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9833 this_ptr_conv.is_owned = false;
9834 int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
9838 void __attribute__((visibility("default"))) TS_UpdateFailHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9839 LDKUpdateFailHTLC this_ptr_conv;
9840 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9841 this_ptr_conv.is_owned = false;
9842 UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
9845 void __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_free(uint32_t this_ptr) {
9846 LDKUpdateFailMalformedHTLC this_ptr_conv;
9847 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9848 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9849 UpdateFailMalformedHTLC_free(this_ptr_conv);
9852 uint32_t __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_clone(uint32_t orig) {
9853 LDKUpdateFailMalformedHTLC orig_conv;
9854 orig_conv.inner = (void*)(orig & (~1));
9855 orig_conv.is_owned = false;
9856 LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
9857 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9858 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9859 long ret_ref = (long)ret_var.inner;
9860 if (ret_var.is_owned) {
9866 int8_tArray __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_channel_id(uint32_t this_ptr) {
9867 LDKUpdateFailMalformedHTLC this_ptr_conv;
9868 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9869 this_ptr_conv.is_owned = false;
9870 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9871 memcpy((uint8_t*)(ret_arr + 4), *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv), 32);
9875 void __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9876 LDKUpdateFailMalformedHTLC this_ptr_conv;
9877 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9878 this_ptr_conv.is_owned = false;
9879 LDKThirtyTwoBytes val_ref;
9880 CHECK(*((uint32_t*)val) == 32);
9881 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9882 UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
9885 int64_t __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_htlc_id(uint32_t this_ptr) {
9886 LDKUpdateFailMalformedHTLC this_ptr_conv;
9887 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9888 this_ptr_conv.is_owned = false;
9889 int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
9893 void __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_htlc_id(uint32_t this_ptr, int64_t val) {
9894 LDKUpdateFailMalformedHTLC this_ptr_conv;
9895 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9896 this_ptr_conv.is_owned = false;
9897 UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
9900 int16_t __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_get_failure_code(uint32_t this_ptr) {
9901 LDKUpdateFailMalformedHTLC this_ptr_conv;
9902 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9903 this_ptr_conv.is_owned = false;
9904 int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
9908 void __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_set_failure_code(uint32_t this_ptr, int16_t val) {
9909 LDKUpdateFailMalformedHTLC this_ptr_conv;
9910 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9911 this_ptr_conv.is_owned = false;
9912 UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
9915 void __attribute__((visibility("default"))) TS_CommitmentSigned_free(uint32_t this_ptr) {
9916 LDKCommitmentSigned this_ptr_conv;
9917 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9918 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
9919 CommitmentSigned_free(this_ptr_conv);
9922 uint32_t __attribute__((visibility("default"))) TS_CommitmentSigned_clone(uint32_t orig) {
9923 LDKCommitmentSigned orig_conv;
9924 orig_conv.inner = (void*)(orig & (~1));
9925 orig_conv.is_owned = false;
9926 LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
9927 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9928 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9929 long ret_ref = (long)ret_var.inner;
9930 if (ret_var.is_owned) {
9936 int8_tArray __attribute__((visibility("default"))) TS_CommitmentSigned_get_channel_id(uint32_t this_ptr) {
9937 LDKCommitmentSigned this_ptr_conv;
9938 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9939 this_ptr_conv.is_owned = false;
9940 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
9941 memcpy((uint8_t*)(ret_arr + 4), *CommitmentSigned_get_channel_id(&this_ptr_conv), 32);
9945 void __attribute__((visibility("default"))) TS_CommitmentSigned_set_channel_id(uint32_t this_ptr, int8_tArray val) {
9946 LDKCommitmentSigned this_ptr_conv;
9947 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9948 this_ptr_conv.is_owned = false;
9949 LDKThirtyTwoBytes val_ref;
9950 CHECK(*((uint32_t*)val) == 32);
9951 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
9952 CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
9955 int8_tArray __attribute__((visibility("default"))) TS_CommitmentSigned_get_signature(uint32_t this_ptr) {
9956 LDKCommitmentSigned this_ptr_conv;
9957 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9958 this_ptr_conv.is_owned = false;
9959 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
9960 memcpy((uint8_t*)(arg_arr + 4), CommitmentSigned_get_signature(&this_ptr_conv).compact_form, 64);
9964 void __attribute__((visibility("default"))) TS_CommitmentSigned_set_signature(uint32_t this_ptr, int8_tArray val) {
9965 LDKCommitmentSigned this_ptr_conv;
9966 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9967 this_ptr_conv.is_owned = false;
9968 LDKSignature val_ref;
9969 CHECK(*((uint32_t*)val) == 64);
9970 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
9971 CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
9974 void __attribute__((visibility("default"))) TS_CommitmentSigned_set_htlc_signatures(uint32_t this_ptr, ptrArray val) {
9975 LDKCommitmentSigned this_ptr_conv;
9976 this_ptr_conv.inner = (void*)(this_ptr & (~1));
9977 this_ptr_conv.is_owned = false;
9978 LDKCVec_SignatureZ val_constr;
9979 val_constr.datalen = *((uint32_t*)val);
9980 if (val_constr.datalen > 0)
9981 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
9983 val_constr.data = NULL;
9984 int8_tArray* val_vals = (int8_tArray*)(val + 4);
9985 for (size_t m = 0; m < val_constr.datalen; m++) {
9986 int8_tArray arr_conv_12 = val_vals[m];
9987 LDKSignature arr_conv_12_ref;
9988 CHECK(*((uint32_t*)arr_conv_12) == 64);
9989 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
9990 val_constr.data[m] = arr_conv_12_ref;
9992 CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
9995 uint32_t __attribute__((visibility("default"))) TS_CommitmentSigned_new(int8_tArray channel_id_arg, int8_tArray signature_arg, ptrArray htlc_signatures_arg) {
9996 LDKThirtyTwoBytes channel_id_arg_ref;
9997 CHECK(*((uint32_t*)channel_id_arg) == 32);
9998 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
9999 LDKSignature signature_arg_ref;
10000 CHECK(*((uint32_t*)signature_arg) == 64);
10001 memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
10002 LDKCVec_SignatureZ htlc_signatures_arg_constr;
10003 htlc_signatures_arg_constr.datalen = *((uint32_t*)htlc_signatures_arg);
10004 if (htlc_signatures_arg_constr.datalen > 0)
10005 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
10007 htlc_signatures_arg_constr.data = NULL;
10008 int8_tArray* htlc_signatures_arg_vals = (int8_tArray*)(htlc_signatures_arg + 4);
10009 for (size_t m = 0; m < htlc_signatures_arg_constr.datalen; m++) {
10010 int8_tArray arr_conv_12 = htlc_signatures_arg_vals[m];
10011 LDKSignature arr_conv_12_ref;
10012 CHECK(*((uint32_t*)arr_conv_12) == 64);
10013 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
10014 htlc_signatures_arg_constr.data[m] = arr_conv_12_ref;
10016 LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
10017 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10018 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10019 long ret_ref = (long)ret_var.inner;
10020 if (ret_var.is_owned) {
10026 void __attribute__((visibility("default"))) TS_RevokeAndACK_free(uint32_t this_ptr) {
10027 LDKRevokeAndACK this_ptr_conv;
10028 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10029 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10030 RevokeAndACK_free(this_ptr_conv);
10033 uint32_t __attribute__((visibility("default"))) TS_RevokeAndACK_clone(uint32_t orig) {
10034 LDKRevokeAndACK orig_conv;
10035 orig_conv.inner = (void*)(orig & (~1));
10036 orig_conv.is_owned = false;
10037 LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
10038 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10039 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10040 long ret_ref = (long)ret_var.inner;
10041 if (ret_var.is_owned) {
10047 int8_tArray __attribute__((visibility("default"))) TS_RevokeAndACK_get_channel_id(uint32_t this_ptr) {
10048 LDKRevokeAndACK this_ptr_conv;
10049 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10050 this_ptr_conv.is_owned = false;
10051 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10052 memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_channel_id(&this_ptr_conv), 32);
10056 void __attribute__((visibility("default"))) TS_RevokeAndACK_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10057 LDKRevokeAndACK this_ptr_conv;
10058 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10059 this_ptr_conv.is_owned = false;
10060 LDKThirtyTwoBytes val_ref;
10061 CHECK(*((uint32_t*)val) == 32);
10062 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10063 RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
10066 int8_tArray __attribute__((visibility("default"))) TS_RevokeAndACK_get_per_commitment_secret(uint32_t this_ptr) {
10067 LDKRevokeAndACK this_ptr_conv;
10068 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10069 this_ptr_conv.is_owned = false;
10070 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10071 memcpy((uint8_t*)(ret_arr + 4), *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv), 32);
10075 void __attribute__((visibility("default"))) TS_RevokeAndACK_set_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
10076 LDKRevokeAndACK this_ptr_conv;
10077 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10078 this_ptr_conv.is_owned = false;
10079 LDKThirtyTwoBytes val_ref;
10080 CHECK(*((uint32_t*)val) == 32);
10081 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10082 RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
10085 int8_tArray __attribute__((visibility("default"))) TS_RevokeAndACK_get_next_per_commitment_point(uint32_t this_ptr) {
10086 LDKRevokeAndACK this_ptr_conv;
10087 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10088 this_ptr_conv.is_owned = false;
10089 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10090 memcpy((uint8_t*)(arg_arr + 4), RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form, 33);
10094 void __attribute__((visibility("default"))) TS_RevokeAndACK_set_next_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
10095 LDKRevokeAndACK this_ptr_conv;
10096 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10097 this_ptr_conv.is_owned = false;
10098 LDKPublicKey val_ref;
10099 CHECK(*((uint32_t*)val) == 33);
10100 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10101 RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
10104 uint32_t __attribute__((visibility("default"))) TS_RevokeAndACK_new(int8_tArray channel_id_arg, int8_tArray per_commitment_secret_arg, int8_tArray next_per_commitment_point_arg) {
10105 LDKThirtyTwoBytes channel_id_arg_ref;
10106 CHECK(*((uint32_t*)channel_id_arg) == 32);
10107 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10108 LDKThirtyTwoBytes per_commitment_secret_arg_ref;
10109 CHECK(*((uint32_t*)per_commitment_secret_arg) == 32);
10110 memcpy(per_commitment_secret_arg_ref.data, (uint8_t*)(per_commitment_secret_arg + 4), 32);
10111 LDKPublicKey next_per_commitment_point_arg_ref;
10112 CHECK(*((uint32_t*)next_per_commitment_point_arg) == 33);
10113 memcpy(next_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(next_per_commitment_point_arg + 4), 33);
10114 LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
10115 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10116 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10117 long ret_ref = (long)ret_var.inner;
10118 if (ret_var.is_owned) {
10124 void __attribute__((visibility("default"))) TS_UpdateFee_free(uint32_t this_ptr) {
10125 LDKUpdateFee this_ptr_conv;
10126 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10127 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10128 UpdateFee_free(this_ptr_conv);
10131 uint32_t __attribute__((visibility("default"))) TS_UpdateFee_clone(uint32_t orig) {
10132 LDKUpdateFee orig_conv;
10133 orig_conv.inner = (void*)(orig & (~1));
10134 orig_conv.is_owned = false;
10135 LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
10136 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10137 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10138 long ret_ref = (long)ret_var.inner;
10139 if (ret_var.is_owned) {
10145 int8_tArray __attribute__((visibility("default"))) TS_UpdateFee_get_channel_id(uint32_t this_ptr) {
10146 LDKUpdateFee this_ptr_conv;
10147 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10148 this_ptr_conv.is_owned = false;
10149 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10150 memcpy((uint8_t*)(ret_arr + 4), *UpdateFee_get_channel_id(&this_ptr_conv), 32);
10154 void __attribute__((visibility("default"))) TS_UpdateFee_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10155 LDKUpdateFee this_ptr_conv;
10156 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10157 this_ptr_conv.is_owned = false;
10158 LDKThirtyTwoBytes val_ref;
10159 CHECK(*((uint32_t*)val) == 32);
10160 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10161 UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
10164 int32_t __attribute__((visibility("default"))) TS_UpdateFee_get_feerate_per_kw(uint32_t this_ptr) {
10165 LDKUpdateFee this_ptr_conv;
10166 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10167 this_ptr_conv.is_owned = false;
10168 int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
10172 void __attribute__((visibility("default"))) TS_UpdateFee_set_feerate_per_kw(uint32_t this_ptr, int32_t val) {
10173 LDKUpdateFee this_ptr_conv;
10174 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10175 this_ptr_conv.is_owned = false;
10176 UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
10179 uint32_t __attribute__((visibility("default"))) TS_UpdateFee_new(int8_tArray channel_id_arg, int32_t feerate_per_kw_arg) {
10180 LDKThirtyTwoBytes channel_id_arg_ref;
10181 CHECK(*((uint32_t*)channel_id_arg) == 32);
10182 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10183 LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
10184 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10185 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10186 long ret_ref = (long)ret_var.inner;
10187 if (ret_var.is_owned) {
10193 void __attribute__((visibility("default"))) TS_DataLossProtect_free(uint32_t this_ptr) {
10194 LDKDataLossProtect this_ptr_conv;
10195 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10196 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10197 DataLossProtect_free(this_ptr_conv);
10200 uint32_t __attribute__((visibility("default"))) TS_DataLossProtect_clone(uint32_t orig) {
10201 LDKDataLossProtect orig_conv;
10202 orig_conv.inner = (void*)(orig & (~1));
10203 orig_conv.is_owned = false;
10204 LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
10205 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10206 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10207 long ret_ref = (long)ret_var.inner;
10208 if (ret_var.is_owned) {
10214 int8_tArray __attribute__((visibility("default"))) TS_DataLossProtect_get_your_last_per_commitment_secret(uint32_t this_ptr) {
10215 LDKDataLossProtect this_ptr_conv;
10216 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10217 this_ptr_conv.is_owned = false;
10218 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10219 memcpy((uint8_t*)(ret_arr + 4), *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv), 32);
10223 void __attribute__((visibility("default"))) TS_DataLossProtect_set_your_last_per_commitment_secret(uint32_t this_ptr, int8_tArray val) {
10224 LDKDataLossProtect this_ptr_conv;
10225 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10226 this_ptr_conv.is_owned = false;
10227 LDKThirtyTwoBytes val_ref;
10228 CHECK(*((uint32_t*)val) == 32);
10229 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10230 DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
10233 int8_tArray __attribute__((visibility("default"))) TS_DataLossProtect_get_my_current_per_commitment_point(uint32_t this_ptr) {
10234 LDKDataLossProtect this_ptr_conv;
10235 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10236 this_ptr_conv.is_owned = false;
10237 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10238 memcpy((uint8_t*)(arg_arr + 4), DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form, 33);
10242 void __attribute__((visibility("default"))) TS_DataLossProtect_set_my_current_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
10243 LDKDataLossProtect this_ptr_conv;
10244 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10245 this_ptr_conv.is_owned = false;
10246 LDKPublicKey val_ref;
10247 CHECK(*((uint32_t*)val) == 33);
10248 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10249 DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
10252 uint32_t __attribute__((visibility("default"))) TS_DataLossProtect_new(int8_tArray your_last_per_commitment_secret_arg, int8_tArray my_current_per_commitment_point_arg) {
10253 LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
10254 CHECK(*((uint32_t*)your_last_per_commitment_secret_arg) == 32);
10255 memcpy(your_last_per_commitment_secret_arg_ref.data, (uint8_t*)(your_last_per_commitment_secret_arg + 4), 32);
10256 LDKPublicKey my_current_per_commitment_point_arg_ref;
10257 CHECK(*((uint32_t*)my_current_per_commitment_point_arg) == 33);
10258 memcpy(my_current_per_commitment_point_arg_ref.compressed_form, (uint8_t*)(my_current_per_commitment_point_arg + 4), 33);
10259 LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
10260 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10261 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10262 long ret_ref = (long)ret_var.inner;
10263 if (ret_var.is_owned) {
10269 void __attribute__((visibility("default"))) TS_ChannelReestablish_free(uint32_t this_ptr) {
10270 LDKChannelReestablish this_ptr_conv;
10271 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10272 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10273 ChannelReestablish_free(this_ptr_conv);
10276 uint32_t __attribute__((visibility("default"))) TS_ChannelReestablish_clone(uint32_t orig) {
10277 LDKChannelReestablish orig_conv;
10278 orig_conv.inner = (void*)(orig & (~1));
10279 orig_conv.is_owned = false;
10280 LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
10281 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10282 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10283 long ret_ref = (long)ret_var.inner;
10284 if (ret_var.is_owned) {
10290 int8_tArray __attribute__((visibility("default"))) TS_ChannelReestablish_get_channel_id(uint32_t this_ptr) {
10291 LDKChannelReestablish this_ptr_conv;
10292 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10293 this_ptr_conv.is_owned = false;
10294 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10295 memcpy((uint8_t*)(ret_arr + 4), *ChannelReestablish_get_channel_id(&this_ptr_conv), 32);
10299 void __attribute__((visibility("default"))) TS_ChannelReestablish_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10300 LDKChannelReestablish this_ptr_conv;
10301 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10302 this_ptr_conv.is_owned = false;
10303 LDKThirtyTwoBytes val_ref;
10304 CHECK(*((uint32_t*)val) == 32);
10305 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10306 ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
10309 int64_t __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_local_commitment_number(uint32_t this_ptr) {
10310 LDKChannelReestablish this_ptr_conv;
10311 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10312 this_ptr_conv.is_owned = false;
10313 int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
10317 void __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_local_commitment_number(uint32_t this_ptr, int64_t val) {
10318 LDKChannelReestablish this_ptr_conv;
10319 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10320 this_ptr_conv.is_owned = false;
10321 ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
10324 int64_t __attribute__((visibility("default"))) TS_ChannelReestablish_get_next_remote_commitment_number(uint32_t this_ptr) {
10325 LDKChannelReestablish this_ptr_conv;
10326 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10327 this_ptr_conv.is_owned = false;
10328 int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
10332 void __attribute__((visibility("default"))) TS_ChannelReestablish_set_next_remote_commitment_number(uint32_t this_ptr, int64_t val) {
10333 LDKChannelReestablish this_ptr_conv;
10334 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10335 this_ptr_conv.is_owned = false;
10336 ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
10339 void __attribute__((visibility("default"))) TS_AnnouncementSignatures_free(uint32_t this_ptr) {
10340 LDKAnnouncementSignatures this_ptr_conv;
10341 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10342 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10343 AnnouncementSignatures_free(this_ptr_conv);
10346 uint32_t __attribute__((visibility("default"))) TS_AnnouncementSignatures_clone(uint32_t orig) {
10347 LDKAnnouncementSignatures orig_conv;
10348 orig_conv.inner = (void*)(orig & (~1));
10349 orig_conv.is_owned = false;
10350 LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
10351 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10352 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10353 long ret_ref = (long)ret_var.inner;
10354 if (ret_var.is_owned) {
10360 int8_tArray __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_channel_id(uint32_t this_ptr) {
10361 LDKAnnouncementSignatures this_ptr_conv;
10362 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10363 this_ptr_conv.is_owned = false;
10364 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10365 memcpy((uint8_t*)(ret_arr + 4), *AnnouncementSignatures_get_channel_id(&this_ptr_conv), 32);
10369 void __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_channel_id(uint32_t this_ptr, int8_tArray val) {
10370 LDKAnnouncementSignatures this_ptr_conv;
10371 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10372 this_ptr_conv.is_owned = false;
10373 LDKThirtyTwoBytes val_ref;
10374 CHECK(*((uint32_t*)val) == 32);
10375 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10376 AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
10379 int64_t __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_short_channel_id(uint32_t this_ptr) {
10380 LDKAnnouncementSignatures this_ptr_conv;
10381 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10382 this_ptr_conv.is_owned = false;
10383 int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
10387 void __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_short_channel_id(uint32_t this_ptr, int64_t val) {
10388 LDKAnnouncementSignatures this_ptr_conv;
10389 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10390 this_ptr_conv.is_owned = false;
10391 AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
10394 int8_tArray __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_node_signature(uint32_t this_ptr) {
10395 LDKAnnouncementSignatures this_ptr_conv;
10396 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10397 this_ptr_conv.is_owned = false;
10398 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10399 memcpy((uint8_t*)(arg_arr + 4), AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form, 64);
10403 void __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_node_signature(uint32_t this_ptr, int8_tArray val) {
10404 LDKAnnouncementSignatures this_ptr_conv;
10405 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10406 this_ptr_conv.is_owned = false;
10407 LDKSignature val_ref;
10408 CHECK(*((uint32_t*)val) == 64);
10409 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10410 AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
10413 int8_tArray __attribute__((visibility("default"))) TS_AnnouncementSignatures_get_bitcoin_signature(uint32_t this_ptr) {
10414 LDKAnnouncementSignatures this_ptr_conv;
10415 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10416 this_ptr_conv.is_owned = false;
10417 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10418 memcpy((uint8_t*)(arg_arr + 4), AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form, 64);
10422 void __attribute__((visibility("default"))) TS_AnnouncementSignatures_set_bitcoin_signature(uint32_t this_ptr, int8_tArray val) {
10423 LDKAnnouncementSignatures this_ptr_conv;
10424 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10425 this_ptr_conv.is_owned = false;
10426 LDKSignature val_ref;
10427 CHECK(*((uint32_t*)val) == 64);
10428 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10429 AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
10432 uint32_t __attribute__((visibility("default"))) TS_AnnouncementSignatures_new(int8_tArray channel_id_arg, int64_t short_channel_id_arg, int8_tArray node_signature_arg, int8_tArray bitcoin_signature_arg) {
10433 LDKThirtyTwoBytes channel_id_arg_ref;
10434 CHECK(*((uint32_t*)channel_id_arg) == 32);
10435 memcpy(channel_id_arg_ref.data, (uint8_t*)(channel_id_arg + 4), 32);
10436 LDKSignature node_signature_arg_ref;
10437 CHECK(*((uint32_t*)node_signature_arg) == 64);
10438 memcpy(node_signature_arg_ref.compact_form, (uint8_t*)(node_signature_arg + 4), 64);
10439 LDKSignature bitcoin_signature_arg_ref;
10440 CHECK(*((uint32_t*)bitcoin_signature_arg) == 64);
10441 memcpy(bitcoin_signature_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_arg + 4), 64);
10442 LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
10443 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10444 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10445 long ret_ref = (long)ret_var.inner;
10446 if (ret_var.is_owned) {
10452 void __attribute__((visibility("default"))) TS_NetAddress_free(uint32_t this_ptr) {
10453 LDKNetAddress this_ptr_conv = *(LDKNetAddress*)this_ptr;
10454 FREE((void*)this_ptr);
10455 NetAddress_free(this_ptr_conv);
10458 uint32_t __attribute__((visibility("default"))) TS_NetAddress_clone(uint32_t orig) {
10459 LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
10460 LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
10461 *ret_copy = NetAddress_clone(orig_conv);
10462 long ret_ref = (long)ret_copy;
10466 int8_tArray __attribute__((visibility("default"))) TS_NetAddress_write(uint32_t obj) {
10467 LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
10468 LDKCVec_u8Z arg_var = NetAddress_write(obj_conv);
10469 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
10470 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
10471 CVec_u8Z_free(arg_var);
10475 uint32_t __attribute__((visibility("default"))) TS_Result_read(int8_tArray ser) {
10476 LDKu8slice ser_ref;
10477 ser_ref.datalen = *((uint32_t*)ser);
10478 ser_ref.data = (int8_t*)(ser + 4);
10479 LDKCResult_CResult_NetAddressu8ZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CResult_NetAddressu8ZDecodeErrorZ), "LDKCResult_CResult_NetAddressu8ZDecodeErrorZ");
10480 *ret_conv = Result_read(ser_ref);
10481 return (long)ret_conv;
10484 void __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_free(uint32_t this_ptr) {
10485 LDKUnsignedNodeAnnouncement this_ptr_conv;
10486 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10487 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10488 UnsignedNodeAnnouncement_free(this_ptr_conv);
10491 uint32_t __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_clone(uint32_t orig) {
10492 LDKUnsignedNodeAnnouncement orig_conv;
10493 orig_conv.inner = (void*)(orig & (~1));
10494 orig_conv.is_owned = false;
10495 LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
10496 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10497 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10498 long ret_ref = (long)ret_var.inner;
10499 if (ret_var.is_owned) {
10505 uint32_t __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_features(uint32_t this_ptr) {
10506 LDKUnsignedNodeAnnouncement this_ptr_conv;
10507 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10508 this_ptr_conv.is_owned = false;
10509 LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
10510 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10511 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10512 long ret_ref = (long)ret_var.inner;
10513 if (ret_var.is_owned) {
10519 void __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
10520 LDKUnsignedNodeAnnouncement this_ptr_conv;
10521 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10522 this_ptr_conv.is_owned = false;
10523 LDKNodeFeatures val_conv;
10524 val_conv.inner = (void*)(val & (~1));
10525 val_conv.is_owned = (val & 1) || (val == 0);
10526 // Warning: we may need a move here but can't clone!
10527 UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
10530 int32_t __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_timestamp(uint32_t this_ptr) {
10531 LDKUnsignedNodeAnnouncement this_ptr_conv;
10532 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10533 this_ptr_conv.is_owned = false;
10534 int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
10538 void __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_timestamp(uint32_t this_ptr, int32_t val) {
10539 LDKUnsignedNodeAnnouncement this_ptr_conv;
10540 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10541 this_ptr_conv.is_owned = false;
10542 UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
10545 int8_tArray __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_node_id(uint32_t this_ptr) {
10546 LDKUnsignedNodeAnnouncement this_ptr_conv;
10547 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10548 this_ptr_conv.is_owned = false;
10549 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10550 memcpy((uint8_t*)(arg_arr + 4), UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form, 33);
10554 void __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_node_id(uint32_t this_ptr, int8_tArray val) {
10555 LDKUnsignedNodeAnnouncement this_ptr_conv;
10556 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10557 this_ptr_conv.is_owned = false;
10558 LDKPublicKey val_ref;
10559 CHECK(*((uint32_t*)val) == 33);
10560 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10561 UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
10564 int8_tArray __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_rgb(uint32_t this_ptr) {
10565 LDKUnsignedNodeAnnouncement this_ptr_conv;
10566 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10567 this_ptr_conv.is_owned = false;
10568 int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
10569 memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv), 3);
10573 void __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_rgb(uint32_t this_ptr, int8_tArray val) {
10574 LDKUnsignedNodeAnnouncement this_ptr_conv;
10575 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10576 this_ptr_conv.is_owned = false;
10577 LDKThreeBytes val_ref;
10578 CHECK(*((uint32_t*)val) == 3);
10579 memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
10580 UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
10583 int8_tArray __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_get_alias(uint32_t this_ptr) {
10584 LDKUnsignedNodeAnnouncement this_ptr_conv;
10585 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10586 this_ptr_conv.is_owned = false;
10587 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10588 memcpy((uint8_t*)(ret_arr + 4), *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv), 32);
10592 void __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_alias(uint32_t this_ptr, int8_tArray val) {
10593 LDKUnsignedNodeAnnouncement this_ptr_conv;
10594 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10595 this_ptr_conv.is_owned = false;
10596 LDKThirtyTwoBytes val_ref;
10597 CHECK(*((uint32_t*)val) == 32);
10598 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10599 UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
10602 void __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_set_addresses(uint32_t this_ptr, uint32_tArray val) {
10603 LDKUnsignedNodeAnnouncement this_ptr_conv;
10604 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10605 this_ptr_conv.is_owned = false;
10606 LDKCVec_NetAddressZ val_constr;
10607 val_constr.datalen = *((uint32_t*)val);
10608 if (val_constr.datalen > 0)
10609 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
10611 val_constr.data = NULL;
10612 uint32_t* val_vals = (uint32_t*)(val + 4);
10613 for (size_t m = 0; m < val_constr.datalen; m++) {
10614 uint32_t arr_conv_12 = val_vals[m];
10615 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
10616 FREE((void*)arr_conv_12);
10617 val_constr.data[m] = arr_conv_12_conv;
10619 UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
10622 void __attribute__((visibility("default"))) TS_NodeAnnouncement_free(uint32_t this_ptr) {
10623 LDKNodeAnnouncement this_ptr_conv;
10624 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10625 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10626 NodeAnnouncement_free(this_ptr_conv);
10629 uint32_t __attribute__((visibility("default"))) TS_NodeAnnouncement_clone(uint32_t orig) {
10630 LDKNodeAnnouncement orig_conv;
10631 orig_conv.inner = (void*)(orig & (~1));
10632 orig_conv.is_owned = false;
10633 LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
10634 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10635 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10636 long ret_ref = (long)ret_var.inner;
10637 if (ret_var.is_owned) {
10643 int8_tArray __attribute__((visibility("default"))) TS_NodeAnnouncement_get_signature(uint32_t this_ptr) {
10644 LDKNodeAnnouncement this_ptr_conv;
10645 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10646 this_ptr_conv.is_owned = false;
10647 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10648 memcpy((uint8_t*)(arg_arr + 4), NodeAnnouncement_get_signature(&this_ptr_conv).compact_form, 64);
10652 void __attribute__((visibility("default"))) TS_NodeAnnouncement_set_signature(uint32_t this_ptr, int8_tArray val) {
10653 LDKNodeAnnouncement this_ptr_conv;
10654 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10655 this_ptr_conv.is_owned = false;
10656 LDKSignature val_ref;
10657 CHECK(*((uint32_t*)val) == 64);
10658 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10659 NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
10662 uint32_t __attribute__((visibility("default"))) TS_NodeAnnouncement_get_contents(uint32_t this_ptr) {
10663 LDKNodeAnnouncement this_ptr_conv;
10664 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10665 this_ptr_conv.is_owned = false;
10666 LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
10667 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10668 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10669 long ret_ref = (long)ret_var.inner;
10670 if (ret_var.is_owned) {
10676 void __attribute__((visibility("default"))) TS_NodeAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
10677 LDKNodeAnnouncement this_ptr_conv;
10678 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10679 this_ptr_conv.is_owned = false;
10680 LDKUnsignedNodeAnnouncement val_conv;
10681 val_conv.inner = (void*)(val & (~1));
10682 val_conv.is_owned = (val & 1) || (val == 0);
10683 if (val_conv.inner != NULL)
10684 val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
10685 NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
10688 uint32_t __attribute__((visibility("default"))) TS_NodeAnnouncement_new(int8_tArray signature_arg, uint32_t contents_arg) {
10689 LDKSignature signature_arg_ref;
10690 CHECK(*((uint32_t*)signature_arg) == 64);
10691 memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
10692 LDKUnsignedNodeAnnouncement contents_arg_conv;
10693 contents_arg_conv.inner = (void*)(contents_arg & (~1));
10694 contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
10695 if (contents_arg_conv.inner != NULL)
10696 contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
10697 LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
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) {
10707 void __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_free(uint32_t this_ptr) {
10708 LDKUnsignedChannelAnnouncement 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 UnsignedChannelAnnouncement_free(this_ptr_conv);
10714 uint32_t __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_clone(uint32_t orig) {
10715 LDKUnsignedChannelAnnouncement orig_conv;
10716 orig_conv.inner = (void*)(orig & (~1));
10717 orig_conv.is_owned = false;
10718 LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_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) {
10728 uint32_t __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_features(uint32_t this_ptr) {
10729 LDKUnsignedChannelAnnouncement this_ptr_conv;
10730 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10731 this_ptr_conv.is_owned = false;
10732 LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
10733 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10734 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10735 long ret_ref = (long)ret_var.inner;
10736 if (ret_var.is_owned) {
10742 void __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_features(uint32_t this_ptr, uint32_t val) {
10743 LDKUnsignedChannelAnnouncement this_ptr_conv;
10744 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10745 this_ptr_conv.is_owned = false;
10746 LDKChannelFeatures val_conv;
10747 val_conv.inner = (void*)(val & (~1));
10748 val_conv.is_owned = (val & 1) || (val == 0);
10749 // Warning: we may need a move here but can't clone!
10750 UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
10753 int8_tArray __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_chain_hash(uint32_t this_ptr) {
10754 LDKUnsignedChannelAnnouncement this_ptr_conv;
10755 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10756 this_ptr_conv.is_owned = false;
10757 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
10758 memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv), 32);
10762 void __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
10763 LDKUnsignedChannelAnnouncement this_ptr_conv;
10764 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10765 this_ptr_conv.is_owned = false;
10766 LDKThirtyTwoBytes val_ref;
10767 CHECK(*((uint32_t*)val) == 32);
10768 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
10769 UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
10772 int64_t __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_short_channel_id(uint32_t this_ptr) {
10773 LDKUnsignedChannelAnnouncement this_ptr_conv;
10774 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10775 this_ptr_conv.is_owned = false;
10776 int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
10780 void __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_short_channel_id(uint32_t this_ptr, int64_t val) {
10781 LDKUnsignedChannelAnnouncement this_ptr_conv;
10782 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10783 this_ptr_conv.is_owned = false;
10784 UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
10787 int8_tArray __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_1(uint32_t this_ptr) {
10788 LDKUnsignedChannelAnnouncement this_ptr_conv;
10789 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10790 this_ptr_conv.is_owned = false;
10791 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10792 memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form, 33);
10796 void __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_1(uint32_t this_ptr, int8_tArray val) {
10797 LDKUnsignedChannelAnnouncement this_ptr_conv;
10798 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10799 this_ptr_conv.is_owned = false;
10800 LDKPublicKey val_ref;
10801 CHECK(*((uint32_t*)val) == 33);
10802 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10803 UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
10806 int8_tArray __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_node_id_2(uint32_t this_ptr) {
10807 LDKUnsignedChannelAnnouncement this_ptr_conv;
10808 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10809 this_ptr_conv.is_owned = false;
10810 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10811 memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form, 33);
10815 void __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_node_id_2(uint32_t this_ptr, int8_tArray val) {
10816 LDKUnsignedChannelAnnouncement this_ptr_conv;
10817 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10818 this_ptr_conv.is_owned = false;
10819 LDKPublicKey val_ref;
10820 CHECK(*((uint32_t*)val) == 33);
10821 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10822 UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
10825 int8_tArray __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_1(uint32_t this_ptr) {
10826 LDKUnsignedChannelAnnouncement this_ptr_conv;
10827 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10828 this_ptr_conv.is_owned = false;
10829 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10830 memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form, 33);
10834 void __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_1(uint32_t this_ptr, int8_tArray val) {
10835 LDKUnsignedChannelAnnouncement this_ptr_conv;
10836 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10837 this_ptr_conv.is_owned = false;
10838 LDKPublicKey val_ref;
10839 CHECK(*((uint32_t*)val) == 33);
10840 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10841 UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
10844 int8_tArray __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_get_bitcoin_key_2(uint32_t this_ptr) {
10845 LDKUnsignedChannelAnnouncement this_ptr_conv;
10846 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10847 this_ptr_conv.is_owned = false;
10848 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
10849 memcpy((uint8_t*)(arg_arr + 4), UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form, 33);
10853 void __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_set_bitcoin_key_2(uint32_t this_ptr, int8_tArray val) {
10854 LDKUnsignedChannelAnnouncement this_ptr_conv;
10855 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10856 this_ptr_conv.is_owned = false;
10857 LDKPublicKey val_ref;
10858 CHECK(*((uint32_t*)val) == 33);
10859 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
10860 UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
10863 void __attribute__((visibility("default"))) TS_ChannelAnnouncement_free(uint32_t this_ptr) {
10864 LDKChannelAnnouncement this_ptr_conv;
10865 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10866 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
10867 ChannelAnnouncement_free(this_ptr_conv);
10870 uint32_t __attribute__((visibility("default"))) TS_ChannelAnnouncement_clone(uint32_t orig) {
10871 LDKChannelAnnouncement orig_conv;
10872 orig_conv.inner = (void*)(orig & (~1));
10873 orig_conv.is_owned = false;
10874 LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
10875 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10876 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10877 long ret_ref = (long)ret_var.inner;
10878 if (ret_var.is_owned) {
10884 int8_tArray __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_1(uint32_t this_ptr) {
10885 LDKChannelAnnouncement this_ptr_conv;
10886 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10887 this_ptr_conv.is_owned = false;
10888 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10889 memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form, 64);
10893 void __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_1(uint32_t this_ptr, int8_tArray val) {
10894 LDKChannelAnnouncement this_ptr_conv;
10895 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10896 this_ptr_conv.is_owned = false;
10897 LDKSignature val_ref;
10898 CHECK(*((uint32_t*)val) == 64);
10899 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10900 ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
10903 int8_tArray __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_node_signature_2(uint32_t this_ptr) {
10904 LDKChannelAnnouncement this_ptr_conv;
10905 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10906 this_ptr_conv.is_owned = false;
10907 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10908 memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form, 64);
10912 void __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_node_signature_2(uint32_t this_ptr, int8_tArray val) {
10913 LDKChannelAnnouncement this_ptr_conv;
10914 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10915 this_ptr_conv.is_owned = false;
10916 LDKSignature val_ref;
10917 CHECK(*((uint32_t*)val) == 64);
10918 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10919 ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
10922 int8_tArray __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_1(uint32_t this_ptr) {
10923 LDKChannelAnnouncement this_ptr_conv;
10924 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10925 this_ptr_conv.is_owned = false;
10926 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10927 memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form, 64);
10931 void __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_1(uint32_t this_ptr, int8_tArray val) {
10932 LDKChannelAnnouncement this_ptr_conv;
10933 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10934 this_ptr_conv.is_owned = false;
10935 LDKSignature val_ref;
10936 CHECK(*((uint32_t*)val) == 64);
10937 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10938 ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
10941 int8_tArray __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_bitcoin_signature_2(uint32_t this_ptr) {
10942 LDKChannelAnnouncement this_ptr_conv;
10943 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10944 this_ptr_conv.is_owned = false;
10945 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
10946 memcpy((uint8_t*)(arg_arr + 4), ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form, 64);
10950 void __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_bitcoin_signature_2(uint32_t this_ptr, int8_tArray val) {
10951 LDKChannelAnnouncement this_ptr_conv;
10952 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10953 this_ptr_conv.is_owned = false;
10954 LDKSignature val_ref;
10955 CHECK(*((uint32_t*)val) == 64);
10956 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
10957 ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
10960 uint32_t __attribute__((visibility("default"))) TS_ChannelAnnouncement_get_contents(uint32_t this_ptr) {
10961 LDKChannelAnnouncement this_ptr_conv;
10962 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10963 this_ptr_conv.is_owned = false;
10964 LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
10965 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10966 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10967 long ret_ref = (long)ret_var.inner;
10968 if (ret_var.is_owned) {
10974 void __attribute__((visibility("default"))) TS_ChannelAnnouncement_set_contents(uint32_t this_ptr, uint32_t val) {
10975 LDKChannelAnnouncement this_ptr_conv;
10976 this_ptr_conv.inner = (void*)(this_ptr & (~1));
10977 this_ptr_conv.is_owned = false;
10978 LDKUnsignedChannelAnnouncement val_conv;
10979 val_conv.inner = (void*)(val & (~1));
10980 val_conv.is_owned = (val & 1) || (val == 0);
10981 if (val_conv.inner != NULL)
10982 val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
10983 ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
10986 uint32_t __attribute__((visibility("default"))) TS_ChannelAnnouncement_new(int8_tArray node_signature_1_arg, int8_tArray node_signature_2_arg, int8_tArray bitcoin_signature_1_arg, int8_tArray bitcoin_signature_2_arg, uint32_t contents_arg) {
10987 LDKSignature node_signature_1_arg_ref;
10988 CHECK(*((uint32_t*)node_signature_1_arg) == 64);
10989 memcpy(node_signature_1_arg_ref.compact_form, (uint8_t*)(node_signature_1_arg + 4), 64);
10990 LDKSignature node_signature_2_arg_ref;
10991 CHECK(*((uint32_t*)node_signature_2_arg) == 64);
10992 memcpy(node_signature_2_arg_ref.compact_form, (uint8_t*)(node_signature_2_arg + 4), 64);
10993 LDKSignature bitcoin_signature_1_arg_ref;
10994 CHECK(*((uint32_t*)bitcoin_signature_1_arg) == 64);
10995 memcpy(bitcoin_signature_1_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_1_arg + 4), 64);
10996 LDKSignature bitcoin_signature_2_arg_ref;
10997 CHECK(*((uint32_t*)bitcoin_signature_2_arg) == 64);
10998 memcpy(bitcoin_signature_2_arg_ref.compact_form, (uint8_t*)(bitcoin_signature_2_arg + 4), 64);
10999 LDKUnsignedChannelAnnouncement contents_arg_conv;
11000 contents_arg_conv.inner = (void*)(contents_arg & (~1));
11001 contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
11002 if (contents_arg_conv.inner != NULL)
11003 contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
11004 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);
11005 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11006 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11007 long ret_ref = (long)ret_var.inner;
11008 if (ret_var.is_owned) {
11014 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_free(uint32_t this_ptr) {
11015 LDKUnsignedChannelUpdate this_ptr_conv;
11016 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11017 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11018 UnsignedChannelUpdate_free(this_ptr_conv);
11021 uint32_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_clone(uint32_t orig) {
11022 LDKUnsignedChannelUpdate orig_conv;
11023 orig_conv.inner = (void*)(orig & (~1));
11024 orig_conv.is_owned = false;
11025 LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
11026 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11027 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11028 long ret_ref = (long)ret_var.inner;
11029 if (ret_var.is_owned) {
11035 int8_tArray __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_chain_hash(uint32_t this_ptr) {
11036 LDKUnsignedChannelUpdate this_ptr_conv;
11037 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11038 this_ptr_conv.is_owned = false;
11039 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11040 memcpy((uint8_t*)(ret_arr + 4), *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv), 32);
11044 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11045 LDKUnsignedChannelUpdate this_ptr_conv;
11046 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11047 this_ptr_conv.is_owned = false;
11048 LDKThirtyTwoBytes val_ref;
11049 CHECK(*((uint32_t*)val) == 32);
11050 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11051 UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
11054 int64_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_short_channel_id(uint32_t this_ptr) {
11055 LDKUnsignedChannelUpdate this_ptr_conv;
11056 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11057 this_ptr_conv.is_owned = false;
11058 int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
11062 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_short_channel_id(uint32_t this_ptr, int64_t val) {
11063 LDKUnsignedChannelUpdate this_ptr_conv;
11064 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11065 this_ptr_conv.is_owned = false;
11066 UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
11069 int32_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_timestamp(uint32_t this_ptr) {
11070 LDKUnsignedChannelUpdate this_ptr_conv;
11071 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11072 this_ptr_conv.is_owned = false;
11073 int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
11077 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_timestamp(uint32_t this_ptr, int32_t val) {
11078 LDKUnsignedChannelUpdate this_ptr_conv;
11079 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11080 this_ptr_conv.is_owned = false;
11081 UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
11084 int8_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_flags(uint32_t this_ptr) {
11085 LDKUnsignedChannelUpdate this_ptr_conv;
11086 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11087 this_ptr_conv.is_owned = false;
11088 int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
11092 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_flags(uint32_t this_ptr, int8_t val) {
11093 LDKUnsignedChannelUpdate this_ptr_conv;
11094 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11095 this_ptr_conv.is_owned = false;
11096 UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
11099 int16_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_cltv_expiry_delta(uint32_t this_ptr) {
11100 LDKUnsignedChannelUpdate this_ptr_conv;
11101 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11102 this_ptr_conv.is_owned = false;
11103 int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
11107 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
11108 LDKUnsignedChannelUpdate this_ptr_conv;
11109 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11110 this_ptr_conv.is_owned = false;
11111 UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
11114 int64_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_htlc_minimum_msat(uint32_t this_ptr) {
11115 LDKUnsignedChannelUpdate this_ptr_conv;
11116 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11117 this_ptr_conv.is_owned = false;
11118 int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
11122 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
11123 LDKUnsignedChannelUpdate this_ptr_conv;
11124 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11125 this_ptr_conv.is_owned = false;
11126 UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
11129 int32_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_base_msat(uint32_t this_ptr) {
11130 LDKUnsignedChannelUpdate this_ptr_conv;
11131 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11132 this_ptr_conv.is_owned = false;
11133 int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
11137 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_base_msat(uint32_t this_ptr, int32_t val) {
11138 LDKUnsignedChannelUpdate this_ptr_conv;
11139 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11140 this_ptr_conv.is_owned = false;
11141 UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
11144 int32_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_get_fee_proportional_millionths(uint32_t this_ptr) {
11145 LDKUnsignedChannelUpdate this_ptr_conv;
11146 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11147 this_ptr_conv.is_owned = false;
11148 int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
11152 void __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_set_fee_proportional_millionths(uint32_t this_ptr, int32_t val) {
11153 LDKUnsignedChannelUpdate this_ptr_conv;
11154 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11155 this_ptr_conv.is_owned = false;
11156 UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
11159 void __attribute__((visibility("default"))) TS_ChannelUpdate_free(uint32_t this_ptr) {
11160 LDKChannelUpdate this_ptr_conv;
11161 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11162 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11163 ChannelUpdate_free(this_ptr_conv);
11166 uint32_t __attribute__((visibility("default"))) TS_ChannelUpdate_clone(uint32_t orig) {
11167 LDKChannelUpdate orig_conv;
11168 orig_conv.inner = (void*)(orig & (~1));
11169 orig_conv.is_owned = false;
11170 LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
11171 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11172 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11173 long ret_ref = (long)ret_var.inner;
11174 if (ret_var.is_owned) {
11180 int8_tArray __attribute__((visibility("default"))) TS_ChannelUpdate_get_signature(uint32_t this_ptr) {
11181 LDKChannelUpdate this_ptr_conv;
11182 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11183 this_ptr_conv.is_owned = false;
11184 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
11185 memcpy((uint8_t*)(arg_arr + 4), ChannelUpdate_get_signature(&this_ptr_conv).compact_form, 64);
11189 void __attribute__((visibility("default"))) TS_ChannelUpdate_set_signature(uint32_t this_ptr, int8_tArray val) {
11190 LDKChannelUpdate this_ptr_conv;
11191 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11192 this_ptr_conv.is_owned = false;
11193 LDKSignature val_ref;
11194 CHECK(*((uint32_t*)val) == 64);
11195 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
11196 ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
11199 uint32_t __attribute__((visibility("default"))) TS_ChannelUpdate_get_contents(uint32_t this_ptr) {
11200 LDKChannelUpdate this_ptr_conv;
11201 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11202 this_ptr_conv.is_owned = false;
11203 LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
11204 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11205 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11206 long ret_ref = (long)ret_var.inner;
11207 if (ret_var.is_owned) {
11213 void __attribute__((visibility("default"))) TS_ChannelUpdate_set_contents(uint32_t this_ptr, uint32_t val) {
11214 LDKChannelUpdate this_ptr_conv;
11215 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11216 this_ptr_conv.is_owned = false;
11217 LDKUnsignedChannelUpdate val_conv;
11218 val_conv.inner = (void*)(val & (~1));
11219 val_conv.is_owned = (val & 1) || (val == 0);
11220 if (val_conv.inner != NULL)
11221 val_conv = UnsignedChannelUpdate_clone(&val_conv);
11222 ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
11225 uint32_t __attribute__((visibility("default"))) TS_ChannelUpdate_new(int8_tArray signature_arg, uint32_t contents_arg) {
11226 LDKSignature signature_arg_ref;
11227 CHECK(*((uint32_t*)signature_arg) == 64);
11228 memcpy(signature_arg_ref.compact_form, (uint8_t*)(signature_arg + 4), 64);
11229 LDKUnsignedChannelUpdate contents_arg_conv;
11230 contents_arg_conv.inner = (void*)(contents_arg & (~1));
11231 contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
11232 if (contents_arg_conv.inner != NULL)
11233 contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
11234 LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
11235 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11236 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11237 long ret_ref = (long)ret_var.inner;
11238 if (ret_var.is_owned) {
11244 void __attribute__((visibility("default"))) TS_QueryChannelRange_free(uint32_t this_ptr) {
11245 LDKQueryChannelRange this_ptr_conv;
11246 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11247 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11248 QueryChannelRange_free(this_ptr_conv);
11251 uint32_t __attribute__((visibility("default"))) TS_QueryChannelRange_clone(uint32_t orig) {
11252 LDKQueryChannelRange orig_conv;
11253 orig_conv.inner = (void*)(orig & (~1));
11254 orig_conv.is_owned = false;
11255 LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
11256 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11257 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11258 long ret_ref = (long)ret_var.inner;
11259 if (ret_var.is_owned) {
11265 int8_tArray __attribute__((visibility("default"))) TS_QueryChannelRange_get_chain_hash(uint32_t this_ptr) {
11266 LDKQueryChannelRange this_ptr_conv;
11267 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11268 this_ptr_conv.is_owned = false;
11269 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11270 memcpy((uint8_t*)(ret_arr + 4), *QueryChannelRange_get_chain_hash(&this_ptr_conv), 32);
11274 void __attribute__((visibility("default"))) TS_QueryChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11275 LDKQueryChannelRange this_ptr_conv;
11276 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11277 this_ptr_conv.is_owned = false;
11278 LDKThirtyTwoBytes val_ref;
11279 CHECK(*((uint32_t*)val) == 32);
11280 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11281 QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
11284 int32_t __attribute__((visibility("default"))) TS_QueryChannelRange_get_first_blocknum(uint32_t this_ptr) {
11285 LDKQueryChannelRange this_ptr_conv;
11286 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11287 this_ptr_conv.is_owned = false;
11288 int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
11292 void __attribute__((visibility("default"))) TS_QueryChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
11293 LDKQueryChannelRange this_ptr_conv;
11294 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11295 this_ptr_conv.is_owned = false;
11296 QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
11299 int32_t __attribute__((visibility("default"))) TS_QueryChannelRange_get_number_of_blocks(uint32_t this_ptr) {
11300 LDKQueryChannelRange this_ptr_conv;
11301 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11302 this_ptr_conv.is_owned = false;
11303 int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
11307 void __attribute__((visibility("default"))) TS_QueryChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
11308 LDKQueryChannelRange this_ptr_conv;
11309 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11310 this_ptr_conv.is_owned = false;
11311 QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
11314 uint32_t __attribute__((visibility("default"))) TS_QueryChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg) {
11315 LDKThirtyTwoBytes chain_hash_arg_ref;
11316 CHECK(*((uint32_t*)chain_hash_arg) == 32);
11317 memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11318 LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
11319 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11320 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11321 long ret_ref = (long)ret_var.inner;
11322 if (ret_var.is_owned) {
11328 void __attribute__((visibility("default"))) TS_ReplyChannelRange_free(uint32_t this_ptr) {
11329 LDKReplyChannelRange this_ptr_conv;
11330 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11331 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11332 ReplyChannelRange_free(this_ptr_conv);
11335 uint32_t __attribute__((visibility("default"))) TS_ReplyChannelRange_clone(uint32_t orig) {
11336 LDKReplyChannelRange orig_conv;
11337 orig_conv.inner = (void*)(orig & (~1));
11338 orig_conv.is_owned = false;
11339 LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
11340 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11341 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11342 long ret_ref = (long)ret_var.inner;
11343 if (ret_var.is_owned) {
11349 int8_tArray __attribute__((visibility("default"))) TS_ReplyChannelRange_get_chain_hash(uint32_t this_ptr) {
11350 LDKReplyChannelRange this_ptr_conv;
11351 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11352 this_ptr_conv.is_owned = false;
11353 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11354 memcpy((uint8_t*)(ret_arr + 4), *ReplyChannelRange_get_chain_hash(&this_ptr_conv), 32);
11358 void __attribute__((visibility("default"))) TS_ReplyChannelRange_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11359 LDKReplyChannelRange this_ptr_conv;
11360 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11361 this_ptr_conv.is_owned = false;
11362 LDKThirtyTwoBytes val_ref;
11363 CHECK(*((uint32_t*)val) == 32);
11364 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11365 ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
11368 int32_t __attribute__((visibility("default"))) TS_ReplyChannelRange_get_first_blocknum(uint32_t this_ptr) {
11369 LDKReplyChannelRange this_ptr_conv;
11370 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11371 this_ptr_conv.is_owned = false;
11372 int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
11376 void __attribute__((visibility("default"))) TS_ReplyChannelRange_set_first_blocknum(uint32_t this_ptr, int32_t val) {
11377 LDKReplyChannelRange this_ptr_conv;
11378 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11379 this_ptr_conv.is_owned = false;
11380 ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
11383 int32_t __attribute__((visibility("default"))) TS_ReplyChannelRange_get_number_of_blocks(uint32_t this_ptr) {
11384 LDKReplyChannelRange this_ptr_conv;
11385 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11386 this_ptr_conv.is_owned = false;
11387 int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
11391 void __attribute__((visibility("default"))) TS_ReplyChannelRange_set_number_of_blocks(uint32_t this_ptr, int32_t val) {
11392 LDKReplyChannelRange this_ptr_conv;
11393 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11394 this_ptr_conv.is_owned = false;
11395 ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
11398 jboolean __attribute__((visibility("default"))) TS_ReplyChannelRange_get_full_information(uint32_t this_ptr) {
11399 LDKReplyChannelRange this_ptr_conv;
11400 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11401 this_ptr_conv.is_owned = false;
11402 jboolean ret_val = ReplyChannelRange_get_full_information(&this_ptr_conv);
11406 void __attribute__((visibility("default"))) TS_ReplyChannelRange_set_full_information(uint32_t this_ptr, jboolean val) {
11407 LDKReplyChannelRange this_ptr_conv;
11408 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11409 this_ptr_conv.is_owned = false;
11410 ReplyChannelRange_set_full_information(&this_ptr_conv, val);
11413 void __attribute__((visibility("default"))) TS_ReplyChannelRange_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
11414 LDKReplyChannelRange this_ptr_conv;
11415 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11416 this_ptr_conv.is_owned = false;
11417 LDKCVec_u64Z val_constr;
11418 val_constr.datalen = *((uint32_t*)val);
11419 if (val_constr.datalen > 0)
11420 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11422 val_constr.data = NULL;
11423 int64_t* val_vals = (int64_t*)(val + 4);
11424 for (size_t i = 0; i < val_constr.datalen; i++) {
11425 int64_t arr_conv_8 = val_vals[i];
11426 val_constr.data[i] = arr_conv_8;
11428 ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
11431 uint32_t __attribute__((visibility("default"))) TS_ReplyChannelRange_new(int8_tArray chain_hash_arg, int32_t first_blocknum_arg, int32_t number_of_blocks_arg, jboolean full_information_arg, int64_tArray short_channel_ids_arg) {
11432 LDKThirtyTwoBytes chain_hash_arg_ref;
11433 CHECK(*((uint32_t*)chain_hash_arg) == 32);
11434 memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11435 LDKCVec_u64Z short_channel_ids_arg_constr;
11436 short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
11437 if (short_channel_ids_arg_constr.datalen > 0)
11438 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11440 short_channel_ids_arg_constr.data = NULL;
11441 int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
11442 for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
11443 int64_t arr_conv_8 = short_channel_ids_arg_vals[i];
11444 short_channel_ids_arg_constr.data[i] = arr_conv_8;
11446 LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, full_information_arg, short_channel_ids_arg_constr);
11447 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11448 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11449 long ret_ref = (long)ret_var.inner;
11450 if (ret_var.is_owned) {
11456 void __attribute__((visibility("default"))) TS_QueryShortChannelIds_free(uint32_t this_ptr) {
11457 LDKQueryShortChannelIds this_ptr_conv;
11458 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11459 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11460 QueryShortChannelIds_free(this_ptr_conv);
11463 uint32_t __attribute__((visibility("default"))) TS_QueryShortChannelIds_clone(uint32_t orig) {
11464 LDKQueryShortChannelIds orig_conv;
11465 orig_conv.inner = (void*)(orig & (~1));
11466 orig_conv.is_owned = false;
11467 LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
11468 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11469 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11470 long ret_ref = (long)ret_var.inner;
11471 if (ret_var.is_owned) {
11477 int8_tArray __attribute__((visibility("default"))) TS_QueryShortChannelIds_get_chain_hash(uint32_t this_ptr) {
11478 LDKQueryShortChannelIds this_ptr_conv;
11479 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11480 this_ptr_conv.is_owned = false;
11481 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11482 memcpy((uint8_t*)(ret_arr + 4), *QueryShortChannelIds_get_chain_hash(&this_ptr_conv), 32);
11486 void __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11487 LDKQueryShortChannelIds this_ptr_conv;
11488 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11489 this_ptr_conv.is_owned = false;
11490 LDKThirtyTwoBytes val_ref;
11491 CHECK(*((uint32_t*)val) == 32);
11492 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11493 QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
11496 void __attribute__((visibility("default"))) TS_QueryShortChannelIds_set_short_channel_ids(uint32_t this_ptr, int64_tArray val) {
11497 LDKQueryShortChannelIds this_ptr_conv;
11498 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11499 this_ptr_conv.is_owned = false;
11500 LDKCVec_u64Z val_constr;
11501 val_constr.datalen = *((uint32_t*)val);
11502 if (val_constr.datalen > 0)
11503 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11505 val_constr.data = NULL;
11506 int64_t* val_vals = (int64_t*)(val + 4);
11507 for (size_t i = 0; i < val_constr.datalen; i++) {
11508 int64_t arr_conv_8 = val_vals[i];
11509 val_constr.data[i] = arr_conv_8;
11511 QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
11514 uint32_t __attribute__((visibility("default"))) TS_QueryShortChannelIds_new(int8_tArray chain_hash_arg, int64_tArray short_channel_ids_arg) {
11515 LDKThirtyTwoBytes chain_hash_arg_ref;
11516 CHECK(*((uint32_t*)chain_hash_arg) == 32);
11517 memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11518 LDKCVec_u64Z short_channel_ids_arg_constr;
11519 short_channel_ids_arg_constr.datalen = *((uint32_t*)short_channel_ids_arg);
11520 if (short_channel_ids_arg_constr.datalen > 0)
11521 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
11523 short_channel_ids_arg_constr.data = NULL;
11524 int64_t* short_channel_ids_arg_vals = (int64_t*)(short_channel_ids_arg + 4);
11525 for (size_t i = 0; i < short_channel_ids_arg_constr.datalen; i++) {
11526 int64_t arr_conv_8 = short_channel_ids_arg_vals[i];
11527 short_channel_ids_arg_constr.data[i] = arr_conv_8;
11529 LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
11530 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11531 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11532 long ret_ref = (long)ret_var.inner;
11533 if (ret_var.is_owned) {
11539 void __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_free(uint32_t this_ptr) {
11540 LDKReplyShortChannelIdsEnd this_ptr_conv;
11541 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11542 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11543 ReplyShortChannelIdsEnd_free(this_ptr_conv);
11546 uint32_t __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_clone(uint32_t orig) {
11547 LDKReplyShortChannelIdsEnd orig_conv;
11548 orig_conv.inner = (void*)(orig & (~1));
11549 orig_conv.is_owned = false;
11550 LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
11551 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11552 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11553 long ret_ref = (long)ret_var.inner;
11554 if (ret_var.is_owned) {
11560 int8_tArray __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_chain_hash(uint32_t this_ptr) {
11561 LDKReplyShortChannelIdsEnd this_ptr_conv;
11562 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11563 this_ptr_conv.is_owned = false;
11564 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11565 memcpy((uint8_t*)(ret_arr + 4), *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv), 32);
11569 void __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11570 LDKReplyShortChannelIdsEnd this_ptr_conv;
11571 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11572 this_ptr_conv.is_owned = false;
11573 LDKThirtyTwoBytes val_ref;
11574 CHECK(*((uint32_t*)val) == 32);
11575 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11576 ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
11579 jboolean __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_get_full_information(uint32_t this_ptr) {
11580 LDKReplyShortChannelIdsEnd this_ptr_conv;
11581 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11582 this_ptr_conv.is_owned = false;
11583 jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
11587 void __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_set_full_information(uint32_t this_ptr, jboolean val) {
11588 LDKReplyShortChannelIdsEnd this_ptr_conv;
11589 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11590 this_ptr_conv.is_owned = false;
11591 ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
11594 uint32_t __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_new(int8_tArray chain_hash_arg, jboolean full_information_arg) {
11595 LDKThirtyTwoBytes chain_hash_arg_ref;
11596 CHECK(*((uint32_t*)chain_hash_arg) == 32);
11597 memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11598 LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
11599 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11600 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11601 long ret_ref = (long)ret_var.inner;
11602 if (ret_var.is_owned) {
11608 void __attribute__((visibility("default"))) TS_GossipTimestampFilter_free(uint32_t this_ptr) {
11609 LDKGossipTimestampFilter this_ptr_conv;
11610 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11611 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11612 GossipTimestampFilter_free(this_ptr_conv);
11615 uint32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_clone(uint32_t orig) {
11616 LDKGossipTimestampFilter orig_conv;
11617 orig_conv.inner = (void*)(orig & (~1));
11618 orig_conv.is_owned = false;
11619 LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
11620 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11621 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11622 long ret_ref = (long)ret_var.inner;
11623 if (ret_var.is_owned) {
11629 int8_tArray __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_chain_hash(uint32_t this_ptr) {
11630 LDKGossipTimestampFilter this_ptr_conv;
11631 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11632 this_ptr_conv.is_owned = false;
11633 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
11634 memcpy((uint8_t*)(ret_arr + 4), *GossipTimestampFilter_get_chain_hash(&this_ptr_conv), 32);
11638 void __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_chain_hash(uint32_t this_ptr, int8_tArray val) {
11639 LDKGossipTimestampFilter this_ptr_conv;
11640 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11641 this_ptr_conv.is_owned = false;
11642 LDKThirtyTwoBytes val_ref;
11643 CHECK(*((uint32_t*)val) == 32);
11644 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
11645 GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
11648 int32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_first_timestamp(uint32_t this_ptr) {
11649 LDKGossipTimestampFilter this_ptr_conv;
11650 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11651 this_ptr_conv.is_owned = false;
11652 int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
11656 void __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_first_timestamp(uint32_t this_ptr, int32_t val) {
11657 LDKGossipTimestampFilter this_ptr_conv;
11658 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11659 this_ptr_conv.is_owned = false;
11660 GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
11663 int32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_get_timestamp_range(uint32_t this_ptr) {
11664 LDKGossipTimestampFilter this_ptr_conv;
11665 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11666 this_ptr_conv.is_owned = false;
11667 int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
11671 void __attribute__((visibility("default"))) TS_GossipTimestampFilter_set_timestamp_range(uint32_t this_ptr, int32_t val) {
11672 LDKGossipTimestampFilter this_ptr_conv;
11673 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11674 this_ptr_conv.is_owned = false;
11675 GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
11678 uint32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_new(int8_tArray chain_hash_arg, int32_t first_timestamp_arg, int32_t timestamp_range_arg) {
11679 LDKThirtyTwoBytes chain_hash_arg_ref;
11680 CHECK(*((uint32_t*)chain_hash_arg) == 32);
11681 memcpy(chain_hash_arg_ref.data, (uint8_t*)(chain_hash_arg + 4), 32);
11682 LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
11683 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11684 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11685 long ret_ref = (long)ret_var.inner;
11686 if (ret_var.is_owned) {
11692 void __attribute__((visibility("default"))) TS_ErrorAction_free(uint32_t this_ptr) {
11693 LDKErrorAction this_ptr_conv = *(LDKErrorAction*)this_ptr;
11694 FREE((void*)this_ptr);
11695 ErrorAction_free(this_ptr_conv);
11698 uint32_t __attribute__((visibility("default"))) TS_ErrorAction_clone(uint32_t orig) {
11699 LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
11700 LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
11701 *ret_copy = ErrorAction_clone(orig_conv);
11702 long ret_ref = (long)ret_copy;
11706 void __attribute__((visibility("default"))) TS_LightningError_free(uint32_t this_ptr) {
11707 LDKLightningError this_ptr_conv;
11708 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11709 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11710 LightningError_free(this_ptr_conv);
11713 jstring __attribute__((visibility("default"))) TS_LightningError_get_err(uint32_t this_ptr) {
11714 LDKLightningError this_ptr_conv;
11715 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11716 this_ptr_conv.is_owned = false;
11717 LDKStr _str = LightningError_get_err(&this_ptr_conv);
11718 jstring _conv = str_ref_to_ts(_str.chars, _str.len);
11722 void __attribute__((visibility("default"))) TS_LightningError_set_err(uint32_t this_ptr, int8_tArray val) {
11723 LDKLightningError this_ptr_conv;
11724 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11725 this_ptr_conv.is_owned = false;
11726 LDKCVec_u8Z val_ref;
11727 val_ref.datalen = *((uint32_t*)val);
11728 val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
11729 memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
11730 LightningError_set_err(&this_ptr_conv, val_ref);
11733 uint32_t __attribute__((visibility("default"))) TS_LightningError_get_action(uint32_t this_ptr) {
11734 LDKLightningError this_ptr_conv;
11735 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11736 this_ptr_conv.is_owned = false;
11737 LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
11738 *ret_copy = LightningError_get_action(&this_ptr_conv);
11739 long ret_ref = (long)ret_copy;
11743 void __attribute__((visibility("default"))) TS_LightningError_set_action(uint32_t this_ptr, uint32_t val) {
11744 LDKLightningError this_ptr_conv;
11745 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11746 this_ptr_conv.is_owned = false;
11747 LDKErrorAction val_conv = *(LDKErrorAction*)val;
11749 LightningError_set_action(&this_ptr_conv, val_conv);
11752 uint32_t __attribute__((visibility("default"))) TS_LightningError_new(int8_tArray err_arg, uint32_t action_arg) {
11753 LDKCVec_u8Z err_arg_ref;
11754 err_arg_ref.datalen = *((uint32_t*)err_arg);
11755 err_arg_ref.data = MALLOC(err_arg_ref.datalen, "LDKCVec_u8Z Bytes");
11756 memcpy(err_arg_ref.data, (uint8_t*)(err_arg + 4), err_arg_ref.datalen);
11757 LDKErrorAction action_arg_conv = *(LDKErrorAction*)action_arg;
11758 FREE((void*)action_arg);
11759 LDKLightningError ret_var = LightningError_new(err_arg_ref, action_arg_conv);
11760 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11761 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11762 long ret_ref = (long)ret_var.inner;
11763 if (ret_var.is_owned) {
11769 void __attribute__((visibility("default"))) TS_CommitmentUpdate_free(uint32_t this_ptr) {
11770 LDKCommitmentUpdate this_ptr_conv;
11771 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11772 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
11773 CommitmentUpdate_free(this_ptr_conv);
11776 uint32_t __attribute__((visibility("default"))) TS_CommitmentUpdate_clone(uint32_t orig) {
11777 LDKCommitmentUpdate orig_conv;
11778 orig_conv.inner = (void*)(orig & (~1));
11779 orig_conv.is_owned = false;
11780 LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
11781 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11782 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11783 long ret_ref = (long)ret_var.inner;
11784 if (ret_var.is_owned) {
11790 void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_add_htlcs(uint32_t this_ptr, uint32_tArray val) {
11791 LDKCommitmentUpdate this_ptr_conv;
11792 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11793 this_ptr_conv.is_owned = false;
11794 LDKCVec_UpdateAddHTLCZ val_constr;
11795 val_constr.datalen = *((uint32_t*)val);
11796 if (val_constr.datalen > 0)
11797 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11799 val_constr.data = NULL;
11800 uint32_t* val_vals = (uint32_t*)(val + 4);
11801 for (size_t p = 0; p < val_constr.datalen; p++) {
11802 uint32_t arr_conv_15 = val_vals[p];
11803 LDKUpdateAddHTLC arr_conv_15_conv;
11804 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
11805 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
11806 if (arr_conv_15_conv.inner != NULL)
11807 arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
11808 val_constr.data[p] = arr_conv_15_conv;
11810 CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
11813 void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fulfill_htlcs(uint32_t this_ptr, uint32_tArray val) {
11814 LDKCommitmentUpdate this_ptr_conv;
11815 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11816 this_ptr_conv.is_owned = false;
11817 LDKCVec_UpdateFulfillHTLCZ val_constr;
11818 val_constr.datalen = *((uint32_t*)val);
11819 if (val_constr.datalen > 0)
11820 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11822 val_constr.data = NULL;
11823 uint32_t* val_vals = (uint32_t*)(val + 4);
11824 for (size_t t = 0; t < val_constr.datalen; t++) {
11825 uint32_t arr_conv_19 = val_vals[t];
11826 LDKUpdateFulfillHTLC arr_conv_19_conv;
11827 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
11828 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
11829 if (arr_conv_19_conv.inner != NULL)
11830 arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
11831 val_constr.data[t] = arr_conv_19_conv;
11833 CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
11836 void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_htlcs(uint32_t this_ptr, uint32_tArray val) {
11837 LDKCommitmentUpdate this_ptr_conv;
11838 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11839 this_ptr_conv.is_owned = false;
11840 LDKCVec_UpdateFailHTLCZ val_constr;
11841 val_constr.datalen = *((uint32_t*)val);
11842 if (val_constr.datalen > 0)
11843 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11845 val_constr.data = NULL;
11846 uint32_t* val_vals = (uint32_t*)(val + 4);
11847 for (size_t q = 0; q < val_constr.datalen; q++) {
11848 uint32_t arr_conv_16 = val_vals[q];
11849 LDKUpdateFailHTLC arr_conv_16_conv;
11850 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
11851 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
11852 if (arr_conv_16_conv.inner != NULL)
11853 arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
11854 val_constr.data[q] = arr_conv_16_conv;
11856 CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
11859 void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fail_malformed_htlcs(uint32_t this_ptr, uint32_tArray val) {
11860 LDKCommitmentUpdate this_ptr_conv;
11861 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11862 this_ptr_conv.is_owned = false;
11863 LDKCVec_UpdateFailMalformedHTLCZ val_constr;
11864 val_constr.datalen = *((uint32_t*)val);
11865 if (val_constr.datalen > 0)
11866 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11868 val_constr.data = NULL;
11869 uint32_t* val_vals = (uint32_t*)(val + 4);
11870 for (size_t z = 0; z < val_constr.datalen; z++) {
11871 uint32_t arr_conv_25 = val_vals[z];
11872 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
11873 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
11874 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
11875 if (arr_conv_25_conv.inner != NULL)
11876 arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
11877 val_constr.data[z] = arr_conv_25_conv;
11879 CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
11882 uint32_t __attribute__((visibility("default"))) TS_CommitmentUpdate_get_update_fee(uint32_t this_ptr) {
11883 LDKCommitmentUpdate this_ptr_conv;
11884 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11885 this_ptr_conv.is_owned = false;
11886 LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
11887 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11888 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11889 long ret_ref = (long)ret_var.inner;
11890 if (ret_var.is_owned) {
11896 void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_update_fee(uint32_t this_ptr, uint32_t val) {
11897 LDKCommitmentUpdate this_ptr_conv;
11898 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11899 this_ptr_conv.is_owned = false;
11900 LDKUpdateFee val_conv;
11901 val_conv.inner = (void*)(val & (~1));
11902 val_conv.is_owned = (val & 1) || (val == 0);
11903 if (val_conv.inner != NULL)
11904 val_conv = UpdateFee_clone(&val_conv);
11905 CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
11908 uint32_t __attribute__((visibility("default"))) TS_CommitmentUpdate_get_commitment_signed(uint32_t this_ptr) {
11909 LDKCommitmentUpdate this_ptr_conv;
11910 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11911 this_ptr_conv.is_owned = false;
11912 LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
11913 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
11914 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
11915 long ret_ref = (long)ret_var.inner;
11916 if (ret_var.is_owned) {
11922 void __attribute__((visibility("default"))) TS_CommitmentUpdate_set_commitment_signed(uint32_t this_ptr, uint32_t val) {
11923 LDKCommitmentUpdate this_ptr_conv;
11924 this_ptr_conv.inner = (void*)(this_ptr & (~1));
11925 this_ptr_conv.is_owned = false;
11926 LDKCommitmentSigned val_conv;
11927 val_conv.inner = (void*)(val & (~1));
11928 val_conv.is_owned = (val & 1) || (val == 0);
11929 if (val_conv.inner != NULL)
11930 val_conv = CommitmentSigned_clone(&val_conv);
11931 CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
11934 uint32_t __attribute__((visibility("default"))) TS_CommitmentUpdate_new(uint32_tArray update_add_htlcs_arg, uint32_tArray update_fulfill_htlcs_arg, uint32_tArray update_fail_htlcs_arg, uint32_tArray update_fail_malformed_htlcs_arg, uint32_t update_fee_arg, uint32_t commitment_signed_arg) {
11935 LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
11936 update_add_htlcs_arg_constr.datalen = *((uint32_t*)update_add_htlcs_arg);
11937 if (update_add_htlcs_arg_constr.datalen > 0)
11938 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
11940 update_add_htlcs_arg_constr.data = NULL;
11941 uint32_t* update_add_htlcs_arg_vals = (uint32_t*)(update_add_htlcs_arg + 4);
11942 for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
11943 uint32_t arr_conv_15 = update_add_htlcs_arg_vals[p];
11944 LDKUpdateAddHTLC arr_conv_15_conv;
11945 arr_conv_15_conv.inner = (void*)(arr_conv_15 & (~1));
11946 arr_conv_15_conv.is_owned = (arr_conv_15 & 1) || (arr_conv_15 == 0);
11947 if (arr_conv_15_conv.inner != NULL)
11948 arr_conv_15_conv = UpdateAddHTLC_clone(&arr_conv_15_conv);
11949 update_add_htlcs_arg_constr.data[p] = arr_conv_15_conv;
11951 LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
11952 update_fulfill_htlcs_arg_constr.datalen = *((uint32_t*)update_fulfill_htlcs_arg);
11953 if (update_fulfill_htlcs_arg_constr.datalen > 0)
11954 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
11956 update_fulfill_htlcs_arg_constr.data = NULL;
11957 uint32_t* update_fulfill_htlcs_arg_vals = (uint32_t*)(update_fulfill_htlcs_arg + 4);
11958 for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
11959 uint32_t arr_conv_19 = update_fulfill_htlcs_arg_vals[t];
11960 LDKUpdateFulfillHTLC arr_conv_19_conv;
11961 arr_conv_19_conv.inner = (void*)(arr_conv_19 & (~1));
11962 arr_conv_19_conv.is_owned = (arr_conv_19 & 1) || (arr_conv_19 == 0);
11963 if (arr_conv_19_conv.inner != NULL)
11964 arr_conv_19_conv = UpdateFulfillHTLC_clone(&arr_conv_19_conv);
11965 update_fulfill_htlcs_arg_constr.data[t] = arr_conv_19_conv;
11967 LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
11968 update_fail_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_htlcs_arg);
11969 if (update_fail_htlcs_arg_constr.datalen > 0)
11970 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
11972 update_fail_htlcs_arg_constr.data = NULL;
11973 uint32_t* update_fail_htlcs_arg_vals = (uint32_t*)(update_fail_htlcs_arg + 4);
11974 for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
11975 uint32_t arr_conv_16 = update_fail_htlcs_arg_vals[q];
11976 LDKUpdateFailHTLC arr_conv_16_conv;
11977 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
11978 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
11979 if (arr_conv_16_conv.inner != NULL)
11980 arr_conv_16_conv = UpdateFailHTLC_clone(&arr_conv_16_conv);
11981 update_fail_htlcs_arg_constr.data[q] = arr_conv_16_conv;
11983 LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
11984 update_fail_malformed_htlcs_arg_constr.datalen = *((uint32_t*)update_fail_malformed_htlcs_arg);
11985 if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
11986 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
11988 update_fail_malformed_htlcs_arg_constr.data = NULL;
11989 uint32_t* update_fail_malformed_htlcs_arg_vals = (uint32_t*)(update_fail_malformed_htlcs_arg + 4);
11990 for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
11991 uint32_t arr_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
11992 LDKUpdateFailMalformedHTLC arr_conv_25_conv;
11993 arr_conv_25_conv.inner = (void*)(arr_conv_25 & (~1));
11994 arr_conv_25_conv.is_owned = (arr_conv_25 & 1) || (arr_conv_25 == 0);
11995 if (arr_conv_25_conv.inner != NULL)
11996 arr_conv_25_conv = UpdateFailMalformedHTLC_clone(&arr_conv_25_conv);
11997 update_fail_malformed_htlcs_arg_constr.data[z] = arr_conv_25_conv;
11999 LDKUpdateFee update_fee_arg_conv;
12000 update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
12001 update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
12002 if (update_fee_arg_conv.inner != NULL)
12003 update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
12004 LDKCommitmentSigned commitment_signed_arg_conv;
12005 commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
12006 commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
12007 if (commitment_signed_arg_conv.inner != NULL)
12008 commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
12009 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);
12010 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12011 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12012 long ret_ref = (long)ret_var.inner;
12013 if (ret_var.is_owned) {
12019 void __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_free(uint32_t this_ptr) {
12020 LDKHTLCFailChannelUpdate this_ptr_conv = *(LDKHTLCFailChannelUpdate*)this_ptr;
12021 FREE((void*)this_ptr);
12022 HTLCFailChannelUpdate_free(this_ptr_conv);
12025 uint32_t __attribute__((visibility("default"))) TS_HTLCFailChannelUpdate_clone(uint32_t orig) {
12026 LDKHTLCFailChannelUpdate* orig_conv = (LDKHTLCFailChannelUpdate*)orig;
12027 LDKHTLCFailChannelUpdate *ret_copy = MALLOC(sizeof(LDKHTLCFailChannelUpdate), "LDKHTLCFailChannelUpdate");
12028 *ret_copy = HTLCFailChannelUpdate_clone(orig_conv);
12029 long ret_ref = (long)ret_copy;
12033 void __attribute__((visibility("default"))) TS_ChannelMessageHandler_free(uint32_t this_ptr) {
12034 LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)this_ptr;
12035 FREE((void*)this_ptr);
12036 ChannelMessageHandler_free(this_ptr_conv);
12039 void __attribute__((visibility("default"))) TS_RoutingMessageHandler_free(uint32_t this_ptr) {
12040 LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)this_ptr;
12041 FREE((void*)this_ptr);
12042 RoutingMessageHandler_free(this_ptr_conv);
12045 int8_tArray __attribute__((visibility("default"))) TS_AcceptChannel_write(uint32_t obj) {
12046 LDKAcceptChannel obj_conv;
12047 obj_conv.inner = (void*)(obj & (~1));
12048 obj_conv.is_owned = false;
12049 LDKCVec_u8Z arg_var = AcceptChannel_write(&obj_conv);
12050 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12051 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12052 CVec_u8Z_free(arg_var);
12056 uint32_t __attribute__((visibility("default"))) TS_AcceptChannel_read(int8_tArray ser) {
12057 LDKu8slice ser_ref;
12058 ser_ref.datalen = *((uint32_t*)ser);
12059 ser_ref.data = (int8_t*)(ser + 4);
12060 LDKAcceptChannel ret_var = AcceptChannel_read(ser_ref);
12061 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12062 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12063 long ret_ref = (long)ret_var.inner;
12064 if (ret_var.is_owned) {
12070 int8_tArray __attribute__((visibility("default"))) TS_AnnouncementSignatures_write(uint32_t obj) {
12071 LDKAnnouncementSignatures obj_conv;
12072 obj_conv.inner = (void*)(obj & (~1));
12073 obj_conv.is_owned = false;
12074 LDKCVec_u8Z arg_var = AnnouncementSignatures_write(&obj_conv);
12075 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12076 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12077 CVec_u8Z_free(arg_var);
12081 uint32_t __attribute__((visibility("default"))) TS_AnnouncementSignatures_read(int8_tArray ser) {
12082 LDKu8slice ser_ref;
12083 ser_ref.datalen = *((uint32_t*)ser);
12084 ser_ref.data = (int8_t*)(ser + 4);
12085 LDKAnnouncementSignatures ret_var = AnnouncementSignatures_read(ser_ref);
12086 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12087 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12088 long ret_ref = (long)ret_var.inner;
12089 if (ret_var.is_owned) {
12095 int8_tArray __attribute__((visibility("default"))) TS_ChannelReestablish_write(uint32_t obj) {
12096 LDKChannelReestablish obj_conv;
12097 obj_conv.inner = (void*)(obj & (~1));
12098 obj_conv.is_owned = false;
12099 LDKCVec_u8Z arg_var = ChannelReestablish_write(&obj_conv);
12100 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12101 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12102 CVec_u8Z_free(arg_var);
12106 uint32_t __attribute__((visibility("default"))) TS_ChannelReestablish_read(int8_tArray ser) {
12107 LDKu8slice ser_ref;
12108 ser_ref.datalen = *((uint32_t*)ser);
12109 ser_ref.data = (int8_t*)(ser + 4);
12110 LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
12111 *ret_conv = ChannelReestablish_read(ser_ref);
12112 return (long)ret_conv;
12115 int8_tArray __attribute__((visibility("default"))) TS_ClosingSigned_write(uint32_t obj) {
12116 LDKClosingSigned obj_conv;
12117 obj_conv.inner = (void*)(obj & (~1));
12118 obj_conv.is_owned = false;
12119 LDKCVec_u8Z arg_var = ClosingSigned_write(&obj_conv);
12120 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12121 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12122 CVec_u8Z_free(arg_var);
12126 uint32_t __attribute__((visibility("default"))) TS_ClosingSigned_read(int8_tArray ser) {
12127 LDKu8slice ser_ref;
12128 ser_ref.datalen = *((uint32_t*)ser);
12129 ser_ref.data = (int8_t*)(ser + 4);
12130 LDKClosingSigned ret_var = ClosingSigned_read(ser_ref);
12131 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12132 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12133 long ret_ref = (long)ret_var.inner;
12134 if (ret_var.is_owned) {
12140 int8_tArray __attribute__((visibility("default"))) TS_CommitmentSigned_write(uint32_t obj) {
12141 LDKCommitmentSigned obj_conv;
12142 obj_conv.inner = (void*)(obj & (~1));
12143 obj_conv.is_owned = false;
12144 LDKCVec_u8Z arg_var = CommitmentSigned_write(&obj_conv);
12145 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12146 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12147 CVec_u8Z_free(arg_var);
12151 uint32_t __attribute__((visibility("default"))) TS_CommitmentSigned_read(int8_tArray ser) {
12152 LDKu8slice ser_ref;
12153 ser_ref.datalen = *((uint32_t*)ser);
12154 ser_ref.data = (int8_t*)(ser + 4);
12155 LDKCommitmentSigned ret_var = CommitmentSigned_read(ser_ref);
12156 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12157 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12158 long ret_ref = (long)ret_var.inner;
12159 if (ret_var.is_owned) {
12165 int8_tArray __attribute__((visibility("default"))) TS_FundingCreated_write(uint32_t obj) {
12166 LDKFundingCreated obj_conv;
12167 obj_conv.inner = (void*)(obj & (~1));
12168 obj_conv.is_owned = false;
12169 LDKCVec_u8Z arg_var = FundingCreated_write(&obj_conv);
12170 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12171 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12172 CVec_u8Z_free(arg_var);
12176 uint32_t __attribute__((visibility("default"))) TS_FundingCreated_read(int8_tArray ser) {
12177 LDKu8slice ser_ref;
12178 ser_ref.datalen = *((uint32_t*)ser);
12179 ser_ref.data = (int8_t*)(ser + 4);
12180 LDKFundingCreated ret_var = FundingCreated_read(ser_ref);
12181 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12182 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12183 long ret_ref = (long)ret_var.inner;
12184 if (ret_var.is_owned) {
12190 int8_tArray __attribute__((visibility("default"))) TS_FundingSigned_write(uint32_t obj) {
12191 LDKFundingSigned obj_conv;
12192 obj_conv.inner = (void*)(obj & (~1));
12193 obj_conv.is_owned = false;
12194 LDKCVec_u8Z arg_var = FundingSigned_write(&obj_conv);
12195 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12196 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12197 CVec_u8Z_free(arg_var);
12201 uint32_t __attribute__((visibility("default"))) TS_FundingSigned_read(int8_tArray ser) {
12202 LDKu8slice ser_ref;
12203 ser_ref.datalen = *((uint32_t*)ser);
12204 ser_ref.data = (int8_t*)(ser + 4);
12205 LDKFundingSigned ret_var = FundingSigned_read(ser_ref);
12206 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12207 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12208 long ret_ref = (long)ret_var.inner;
12209 if (ret_var.is_owned) {
12215 int8_tArray __attribute__((visibility("default"))) TS_FundingLocked_write(uint32_t obj) {
12216 LDKFundingLocked obj_conv;
12217 obj_conv.inner = (void*)(obj & (~1));
12218 obj_conv.is_owned = false;
12219 LDKCVec_u8Z arg_var = FundingLocked_write(&obj_conv);
12220 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12221 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12222 CVec_u8Z_free(arg_var);
12226 uint32_t __attribute__((visibility("default"))) TS_FundingLocked_read(int8_tArray ser) {
12227 LDKu8slice ser_ref;
12228 ser_ref.datalen = *((uint32_t*)ser);
12229 ser_ref.data = (int8_t*)(ser + 4);
12230 LDKFundingLocked ret_var = FundingLocked_read(ser_ref);
12231 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12232 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12233 long ret_ref = (long)ret_var.inner;
12234 if (ret_var.is_owned) {
12240 int8_tArray __attribute__((visibility("default"))) TS_Init_write(uint32_t obj) {
12242 obj_conv.inner = (void*)(obj & (~1));
12243 obj_conv.is_owned = false;
12244 LDKCVec_u8Z arg_var = Init_write(&obj_conv);
12245 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12246 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12247 CVec_u8Z_free(arg_var);
12251 uint32_t __attribute__((visibility("default"))) TS_Init_read(int8_tArray ser) {
12252 LDKu8slice ser_ref;
12253 ser_ref.datalen = *((uint32_t*)ser);
12254 ser_ref.data = (int8_t*)(ser + 4);
12255 LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
12256 *ret_conv = Init_read(ser_ref);
12257 return (long)ret_conv;
12260 int8_tArray __attribute__((visibility("default"))) TS_OpenChannel_write(uint32_t obj) {
12261 LDKOpenChannel obj_conv;
12262 obj_conv.inner = (void*)(obj & (~1));
12263 obj_conv.is_owned = false;
12264 LDKCVec_u8Z arg_var = OpenChannel_write(&obj_conv);
12265 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12266 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12267 CVec_u8Z_free(arg_var);
12271 uint32_t __attribute__((visibility("default"))) TS_OpenChannel_read(int8_tArray ser) {
12272 LDKu8slice ser_ref;
12273 ser_ref.datalen = *((uint32_t*)ser);
12274 ser_ref.data = (int8_t*)(ser + 4);
12275 LDKOpenChannel ret_var = OpenChannel_read(ser_ref);
12276 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12277 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12278 long ret_ref = (long)ret_var.inner;
12279 if (ret_var.is_owned) {
12285 int8_tArray __attribute__((visibility("default"))) TS_RevokeAndACK_write(uint32_t obj) {
12286 LDKRevokeAndACK obj_conv;
12287 obj_conv.inner = (void*)(obj & (~1));
12288 obj_conv.is_owned = false;
12289 LDKCVec_u8Z arg_var = RevokeAndACK_write(&obj_conv);
12290 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12291 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12292 CVec_u8Z_free(arg_var);
12296 uint32_t __attribute__((visibility("default"))) TS_RevokeAndACK_read(int8_tArray ser) {
12297 LDKu8slice ser_ref;
12298 ser_ref.datalen = *((uint32_t*)ser);
12299 ser_ref.data = (int8_t*)(ser + 4);
12300 LDKRevokeAndACK ret_var = RevokeAndACK_read(ser_ref);
12301 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12302 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12303 long ret_ref = (long)ret_var.inner;
12304 if (ret_var.is_owned) {
12310 int8_tArray __attribute__((visibility("default"))) TS_Shutdown_write(uint32_t obj) {
12311 LDKShutdown obj_conv;
12312 obj_conv.inner = (void*)(obj & (~1));
12313 obj_conv.is_owned = false;
12314 LDKCVec_u8Z arg_var = Shutdown_write(&obj_conv);
12315 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12316 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12317 CVec_u8Z_free(arg_var);
12321 uint32_t __attribute__((visibility("default"))) TS_Shutdown_read(int8_tArray ser) {
12322 LDKu8slice ser_ref;
12323 ser_ref.datalen = *((uint32_t*)ser);
12324 ser_ref.data = (int8_t*)(ser + 4);
12325 LDKShutdown ret_var = Shutdown_read(ser_ref);
12326 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12327 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12328 long ret_ref = (long)ret_var.inner;
12329 if (ret_var.is_owned) {
12335 int8_tArray __attribute__((visibility("default"))) TS_UpdateFailHTLC_write(uint32_t obj) {
12336 LDKUpdateFailHTLC obj_conv;
12337 obj_conv.inner = (void*)(obj & (~1));
12338 obj_conv.is_owned = false;
12339 LDKCVec_u8Z arg_var = UpdateFailHTLC_write(&obj_conv);
12340 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12341 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12342 CVec_u8Z_free(arg_var);
12346 uint32_t __attribute__((visibility("default"))) TS_UpdateFailHTLC_read(int8_tArray ser) {
12347 LDKu8slice ser_ref;
12348 ser_ref.datalen = *((uint32_t*)ser);
12349 ser_ref.data = (int8_t*)(ser + 4);
12350 LDKUpdateFailHTLC ret_var = UpdateFailHTLC_read(ser_ref);
12351 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12352 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12353 long ret_ref = (long)ret_var.inner;
12354 if (ret_var.is_owned) {
12360 int8_tArray __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_write(uint32_t obj) {
12361 LDKUpdateFailMalformedHTLC obj_conv;
12362 obj_conv.inner = (void*)(obj & (~1));
12363 obj_conv.is_owned = false;
12364 LDKCVec_u8Z arg_var = UpdateFailMalformedHTLC_write(&obj_conv);
12365 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12366 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12367 CVec_u8Z_free(arg_var);
12371 uint32_t __attribute__((visibility("default"))) TS_UpdateFailMalformedHTLC_read(int8_tArray ser) {
12372 LDKu8slice ser_ref;
12373 ser_ref.datalen = *((uint32_t*)ser);
12374 ser_ref.data = (int8_t*)(ser + 4);
12375 LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_read(ser_ref);
12376 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12377 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12378 long ret_ref = (long)ret_var.inner;
12379 if (ret_var.is_owned) {
12385 int8_tArray __attribute__((visibility("default"))) TS_UpdateFee_write(uint32_t obj) {
12386 LDKUpdateFee obj_conv;
12387 obj_conv.inner = (void*)(obj & (~1));
12388 obj_conv.is_owned = false;
12389 LDKCVec_u8Z arg_var = UpdateFee_write(&obj_conv);
12390 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12391 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12392 CVec_u8Z_free(arg_var);
12396 uint32_t __attribute__((visibility("default"))) TS_UpdateFee_read(int8_tArray ser) {
12397 LDKu8slice ser_ref;
12398 ser_ref.datalen = *((uint32_t*)ser);
12399 ser_ref.data = (int8_t*)(ser + 4);
12400 LDKUpdateFee ret_var = UpdateFee_read(ser_ref);
12401 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12402 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12403 long ret_ref = (long)ret_var.inner;
12404 if (ret_var.is_owned) {
12410 int8_tArray __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_write(uint32_t obj) {
12411 LDKUpdateFulfillHTLC obj_conv;
12412 obj_conv.inner = (void*)(obj & (~1));
12413 obj_conv.is_owned = false;
12414 LDKCVec_u8Z arg_var = UpdateFulfillHTLC_write(&obj_conv);
12415 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12416 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12417 CVec_u8Z_free(arg_var);
12421 uint32_t __attribute__((visibility("default"))) TS_UpdateFulfillHTLC_read(int8_tArray ser) {
12422 LDKu8slice ser_ref;
12423 ser_ref.datalen = *((uint32_t*)ser);
12424 ser_ref.data = (int8_t*)(ser + 4);
12425 LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_read(ser_ref);
12426 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12427 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12428 long ret_ref = (long)ret_var.inner;
12429 if (ret_var.is_owned) {
12435 int8_tArray __attribute__((visibility("default"))) TS_UpdateAddHTLC_write(uint32_t obj) {
12436 LDKUpdateAddHTLC obj_conv;
12437 obj_conv.inner = (void*)(obj & (~1));
12438 obj_conv.is_owned = false;
12439 LDKCVec_u8Z arg_var = UpdateAddHTLC_write(&obj_conv);
12440 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12441 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12442 CVec_u8Z_free(arg_var);
12446 uint32_t __attribute__((visibility("default"))) TS_UpdateAddHTLC_read(int8_tArray ser) {
12447 LDKu8slice ser_ref;
12448 ser_ref.datalen = *((uint32_t*)ser);
12449 ser_ref.data = (int8_t*)(ser + 4);
12450 LDKUpdateAddHTLC ret_var = UpdateAddHTLC_read(ser_ref);
12451 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12452 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12453 long ret_ref = (long)ret_var.inner;
12454 if (ret_var.is_owned) {
12460 int8_tArray __attribute__((visibility("default"))) TS_Ping_write(uint32_t obj) {
12462 obj_conv.inner = (void*)(obj & (~1));
12463 obj_conv.is_owned = false;
12464 LDKCVec_u8Z arg_var = Ping_write(&obj_conv);
12465 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12466 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12467 CVec_u8Z_free(arg_var);
12471 uint32_t __attribute__((visibility("default"))) TS_Ping_read(int8_tArray ser) {
12472 LDKu8slice ser_ref;
12473 ser_ref.datalen = *((uint32_t*)ser);
12474 ser_ref.data = (int8_t*)(ser + 4);
12475 LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
12476 *ret_conv = Ping_read(ser_ref);
12477 return (long)ret_conv;
12480 int8_tArray __attribute__((visibility("default"))) TS_Pong_write(uint32_t obj) {
12482 obj_conv.inner = (void*)(obj & (~1));
12483 obj_conv.is_owned = false;
12484 LDKCVec_u8Z arg_var = Pong_write(&obj_conv);
12485 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12486 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12487 CVec_u8Z_free(arg_var);
12491 uint32_t __attribute__((visibility("default"))) TS_Pong_read(int8_tArray ser) {
12492 LDKu8slice ser_ref;
12493 ser_ref.datalen = *((uint32_t*)ser);
12494 ser_ref.data = (int8_t*)(ser + 4);
12495 LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
12496 *ret_conv = Pong_read(ser_ref);
12497 return (long)ret_conv;
12500 int8_tArray __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_write(uint32_t obj) {
12501 LDKUnsignedChannelAnnouncement obj_conv;
12502 obj_conv.inner = (void*)(obj & (~1));
12503 obj_conv.is_owned = false;
12504 LDKCVec_u8Z arg_var = UnsignedChannelAnnouncement_write(&obj_conv);
12505 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12506 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12507 CVec_u8Z_free(arg_var);
12511 uint32_t __attribute__((visibility("default"))) TS_UnsignedChannelAnnouncement_read(int8_tArray ser) {
12512 LDKu8slice ser_ref;
12513 ser_ref.datalen = *((uint32_t*)ser);
12514 ser_ref.data = (int8_t*)(ser + 4);
12515 LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
12516 *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
12517 return (long)ret_conv;
12520 int8_tArray __attribute__((visibility("default"))) TS_ChannelAnnouncement_write(uint32_t obj) {
12521 LDKChannelAnnouncement obj_conv;
12522 obj_conv.inner = (void*)(obj & (~1));
12523 obj_conv.is_owned = false;
12524 LDKCVec_u8Z arg_var = ChannelAnnouncement_write(&obj_conv);
12525 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12526 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12527 CVec_u8Z_free(arg_var);
12531 uint32_t __attribute__((visibility("default"))) TS_ChannelAnnouncement_read(int8_tArray ser) {
12532 LDKu8slice ser_ref;
12533 ser_ref.datalen = *((uint32_t*)ser);
12534 ser_ref.data = (int8_t*)(ser + 4);
12535 LDKChannelAnnouncement ret_var = ChannelAnnouncement_read(ser_ref);
12536 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12537 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12538 long ret_ref = (long)ret_var.inner;
12539 if (ret_var.is_owned) {
12545 int8_tArray __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_write(uint32_t obj) {
12546 LDKUnsignedChannelUpdate obj_conv;
12547 obj_conv.inner = (void*)(obj & (~1));
12548 obj_conv.is_owned = false;
12549 LDKCVec_u8Z arg_var = UnsignedChannelUpdate_write(&obj_conv);
12550 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12551 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12552 CVec_u8Z_free(arg_var);
12556 uint32_t __attribute__((visibility("default"))) TS_UnsignedChannelUpdate_read(int8_tArray ser) {
12557 LDKu8slice ser_ref;
12558 ser_ref.datalen = *((uint32_t*)ser);
12559 ser_ref.data = (int8_t*)(ser + 4);
12560 LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
12561 *ret_conv = UnsignedChannelUpdate_read(ser_ref);
12562 return (long)ret_conv;
12565 int8_tArray __attribute__((visibility("default"))) TS_ChannelUpdate_write(uint32_t obj) {
12566 LDKChannelUpdate obj_conv;
12567 obj_conv.inner = (void*)(obj & (~1));
12568 obj_conv.is_owned = false;
12569 LDKCVec_u8Z arg_var = ChannelUpdate_write(&obj_conv);
12570 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12571 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12572 CVec_u8Z_free(arg_var);
12576 uint32_t __attribute__((visibility("default"))) TS_ChannelUpdate_read(int8_tArray ser) {
12577 LDKu8slice ser_ref;
12578 ser_ref.datalen = *((uint32_t*)ser);
12579 ser_ref.data = (int8_t*)(ser + 4);
12580 LDKChannelUpdate ret_var = ChannelUpdate_read(ser_ref);
12581 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12582 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12583 long ret_ref = (long)ret_var.inner;
12584 if (ret_var.is_owned) {
12590 int8_tArray __attribute__((visibility("default"))) TS_ErrorMessage_write(uint32_t obj) {
12591 LDKErrorMessage obj_conv;
12592 obj_conv.inner = (void*)(obj & (~1));
12593 obj_conv.is_owned = false;
12594 LDKCVec_u8Z arg_var = ErrorMessage_write(&obj_conv);
12595 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12596 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12597 CVec_u8Z_free(arg_var);
12601 uint32_t __attribute__((visibility("default"))) TS_ErrorMessage_read(int8_tArray ser) {
12602 LDKu8slice ser_ref;
12603 ser_ref.datalen = *((uint32_t*)ser);
12604 ser_ref.data = (int8_t*)(ser + 4);
12605 LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
12606 *ret_conv = ErrorMessage_read(ser_ref);
12607 return (long)ret_conv;
12610 int8_tArray __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_write(uint32_t obj) {
12611 LDKUnsignedNodeAnnouncement obj_conv;
12612 obj_conv.inner = (void*)(obj & (~1));
12613 obj_conv.is_owned = false;
12614 LDKCVec_u8Z arg_var = UnsignedNodeAnnouncement_write(&obj_conv);
12615 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12616 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12617 CVec_u8Z_free(arg_var);
12621 uint32_t __attribute__((visibility("default"))) TS_UnsignedNodeAnnouncement_read(int8_tArray ser) {
12622 LDKu8slice ser_ref;
12623 ser_ref.datalen = *((uint32_t*)ser);
12624 ser_ref.data = (int8_t*)(ser + 4);
12625 LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
12626 *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
12627 return (long)ret_conv;
12630 int8_tArray __attribute__((visibility("default"))) TS_NodeAnnouncement_write(uint32_t obj) {
12631 LDKNodeAnnouncement obj_conv;
12632 obj_conv.inner = (void*)(obj & (~1));
12633 obj_conv.is_owned = false;
12634 LDKCVec_u8Z arg_var = NodeAnnouncement_write(&obj_conv);
12635 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12636 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12637 CVec_u8Z_free(arg_var);
12641 uint32_t __attribute__((visibility("default"))) TS_NodeAnnouncement_read(int8_tArray ser) {
12642 LDKu8slice ser_ref;
12643 ser_ref.datalen = *((uint32_t*)ser);
12644 ser_ref.data = (int8_t*)(ser + 4);
12645 LDKNodeAnnouncement ret_var = NodeAnnouncement_read(ser_ref);
12646 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12647 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12648 long ret_ref = (long)ret_var.inner;
12649 if (ret_var.is_owned) {
12655 uint32_t __attribute__((visibility("default"))) TS_QueryShortChannelIds_read(int8_tArray ser) {
12656 LDKu8slice ser_ref;
12657 ser_ref.datalen = *((uint32_t*)ser);
12658 ser_ref.data = (int8_t*)(ser + 4);
12659 LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
12660 *ret_conv = QueryShortChannelIds_read(ser_ref);
12661 return (long)ret_conv;
12664 int8_tArray __attribute__((visibility("default"))) TS_QueryShortChannelIds_write(uint32_t obj) {
12665 LDKQueryShortChannelIds obj_conv;
12666 obj_conv.inner = (void*)(obj & (~1));
12667 obj_conv.is_owned = false;
12668 LDKCVec_u8Z arg_var = QueryShortChannelIds_write(&obj_conv);
12669 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12670 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12671 CVec_u8Z_free(arg_var);
12675 uint32_t __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_read(int8_tArray ser) {
12676 LDKu8slice ser_ref;
12677 ser_ref.datalen = *((uint32_t*)ser);
12678 ser_ref.data = (int8_t*)(ser + 4);
12679 LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
12680 *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
12681 return (long)ret_conv;
12684 int8_tArray __attribute__((visibility("default"))) TS_ReplyShortChannelIdsEnd_write(uint32_t obj) {
12685 LDKReplyShortChannelIdsEnd obj_conv;
12686 obj_conv.inner = (void*)(obj & (~1));
12687 obj_conv.is_owned = false;
12688 LDKCVec_u8Z arg_var = ReplyShortChannelIdsEnd_write(&obj_conv);
12689 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12690 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12691 CVec_u8Z_free(arg_var);
12695 uint32_t __attribute__((visibility("default"))) TS_QueryChannelRange_read(int8_tArray ser) {
12696 LDKu8slice ser_ref;
12697 ser_ref.datalen = *((uint32_t*)ser);
12698 ser_ref.data = (int8_t*)(ser + 4);
12699 LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
12700 *ret_conv = QueryChannelRange_read(ser_ref);
12701 return (long)ret_conv;
12704 int8_tArray __attribute__((visibility("default"))) TS_QueryChannelRange_write(uint32_t obj) {
12705 LDKQueryChannelRange obj_conv;
12706 obj_conv.inner = (void*)(obj & (~1));
12707 obj_conv.is_owned = false;
12708 LDKCVec_u8Z arg_var = QueryChannelRange_write(&obj_conv);
12709 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12710 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12711 CVec_u8Z_free(arg_var);
12715 uint32_t __attribute__((visibility("default"))) TS_ReplyChannelRange_read(int8_tArray ser) {
12716 LDKu8slice ser_ref;
12717 ser_ref.datalen = *((uint32_t*)ser);
12718 ser_ref.data = (int8_t*)(ser + 4);
12719 LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
12720 *ret_conv = ReplyChannelRange_read(ser_ref);
12721 return (long)ret_conv;
12724 int8_tArray __attribute__((visibility("default"))) TS_ReplyChannelRange_write(uint32_t obj) {
12725 LDKReplyChannelRange obj_conv;
12726 obj_conv.inner = (void*)(obj & (~1));
12727 obj_conv.is_owned = false;
12728 LDKCVec_u8Z arg_var = ReplyChannelRange_write(&obj_conv);
12729 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12730 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12731 CVec_u8Z_free(arg_var);
12735 uint32_t __attribute__((visibility("default"))) TS_GossipTimestampFilter_read(int8_tArray ser) {
12736 LDKu8slice ser_ref;
12737 ser_ref.datalen = *((uint32_t*)ser);
12738 ser_ref.data = (int8_t*)(ser + 4);
12739 LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
12740 *ret_conv = GossipTimestampFilter_read(ser_ref);
12741 return (long)ret_conv;
12744 int8_tArray __attribute__((visibility("default"))) TS_GossipTimestampFilter_write(uint32_t obj) {
12745 LDKGossipTimestampFilter obj_conv;
12746 obj_conv.inner = (void*)(obj & (~1));
12747 obj_conv.is_owned = false;
12748 LDKCVec_u8Z arg_var = GossipTimestampFilter_write(&obj_conv);
12749 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
12750 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
12751 CVec_u8Z_free(arg_var);
12755 void __attribute__((visibility("default"))) TS_MessageHandler_free(uint32_t this_ptr) {
12756 LDKMessageHandler this_ptr_conv;
12757 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12758 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12759 MessageHandler_free(this_ptr_conv);
12762 uint32_t __attribute__((visibility("default"))) TS_MessageHandler_get_chan_handler(uint32_t this_ptr) {
12763 LDKMessageHandler this_ptr_conv;
12764 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12765 this_ptr_conv.is_owned = false;
12766 long ret_ret = (long)MessageHandler_get_chan_handler(&this_ptr_conv);
12770 void __attribute__((visibility("default"))) TS_MessageHandler_set_chan_handler(uint32_t this_ptr, uint32_t val) {
12771 LDKMessageHandler this_ptr_conv;
12772 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12773 this_ptr_conv.is_owned = false;
12774 LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)val;
12775 MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
12778 uint32_t __attribute__((visibility("default"))) TS_MessageHandler_get_route_handler(uint32_t this_ptr) {
12779 LDKMessageHandler this_ptr_conv;
12780 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12781 this_ptr_conv.is_owned = false;
12782 long ret_ret = (long)MessageHandler_get_route_handler(&this_ptr_conv);
12786 void __attribute__((visibility("default"))) TS_MessageHandler_set_route_handler(uint32_t this_ptr, uint32_t val) {
12787 LDKMessageHandler this_ptr_conv;
12788 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12789 this_ptr_conv.is_owned = false;
12790 LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)val;
12791 MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
12794 uint32_t __attribute__((visibility("default"))) TS_MessageHandler_new(uint32_t chan_handler_arg, uint32_t route_handler_arg) {
12795 LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)chan_handler_arg;
12796 LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)route_handler_arg;
12797 LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
12798 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12799 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12800 long ret_ref = (long)ret_var.inner;
12801 if (ret_var.is_owned) {
12807 uint32_t __attribute__((visibility("default"))) TS_SocketDescriptor_clone(uint32_t orig) {
12808 LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig;
12809 LDKSocketDescriptor* ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
12810 *ret = SocketDescriptor_clone(orig_conv);
12814 void __attribute__((visibility("default"))) TS_SocketDescriptor_free(uint32_t this_ptr) {
12815 LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)this_ptr;
12816 FREE((void*)this_ptr);
12817 SocketDescriptor_free(this_ptr_conv);
12820 void __attribute__((visibility("default"))) TS_PeerHandleError_free(uint32_t this_ptr) {
12821 LDKPeerHandleError this_ptr_conv;
12822 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12823 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12824 PeerHandleError_free(this_ptr_conv);
12827 jboolean __attribute__((visibility("default"))) TS_PeerHandleError_get_no_connection_possible(uint32_t this_ptr) {
12828 LDKPeerHandleError this_ptr_conv;
12829 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12830 this_ptr_conv.is_owned = false;
12831 jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
12835 void __attribute__((visibility("default"))) TS_PeerHandleError_set_no_connection_possible(uint32_t this_ptr, jboolean val) {
12836 LDKPeerHandleError this_ptr_conv;
12837 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12838 this_ptr_conv.is_owned = false;
12839 PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
12842 uint32_t __attribute__((visibility("default"))) TS_PeerHandleError_new(jboolean no_connection_possible_arg) {
12843 LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
12844 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12845 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12846 long ret_ref = (long)ret_var.inner;
12847 if (ret_var.is_owned) {
12853 void __attribute__((visibility("default"))) TS_PeerManager_free(uint32_t this_ptr) {
12854 LDKPeerManager this_ptr_conv;
12855 this_ptr_conv.inner = (void*)(this_ptr & (~1));
12856 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
12857 PeerManager_free(this_ptr_conv);
12860 uint32_t __attribute__((visibility("default"))) TS_PeerManager_new(uint32_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, uint32_t logger) {
12861 LDKMessageHandler message_handler_conv;
12862 message_handler_conv.inner = (void*)(message_handler & (~1));
12863 message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
12864 // Warning: we may need a move here but can't clone!
12865 LDKSecretKey our_node_secret_ref;
12866 CHECK(*((uint32_t*)our_node_secret) == 32);
12867 memcpy(our_node_secret_ref.bytes, (uint8_t*)(our_node_secret + 4), 32);
12868 unsigned char ephemeral_random_data_arr[32];
12869 CHECK(*((uint32_t*)ephemeral_random_data) == 32);
12870 memcpy(ephemeral_random_data_arr, (uint8_t*)(ephemeral_random_data + 4), 32);
12871 unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
12872 LDKLogger logger_conv = *(LDKLogger*)logger;
12873 LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv);
12874 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
12875 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
12876 long ret_ref = (long)ret_var.inner;
12877 if (ret_var.is_owned) {
12883 ptrArray __attribute__((visibility("default"))) TS_PeerManager_get_peer_node_ids(uint32_t this_arg) {
12884 LDKPeerManager this_arg_conv;
12885 this_arg_conv.inner = (void*)(this_arg & (~1));
12886 this_arg_conv.is_owned = false;
12887 LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
12888 ptrArray ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
12889 int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
12890 for (size_t m = 0; m < ret_var.datalen; m++) {
12891 int8_tArray arr_conv_12_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
12892 memcpy((uint8_t*)(arr_conv_12_arr + 4), ret_var.data[m].compressed_form, 33);
12893 ret_arr_ptr[m] = arr_conv_12_arr;
12895 FREE(ret_var.data);
12899 uint32_t __attribute__((visibility("default"))) TS_PeerManager_new_outbound_connection(uint32_t this_arg, int8_tArray their_node_id, uint32_t descriptor) {
12900 LDKPeerManager this_arg_conv;
12901 this_arg_conv.inner = (void*)(this_arg & (~1));
12902 this_arg_conv.is_owned = false;
12903 LDKPublicKey their_node_id_ref;
12904 CHECK(*((uint32_t*)their_node_id) == 33);
12905 memcpy(their_node_id_ref.compressed_form, (uint8_t*)(their_node_id + 4), 33);
12906 LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
12907 LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
12908 *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
12909 return (long)ret_conv;
12912 uint32_t __attribute__((visibility("default"))) TS_PeerManager_new_inbound_connection(uint32_t this_arg, uint32_t descriptor) {
12913 LDKPeerManager this_arg_conv;
12914 this_arg_conv.inner = (void*)(this_arg & (~1));
12915 this_arg_conv.is_owned = false;
12916 LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)descriptor;
12917 LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12918 *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
12919 return (long)ret_conv;
12922 uint32_t __attribute__((visibility("default"))) TS_PeerManager_write_buffer_space_avail(uint32_t this_arg, uint32_t descriptor) {
12923 LDKPeerManager this_arg_conv;
12924 this_arg_conv.inner = (void*)(this_arg & (~1));
12925 this_arg_conv.is_owned = false;
12926 LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
12927 LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
12928 *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
12929 return (long)ret_conv;
12932 uint32_t __attribute__((visibility("default"))) TS_PeerManager_read_event(uint32_t this_arg, uint32_t peer_descriptor, int8_tArray data) {
12933 LDKPeerManager this_arg_conv;
12934 this_arg_conv.inner = (void*)(this_arg & (~1));
12935 this_arg_conv.is_owned = false;
12936 LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor;
12937 LDKu8slice data_ref;
12938 data_ref.datalen = *((uint32_t*)data);
12939 data_ref.data = (int8_t*)(data + 4);
12940 LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
12941 *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
12942 return (long)ret_conv;
12945 void __attribute__((visibility("default"))) TS_PeerManager_process_events(uint32_t this_arg) {
12946 LDKPeerManager this_arg_conv;
12947 this_arg_conv.inner = (void*)(this_arg & (~1));
12948 this_arg_conv.is_owned = false;
12949 PeerManager_process_events(&this_arg_conv);
12952 void __attribute__((visibility("default"))) TS_PeerManager_socket_disconnected(uint32_t this_arg, uint32_t descriptor) {
12953 LDKPeerManager this_arg_conv;
12954 this_arg_conv.inner = (void*)(this_arg & (~1));
12955 this_arg_conv.is_owned = false;
12956 LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor;
12957 PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
12960 void __attribute__((visibility("default"))) TS_PeerManager_timer_tick_occured(uint32_t this_arg) {
12961 LDKPeerManager this_arg_conv;
12962 this_arg_conv.inner = (void*)(this_arg & (~1));
12963 this_arg_conv.is_owned = false;
12964 PeerManager_timer_tick_occured(&this_arg_conv);
12967 int8_tArray __attribute__((visibility("default"))) TS_build_commitment_secret(int8_tArray commitment_seed, int64_t idx) {
12968 unsigned char commitment_seed_arr[32];
12969 CHECK(*((uint32_t*)commitment_seed) == 32);
12970 memcpy(commitment_seed_arr, (uint8_t*)(commitment_seed + 4), 32);
12971 unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
12972 int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
12973 memcpy((uint8_t*)(arg_arr + 4), build_commitment_secret(commitment_seed_ref, idx).data, 32);
12977 uint32_t __attribute__((visibility("default"))) TS_derive_private_key(int8_tArray per_commitment_point, int8_tArray base_secret) {
12978 LDKPublicKey per_commitment_point_ref;
12979 CHECK(*((uint32_t*)per_commitment_point) == 33);
12980 memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
12981 unsigned char base_secret_arr[32];
12982 CHECK(*((uint32_t*)base_secret) == 32);
12983 memcpy(base_secret_arr, (uint8_t*)(base_secret + 4), 32);
12984 unsigned char (*base_secret_ref)[32] = &base_secret_arr;
12985 LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
12986 *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
12987 return (long)ret_conv;
12990 uint32_t __attribute__((visibility("default"))) TS_derive_public_key(int8_tArray per_commitment_point, int8_tArray base_point) {
12991 LDKPublicKey per_commitment_point_ref;
12992 CHECK(*((uint32_t*)per_commitment_point) == 33);
12993 memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
12994 LDKPublicKey base_point_ref;
12995 CHECK(*((uint32_t*)base_point) == 33);
12996 memcpy(base_point_ref.compressed_form, (uint8_t*)(base_point + 4), 33);
12997 LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
12998 *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
12999 return (long)ret_conv;
13002 uint32_t __attribute__((visibility("default"))) TS_derive_private_revocation_key(int8_tArray per_commitment_secret, int8_tArray countersignatory_revocation_base_secret) {
13003 unsigned char per_commitment_secret_arr[32];
13004 CHECK(*((uint32_t*)per_commitment_secret) == 32);
13005 memcpy(per_commitment_secret_arr, (uint8_t*)(per_commitment_secret + 4), 32);
13006 unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
13007 unsigned char countersignatory_revocation_base_secret_arr[32];
13008 CHECK(*((uint32_t*)countersignatory_revocation_base_secret) == 32);
13009 memcpy(countersignatory_revocation_base_secret_arr, (uint8_t*)(countersignatory_revocation_base_secret + 4), 32);
13010 unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
13011 LDKCResult_SecretKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeySecpErrorZ), "LDKCResult_SecretKeySecpErrorZ");
13012 *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
13013 return (long)ret_conv;
13016 uint32_t __attribute__((visibility("default"))) TS_derive_public_revocation_key(int8_tArray per_commitment_point, int8_tArray countersignatory_revocation_base_point) {
13017 LDKPublicKey per_commitment_point_ref;
13018 CHECK(*((uint32_t*)per_commitment_point) == 33);
13019 memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13020 LDKPublicKey countersignatory_revocation_base_point_ref;
13021 CHECK(*((uint32_t*)countersignatory_revocation_base_point) == 33);
13022 memcpy(countersignatory_revocation_base_point_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base_point + 4), 33);
13023 LDKCResult_PublicKeySecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeySecpErrorZ), "LDKCResult_PublicKeySecpErrorZ");
13024 *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
13025 return (long)ret_conv;
13028 void __attribute__((visibility("default"))) TS_TxCreationKeys_free(uint32_t this_ptr) {
13029 LDKTxCreationKeys this_ptr_conv;
13030 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13031 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13032 TxCreationKeys_free(this_ptr_conv);
13035 uint32_t __attribute__((visibility("default"))) TS_TxCreationKeys_clone(uint32_t orig) {
13036 LDKTxCreationKeys orig_conv;
13037 orig_conv.inner = (void*)(orig & (~1));
13038 orig_conv.is_owned = false;
13039 LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
13040 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13041 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13042 long ret_ref = (long)ret_var.inner;
13043 if (ret_var.is_owned) {
13049 int8_tArray __attribute__((visibility("default"))) TS_TxCreationKeys_get_per_commitment_point(uint32_t this_ptr) {
13050 LDKTxCreationKeys this_ptr_conv;
13051 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13052 this_ptr_conv.is_owned = false;
13053 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13054 memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form, 33);
13058 void __attribute__((visibility("default"))) TS_TxCreationKeys_set_per_commitment_point(uint32_t this_ptr, int8_tArray val) {
13059 LDKTxCreationKeys this_ptr_conv;
13060 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13061 this_ptr_conv.is_owned = false;
13062 LDKPublicKey val_ref;
13063 CHECK(*((uint32_t*)val) == 33);
13064 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13065 TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
13068 int8_tArray __attribute__((visibility("default"))) TS_TxCreationKeys_get_revocation_key(uint32_t this_ptr) {
13069 LDKTxCreationKeys this_ptr_conv;
13070 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13071 this_ptr_conv.is_owned = false;
13072 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13073 memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form, 33);
13077 void __attribute__((visibility("default"))) TS_TxCreationKeys_set_revocation_key(uint32_t this_ptr, int8_tArray val) {
13078 LDKTxCreationKeys this_ptr_conv;
13079 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13080 this_ptr_conv.is_owned = false;
13081 LDKPublicKey val_ref;
13082 CHECK(*((uint32_t*)val) == 33);
13083 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13084 TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
13087 int8_tArray __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_htlc_key(uint32_t this_ptr) {
13088 LDKTxCreationKeys this_ptr_conv;
13089 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13090 this_ptr_conv.is_owned = false;
13091 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13092 memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form, 33);
13096 void __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_htlc_key(uint32_t this_ptr, int8_tArray val) {
13097 LDKTxCreationKeys this_ptr_conv;
13098 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13099 this_ptr_conv.is_owned = false;
13100 LDKPublicKey val_ref;
13101 CHECK(*((uint32_t*)val) == 33);
13102 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13103 TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
13106 int8_tArray __attribute__((visibility("default"))) TS_TxCreationKeys_get_countersignatory_htlc_key(uint32_t this_ptr) {
13107 LDKTxCreationKeys this_ptr_conv;
13108 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13109 this_ptr_conv.is_owned = false;
13110 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13111 memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form, 33);
13115 void __attribute__((visibility("default"))) TS_TxCreationKeys_set_countersignatory_htlc_key(uint32_t this_ptr, int8_tArray val) {
13116 LDKTxCreationKeys this_ptr_conv;
13117 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13118 this_ptr_conv.is_owned = false;
13119 LDKPublicKey val_ref;
13120 CHECK(*((uint32_t*)val) == 33);
13121 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13122 TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
13125 int8_tArray __attribute__((visibility("default"))) TS_TxCreationKeys_get_broadcaster_delayed_payment_key(uint32_t this_ptr) {
13126 LDKTxCreationKeys this_ptr_conv;
13127 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13128 this_ptr_conv.is_owned = false;
13129 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13130 memcpy((uint8_t*)(arg_arr + 4), TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form, 33);
13134 void __attribute__((visibility("default"))) TS_TxCreationKeys_set_broadcaster_delayed_payment_key(uint32_t this_ptr, int8_tArray val) {
13135 LDKTxCreationKeys this_ptr_conv;
13136 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13137 this_ptr_conv.is_owned = false;
13138 LDKPublicKey val_ref;
13139 CHECK(*((uint32_t*)val) == 33);
13140 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13141 TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
13144 uint32_t __attribute__((visibility("default"))) TS_TxCreationKeys_new(int8_tArray per_commitment_point_arg, int8_tArray revocation_key_arg, int8_tArray broadcaster_htlc_key_arg, int8_tArray countersignatory_htlc_key_arg, int8_tArray broadcaster_delayed_payment_key_arg) {
13145 LDKPublicKey per_commitment_point_arg_ref;
13146 CHECK(*((uint32_t*)per_commitment_point_arg) == 33);
13147 memcpy(per_commitment_point_arg_ref.compressed_form, (uint8_t*)(per_commitment_point_arg + 4), 33);
13148 LDKPublicKey revocation_key_arg_ref;
13149 CHECK(*((uint32_t*)revocation_key_arg) == 33);
13150 memcpy(revocation_key_arg_ref.compressed_form, (uint8_t*)(revocation_key_arg + 4), 33);
13151 LDKPublicKey broadcaster_htlc_key_arg_ref;
13152 CHECK(*((uint32_t*)broadcaster_htlc_key_arg) == 33);
13153 memcpy(broadcaster_htlc_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_htlc_key_arg + 4), 33);
13154 LDKPublicKey countersignatory_htlc_key_arg_ref;
13155 CHECK(*((uint32_t*)countersignatory_htlc_key_arg) == 33);
13156 memcpy(countersignatory_htlc_key_arg_ref.compressed_form, (uint8_t*)(countersignatory_htlc_key_arg + 4), 33);
13157 LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
13158 CHECK(*((uint32_t*)broadcaster_delayed_payment_key_arg) == 33);
13159 memcpy(broadcaster_delayed_payment_key_arg_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key_arg + 4), 33);
13160 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);
13161 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13162 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13163 long ret_ref = (long)ret_var.inner;
13164 if (ret_var.is_owned) {
13170 int8_tArray __attribute__((visibility("default"))) TS_TxCreationKeys_write(uint32_t obj) {
13171 LDKTxCreationKeys obj_conv;
13172 obj_conv.inner = (void*)(obj & (~1));
13173 obj_conv.is_owned = false;
13174 LDKCVec_u8Z arg_var = TxCreationKeys_write(&obj_conv);
13175 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13176 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13177 CVec_u8Z_free(arg_var);
13181 uint32_t __attribute__((visibility("default"))) TS_TxCreationKeys_read(int8_tArray ser) {
13182 LDKu8slice ser_ref;
13183 ser_ref.datalen = *((uint32_t*)ser);
13184 ser_ref.data = (int8_t*)(ser + 4);
13185 LDKTxCreationKeys ret_var = TxCreationKeys_read(ser_ref);
13186 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13187 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13188 long ret_ref = (long)ret_var.inner;
13189 if (ret_var.is_owned) {
13195 void __attribute__((visibility("default"))) TS_ChannelPublicKeys_free(uint32_t this_ptr) {
13196 LDKChannelPublicKeys this_ptr_conv;
13197 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13198 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13199 ChannelPublicKeys_free(this_ptr_conv);
13202 uint32_t __attribute__((visibility("default"))) TS_ChannelPublicKeys_clone(uint32_t orig) {
13203 LDKChannelPublicKeys orig_conv;
13204 orig_conv.inner = (void*)(orig & (~1));
13205 orig_conv.is_owned = false;
13206 LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
13207 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13208 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13209 long ret_ref = (long)ret_var.inner;
13210 if (ret_var.is_owned) {
13216 int8_tArray __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_funding_pubkey(uint32_t this_ptr) {
13217 LDKChannelPublicKeys this_ptr_conv;
13218 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13219 this_ptr_conv.is_owned = false;
13220 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13221 memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form, 33);
13225 void __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_funding_pubkey(uint32_t this_ptr, int8_tArray val) {
13226 LDKChannelPublicKeys this_ptr_conv;
13227 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13228 this_ptr_conv.is_owned = false;
13229 LDKPublicKey val_ref;
13230 CHECK(*((uint32_t*)val) == 33);
13231 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13232 ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
13235 int8_tArray __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_revocation_basepoint(uint32_t this_ptr) {
13236 LDKChannelPublicKeys this_ptr_conv;
13237 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13238 this_ptr_conv.is_owned = false;
13239 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13240 memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form, 33);
13244 void __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_revocation_basepoint(uint32_t this_ptr, int8_tArray val) {
13245 LDKChannelPublicKeys this_ptr_conv;
13246 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13247 this_ptr_conv.is_owned = false;
13248 LDKPublicKey val_ref;
13249 CHECK(*((uint32_t*)val) == 33);
13250 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13251 ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
13254 int8_tArray __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_payment_point(uint32_t this_ptr) {
13255 LDKChannelPublicKeys this_ptr_conv;
13256 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13257 this_ptr_conv.is_owned = false;
13258 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13259 memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form, 33);
13263 void __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_payment_point(uint32_t this_ptr, int8_tArray val) {
13264 LDKChannelPublicKeys this_ptr_conv;
13265 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13266 this_ptr_conv.is_owned = false;
13267 LDKPublicKey val_ref;
13268 CHECK(*((uint32_t*)val) == 33);
13269 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13270 ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
13273 int8_tArray __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_delayed_payment_basepoint(uint32_t this_ptr) {
13274 LDKChannelPublicKeys this_ptr_conv;
13275 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13276 this_ptr_conv.is_owned = false;
13277 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13278 memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form, 33);
13282 void __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_delayed_payment_basepoint(uint32_t this_ptr, int8_tArray val) {
13283 LDKChannelPublicKeys this_ptr_conv;
13284 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13285 this_ptr_conv.is_owned = false;
13286 LDKPublicKey val_ref;
13287 CHECK(*((uint32_t*)val) == 33);
13288 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13289 ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
13292 int8_tArray __attribute__((visibility("default"))) TS_ChannelPublicKeys_get_htlc_basepoint(uint32_t this_ptr) {
13293 LDKChannelPublicKeys this_ptr_conv;
13294 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13295 this_ptr_conv.is_owned = false;
13296 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
13297 memcpy((uint8_t*)(arg_arr + 4), ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form, 33);
13301 void __attribute__((visibility("default"))) TS_ChannelPublicKeys_set_htlc_basepoint(uint32_t this_ptr, int8_tArray val) {
13302 LDKChannelPublicKeys this_ptr_conv;
13303 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13304 this_ptr_conv.is_owned = false;
13305 LDKPublicKey val_ref;
13306 CHECK(*((uint32_t*)val) == 33);
13307 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
13308 ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
13311 uint32_t __attribute__((visibility("default"))) TS_ChannelPublicKeys_new(int8_tArray funding_pubkey_arg, int8_tArray revocation_basepoint_arg, int8_tArray payment_point_arg, int8_tArray delayed_payment_basepoint_arg, int8_tArray htlc_basepoint_arg) {
13312 LDKPublicKey funding_pubkey_arg_ref;
13313 CHECK(*((uint32_t*)funding_pubkey_arg) == 33);
13314 memcpy(funding_pubkey_arg_ref.compressed_form, (uint8_t*)(funding_pubkey_arg + 4), 33);
13315 LDKPublicKey revocation_basepoint_arg_ref;
13316 CHECK(*((uint32_t*)revocation_basepoint_arg) == 33);
13317 memcpy(revocation_basepoint_arg_ref.compressed_form, (uint8_t*)(revocation_basepoint_arg + 4), 33);
13318 LDKPublicKey payment_point_arg_ref;
13319 CHECK(*((uint32_t*)payment_point_arg) == 33);
13320 memcpy(payment_point_arg_ref.compressed_form, (uint8_t*)(payment_point_arg + 4), 33);
13321 LDKPublicKey delayed_payment_basepoint_arg_ref;
13322 CHECK(*((uint32_t*)delayed_payment_basepoint_arg) == 33);
13323 memcpy(delayed_payment_basepoint_arg_ref.compressed_form, (uint8_t*)(delayed_payment_basepoint_arg + 4), 33);
13324 LDKPublicKey htlc_basepoint_arg_ref;
13325 CHECK(*((uint32_t*)htlc_basepoint_arg) == 33);
13326 memcpy(htlc_basepoint_arg_ref.compressed_form, (uint8_t*)(htlc_basepoint_arg + 4), 33);
13327 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);
13328 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13329 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13330 long ret_ref = (long)ret_var.inner;
13331 if (ret_var.is_owned) {
13337 int8_tArray __attribute__((visibility("default"))) TS_ChannelPublicKeys_write(uint32_t obj) {
13338 LDKChannelPublicKeys obj_conv;
13339 obj_conv.inner = (void*)(obj & (~1));
13340 obj_conv.is_owned = false;
13341 LDKCVec_u8Z arg_var = ChannelPublicKeys_write(&obj_conv);
13342 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13343 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13344 CVec_u8Z_free(arg_var);
13348 uint32_t __attribute__((visibility("default"))) TS_ChannelPublicKeys_read(int8_tArray ser) {
13349 LDKu8slice ser_ref;
13350 ser_ref.datalen = *((uint32_t*)ser);
13351 ser_ref.data = (int8_t*)(ser + 4);
13352 LDKChannelPublicKeys ret_var = ChannelPublicKeys_read(ser_ref);
13353 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13354 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13355 long ret_ref = (long)ret_var.inner;
13356 if (ret_var.is_owned) {
13362 uint32_t __attribute__((visibility("default"))) TS_TxCreationKeys_derive_new(int8_tArray per_commitment_point, int8_tArray broadcaster_delayed_payment_base, int8_tArray broadcaster_htlc_base, int8_tArray countersignatory_revocation_base, int8_tArray countersignatory_htlc_base) {
13363 LDKPublicKey per_commitment_point_ref;
13364 CHECK(*((uint32_t*)per_commitment_point) == 33);
13365 memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13366 LDKPublicKey broadcaster_delayed_payment_base_ref;
13367 CHECK(*((uint32_t*)broadcaster_delayed_payment_base) == 33);
13368 memcpy(broadcaster_delayed_payment_base_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_base + 4), 33);
13369 LDKPublicKey broadcaster_htlc_base_ref;
13370 CHECK(*((uint32_t*)broadcaster_htlc_base) == 33);
13371 memcpy(broadcaster_htlc_base_ref.compressed_form, (uint8_t*)(broadcaster_htlc_base + 4), 33);
13372 LDKPublicKey countersignatory_revocation_base_ref;
13373 CHECK(*((uint32_t*)countersignatory_revocation_base) == 33);
13374 memcpy(countersignatory_revocation_base_ref.compressed_form, (uint8_t*)(countersignatory_revocation_base + 4), 33);
13375 LDKPublicKey countersignatory_htlc_base_ref;
13376 CHECK(*((uint32_t*)countersignatory_htlc_base) == 33);
13377 memcpy(countersignatory_htlc_base_ref.compressed_form, (uint8_t*)(countersignatory_htlc_base + 4), 33);
13378 LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
13379 *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);
13380 return (long)ret_conv;
13383 uint32_t __attribute__((visibility("default"))) TS_TxCreationKeys_from_channel_static_keys(int8_tArray per_commitment_point, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
13384 LDKPublicKey per_commitment_point_ref;
13385 CHECK(*((uint32_t*)per_commitment_point) == 33);
13386 memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
13387 LDKChannelPublicKeys broadcaster_keys_conv;
13388 broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
13389 broadcaster_keys_conv.is_owned = false;
13390 LDKChannelPublicKeys countersignatory_keys_conv;
13391 countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
13392 countersignatory_keys_conv.is_owned = false;
13393 LDKCResult_TxCreationKeysSecpErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysSecpErrorZ), "LDKCResult_TxCreationKeysSecpErrorZ");
13394 *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
13395 return (long)ret_conv;
13398 int8_tArray __attribute__((visibility("default"))) TS_get_revokeable_redeemscript(int8_tArray revocation_key, int16_t contest_delay, int8_tArray broadcaster_delayed_payment_key) {
13399 LDKPublicKey revocation_key_ref;
13400 CHECK(*((uint32_t*)revocation_key) == 33);
13401 memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
13402 LDKPublicKey broadcaster_delayed_payment_key_ref;
13403 CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
13404 memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
13405 LDKCVec_u8Z arg_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
13406 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13407 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13408 CVec_u8Z_free(arg_var);
13412 void __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_free(uint32_t this_ptr) {
13413 LDKHTLCOutputInCommitment this_ptr_conv;
13414 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13415 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13416 HTLCOutputInCommitment_free(this_ptr_conv);
13419 uint32_t __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_clone(uint32_t orig) {
13420 LDKHTLCOutputInCommitment orig_conv;
13421 orig_conv.inner = (void*)(orig & (~1));
13422 orig_conv.is_owned = false;
13423 LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
13424 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13425 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13426 long ret_ref = (long)ret_var.inner;
13427 if (ret_var.is_owned) {
13433 jboolean __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_offered(uint32_t this_ptr) {
13434 LDKHTLCOutputInCommitment this_ptr_conv;
13435 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13436 this_ptr_conv.is_owned = false;
13437 jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
13441 void __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_offered(uint32_t this_ptr, jboolean val) {
13442 LDKHTLCOutputInCommitment this_ptr_conv;
13443 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13444 this_ptr_conv.is_owned = false;
13445 HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
13448 int64_t __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_amount_msat(uint32_t this_ptr) {
13449 LDKHTLCOutputInCommitment this_ptr_conv;
13450 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13451 this_ptr_conv.is_owned = false;
13452 int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
13456 void __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_amount_msat(uint32_t this_ptr, int64_t val) {
13457 LDKHTLCOutputInCommitment this_ptr_conv;
13458 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13459 this_ptr_conv.is_owned = false;
13460 HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
13463 int32_t __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_cltv_expiry(uint32_t this_ptr) {
13464 LDKHTLCOutputInCommitment this_ptr_conv;
13465 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13466 this_ptr_conv.is_owned = false;
13467 int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
13471 void __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_cltv_expiry(uint32_t this_ptr, int32_t val) {
13472 LDKHTLCOutputInCommitment this_ptr_conv;
13473 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13474 this_ptr_conv.is_owned = false;
13475 HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
13478 int8_tArray __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_get_payment_hash(uint32_t this_ptr) {
13479 LDKHTLCOutputInCommitment this_ptr_conv;
13480 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13481 this_ptr_conv.is_owned = false;
13482 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
13483 memcpy((uint8_t*)(ret_arr + 4), *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv), 32);
13487 void __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_set_payment_hash(uint32_t this_ptr, int8_tArray val) {
13488 LDKHTLCOutputInCommitment this_ptr_conv;
13489 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13490 this_ptr_conv.is_owned = false;
13491 LDKThirtyTwoBytes val_ref;
13492 CHECK(*((uint32_t*)val) == 32);
13493 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
13494 HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
13497 int8_tArray __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_write(uint32_t obj) {
13498 LDKHTLCOutputInCommitment obj_conv;
13499 obj_conv.inner = (void*)(obj & (~1));
13500 obj_conv.is_owned = false;
13501 LDKCVec_u8Z arg_var = HTLCOutputInCommitment_write(&obj_conv);
13502 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13503 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13504 CVec_u8Z_free(arg_var);
13508 uint32_t __attribute__((visibility("default"))) TS_HTLCOutputInCommitment_read(int8_tArray ser) {
13509 LDKu8slice ser_ref;
13510 ser_ref.datalen = *((uint32_t*)ser);
13511 ser_ref.data = (int8_t*)(ser + 4);
13512 LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_read(ser_ref);
13513 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13514 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13515 long ret_ref = (long)ret_var.inner;
13516 if (ret_var.is_owned) {
13522 int8_tArray __attribute__((visibility("default"))) TS_get_htlc_redeemscript(uint32_t htlc, uint32_t keys) {
13523 LDKHTLCOutputInCommitment htlc_conv;
13524 htlc_conv.inner = (void*)(htlc & (~1));
13525 htlc_conv.is_owned = false;
13526 LDKTxCreationKeys keys_conv;
13527 keys_conv.inner = (void*)(keys & (~1));
13528 keys_conv.is_owned = false;
13529 LDKCVec_u8Z arg_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
13530 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13531 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13532 CVec_u8Z_free(arg_var);
13536 int8_tArray __attribute__((visibility("default"))) TS_make_funding_redeemscript(int8_tArray broadcaster, int8_tArray countersignatory) {
13537 LDKPublicKey broadcaster_ref;
13538 CHECK(*((uint32_t*)broadcaster) == 33);
13539 memcpy(broadcaster_ref.compressed_form, (uint8_t*)(broadcaster + 4), 33);
13540 LDKPublicKey countersignatory_ref;
13541 CHECK(*((uint32_t*)countersignatory) == 33);
13542 memcpy(countersignatory_ref.compressed_form, (uint8_t*)(countersignatory + 4), 33);
13543 LDKCVec_u8Z arg_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
13544 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13545 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13546 CVec_u8Z_free(arg_var);
13550 int8_tArray __attribute__((visibility("default"))) TS_build_htlc_transaction(int8_tArray prev_hash, int32_t feerate_per_kw, int16_t contest_delay, uint32_t htlc, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
13551 unsigned char prev_hash_arr[32];
13552 CHECK(*((uint32_t*)prev_hash) == 32);
13553 memcpy(prev_hash_arr, (uint8_t*)(prev_hash + 4), 32);
13554 unsigned char (*prev_hash_ref)[32] = &prev_hash_arr;
13555 LDKHTLCOutputInCommitment htlc_conv;
13556 htlc_conv.inner = (void*)(htlc & (~1));
13557 htlc_conv.is_owned = false;
13558 LDKPublicKey broadcaster_delayed_payment_key_ref;
13559 CHECK(*((uint32_t*)broadcaster_delayed_payment_key) == 33);
13560 memcpy(broadcaster_delayed_payment_key_ref.compressed_form, (uint8_t*)(broadcaster_delayed_payment_key + 4), 33);
13561 LDKPublicKey revocation_key_ref;
13562 CHECK(*((uint32_t*)revocation_key) == 33);
13563 memcpy(revocation_key_ref.compressed_form, (uint8_t*)(revocation_key + 4), 33);
13564 LDKTransaction arg_var = build_htlc_transaction(prev_hash_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
13565 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13566 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13567 Transaction_free(arg_var);
13571 void __attribute__((visibility("default"))) TS_ChannelTransactionParameters_free(uint32_t this_ptr) {
13572 LDKChannelTransactionParameters this_ptr_conv;
13573 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13574 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13575 ChannelTransactionParameters_free(this_ptr_conv);
13578 uint32_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_clone(uint32_t orig) {
13579 LDKChannelTransactionParameters orig_conv;
13580 orig_conv.inner = (void*)(orig & (~1));
13581 orig_conv.is_owned = false;
13582 LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
13583 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13584 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13585 long ret_ref = (long)ret_var.inner;
13586 if (ret_var.is_owned) {
13592 uint32_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_pubkeys(uint32_t this_ptr) {
13593 LDKChannelTransactionParameters this_ptr_conv;
13594 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13595 this_ptr_conv.is_owned = false;
13596 LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
13597 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13598 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13599 long ret_ref = (long)ret_var.inner;
13600 if (ret_var.is_owned) {
13606 void __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_pubkeys(uint32_t this_ptr, uint32_t val) {
13607 LDKChannelTransactionParameters this_ptr_conv;
13608 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13609 this_ptr_conv.is_owned = false;
13610 LDKChannelPublicKeys val_conv;
13611 val_conv.inner = (void*)(val & (~1));
13612 val_conv.is_owned = (val & 1) || (val == 0);
13613 if (val_conv.inner != NULL)
13614 val_conv = ChannelPublicKeys_clone(&val_conv);
13615 ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
13618 int16_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_holder_selected_contest_delay(uint32_t this_ptr) {
13619 LDKChannelTransactionParameters this_ptr_conv;
13620 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13621 this_ptr_conv.is_owned = false;
13622 int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
13626 void __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_holder_selected_contest_delay(uint32_t this_ptr, int16_t val) {
13627 LDKChannelTransactionParameters this_ptr_conv;
13628 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13629 this_ptr_conv.is_owned = false;
13630 ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
13633 jboolean __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_is_outbound_from_holder(uint32_t this_ptr) {
13634 LDKChannelTransactionParameters this_ptr_conv;
13635 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13636 this_ptr_conv.is_owned = false;
13637 jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
13641 void __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_is_outbound_from_holder(uint32_t this_ptr, jboolean val) {
13642 LDKChannelTransactionParameters this_ptr_conv;
13643 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13644 this_ptr_conv.is_owned = false;
13645 ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
13648 uint32_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_counterparty_parameters(uint32_t this_ptr) {
13649 LDKChannelTransactionParameters this_ptr_conv;
13650 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13651 this_ptr_conv.is_owned = false;
13652 LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
13653 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13654 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13655 long ret_ref = (long)ret_var.inner;
13656 if (ret_var.is_owned) {
13662 void __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_counterparty_parameters(uint32_t this_ptr, uint32_t val) {
13663 LDKChannelTransactionParameters this_ptr_conv;
13664 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13665 this_ptr_conv.is_owned = false;
13666 LDKCounterpartyChannelTransactionParameters val_conv;
13667 val_conv.inner = (void*)(val & (~1));
13668 val_conv.is_owned = (val & 1) || (val == 0);
13669 if (val_conv.inner != NULL)
13670 val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
13671 ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
13674 uint32_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_get_funding_outpoint(uint32_t this_ptr) {
13675 LDKChannelTransactionParameters this_ptr_conv;
13676 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13677 this_ptr_conv.is_owned = false;
13678 LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
13679 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13680 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13681 long ret_ref = (long)ret_var.inner;
13682 if (ret_var.is_owned) {
13688 void __attribute__((visibility("default"))) TS_ChannelTransactionParameters_set_funding_outpoint(uint32_t this_ptr, uint32_t val) {
13689 LDKChannelTransactionParameters this_ptr_conv;
13690 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13691 this_ptr_conv.is_owned = false;
13692 LDKOutPoint val_conv;
13693 val_conv.inner = (void*)(val & (~1));
13694 val_conv.is_owned = (val & 1) || (val == 0);
13695 if (val_conv.inner != NULL)
13696 val_conv = OutPoint_clone(&val_conv);
13697 ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
13700 uint32_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_new(uint32_t holder_pubkeys_arg, int16_t holder_selected_contest_delay_arg, jboolean is_outbound_from_holder_arg, uint32_t counterparty_parameters_arg, uint32_t funding_outpoint_arg) {
13701 LDKChannelPublicKeys holder_pubkeys_arg_conv;
13702 holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
13703 holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
13704 if (holder_pubkeys_arg_conv.inner != NULL)
13705 holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
13706 LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
13707 counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
13708 counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
13709 if (counterparty_parameters_arg_conv.inner != NULL)
13710 counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
13711 LDKOutPoint funding_outpoint_arg_conv;
13712 funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
13713 funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
13714 if (funding_outpoint_arg_conv.inner != NULL)
13715 funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
13716 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);
13717 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13718 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13719 long ret_ref = (long)ret_var.inner;
13720 if (ret_var.is_owned) {
13726 void __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_free(uint32_t this_ptr) {
13727 LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13728 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13729 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13730 CounterpartyChannelTransactionParameters_free(this_ptr_conv);
13733 uint32_t __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_clone(uint32_t orig) {
13734 LDKCounterpartyChannelTransactionParameters orig_conv;
13735 orig_conv.inner = (void*)(orig & (~1));
13736 orig_conv.is_owned = false;
13737 LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
13738 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13739 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13740 long ret_ref = (long)ret_var.inner;
13741 if (ret_var.is_owned) {
13747 uint32_t __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_pubkeys(uint32_t this_ptr) {
13748 LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13749 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13750 this_ptr_conv.is_owned = false;
13751 LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
13752 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13753 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13754 long ret_ref = (long)ret_var.inner;
13755 if (ret_var.is_owned) {
13761 void __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_pubkeys(uint32_t this_ptr, uint32_t val) {
13762 LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13763 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13764 this_ptr_conv.is_owned = false;
13765 LDKChannelPublicKeys val_conv;
13766 val_conv.inner = (void*)(val & (~1));
13767 val_conv.is_owned = (val & 1) || (val == 0);
13768 if (val_conv.inner != NULL)
13769 val_conv = ChannelPublicKeys_clone(&val_conv);
13770 CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
13773 int16_t __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_get_selected_contest_delay(uint32_t this_ptr) {
13774 LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13775 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13776 this_ptr_conv.is_owned = false;
13777 int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
13781 void __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_set_selected_contest_delay(uint32_t this_ptr, int16_t val) {
13782 LDKCounterpartyChannelTransactionParameters this_ptr_conv;
13783 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13784 this_ptr_conv.is_owned = false;
13785 CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
13788 uint32_t __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_new(uint32_t pubkeys_arg, int16_t selected_contest_delay_arg) {
13789 LDKChannelPublicKeys pubkeys_arg_conv;
13790 pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
13791 pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
13792 if (pubkeys_arg_conv.inner != NULL)
13793 pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
13794 LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
13795 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13796 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13797 long ret_ref = (long)ret_var.inner;
13798 if (ret_var.is_owned) {
13804 jboolean __attribute__((visibility("default"))) TS_ChannelTransactionParameters_is_populated(uint32_t this_arg) {
13805 LDKChannelTransactionParameters this_arg_conv;
13806 this_arg_conv.inner = (void*)(this_arg & (~1));
13807 this_arg_conv.is_owned = false;
13808 jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
13812 uint32_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_holder_broadcastable(uint32_t this_arg) {
13813 LDKChannelTransactionParameters this_arg_conv;
13814 this_arg_conv.inner = (void*)(this_arg & (~1));
13815 this_arg_conv.is_owned = false;
13816 LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
13817 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13818 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13819 long ret_ref = (long)ret_var.inner;
13820 if (ret_var.is_owned) {
13826 uint32_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_as_counterparty_broadcastable(uint32_t this_arg) {
13827 LDKChannelTransactionParameters this_arg_conv;
13828 this_arg_conv.inner = (void*)(this_arg & (~1));
13829 this_arg_conv.is_owned = false;
13830 LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
13831 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13832 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13833 long ret_ref = (long)ret_var.inner;
13834 if (ret_var.is_owned) {
13840 int8_tArray __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_write(uint32_t obj) {
13841 LDKCounterpartyChannelTransactionParameters obj_conv;
13842 obj_conv.inner = (void*)(obj & (~1));
13843 obj_conv.is_owned = false;
13844 LDKCVec_u8Z arg_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
13845 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13846 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13847 CVec_u8Z_free(arg_var);
13851 uint32_t __attribute__((visibility("default"))) TS_CounterpartyChannelTransactionParameters_read(int8_tArray ser) {
13852 LDKu8slice ser_ref;
13853 ser_ref.datalen = *((uint32_t*)ser);
13854 ser_ref.data = (int8_t*)(ser + 4);
13855 LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_read(ser_ref);
13856 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13857 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13858 long ret_ref = (long)ret_var.inner;
13859 if (ret_var.is_owned) {
13865 int8_tArray __attribute__((visibility("default"))) TS_ChannelTransactionParameters_write(uint32_t obj) {
13866 LDKChannelTransactionParameters obj_conv;
13867 obj_conv.inner = (void*)(obj & (~1));
13868 obj_conv.is_owned = false;
13869 LDKCVec_u8Z arg_var = ChannelTransactionParameters_write(&obj_conv);
13870 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
13871 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
13872 CVec_u8Z_free(arg_var);
13876 uint32_t __attribute__((visibility("default"))) TS_ChannelTransactionParameters_read(int8_tArray ser) {
13877 LDKu8slice ser_ref;
13878 ser_ref.datalen = *((uint32_t*)ser);
13879 ser_ref.data = (int8_t*)(ser + 4);
13880 LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_read(ser_ref);
13881 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13882 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13883 long ret_ref = (long)ret_var.inner;
13884 if (ret_var.is_owned) {
13890 void __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_free(uint32_t this_ptr) {
13891 LDKDirectedChannelTransactionParameters this_ptr_conv;
13892 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13893 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13894 DirectedChannelTransactionParameters_free(this_ptr_conv);
13897 uint32_t __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_broadcaster_pubkeys(uint32_t this_arg) {
13898 LDKDirectedChannelTransactionParameters this_arg_conv;
13899 this_arg_conv.inner = (void*)(this_arg & (~1));
13900 this_arg_conv.is_owned = false;
13901 LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
13902 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13903 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13904 long ret_ref = (long)ret_var.inner;
13905 if (ret_var.is_owned) {
13911 uint32_t __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_countersignatory_pubkeys(uint32_t this_arg) {
13912 LDKDirectedChannelTransactionParameters this_arg_conv;
13913 this_arg_conv.inner = (void*)(this_arg & (~1));
13914 this_arg_conv.is_owned = false;
13915 LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
13916 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13917 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13918 long ret_ref = (long)ret_var.inner;
13919 if (ret_var.is_owned) {
13925 int16_t __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_contest_delay(uint32_t this_arg) {
13926 LDKDirectedChannelTransactionParameters this_arg_conv;
13927 this_arg_conv.inner = (void*)(this_arg & (~1));
13928 this_arg_conv.is_owned = false;
13929 int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
13933 jboolean __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_is_outbound(uint32_t this_arg) {
13934 LDKDirectedChannelTransactionParameters this_arg_conv;
13935 this_arg_conv.inner = (void*)(this_arg & (~1));
13936 this_arg_conv.is_owned = false;
13937 jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
13941 uint32_t __attribute__((visibility("default"))) TS_DirectedChannelTransactionParameters_funding_outpoint(uint32_t this_arg) {
13942 LDKDirectedChannelTransactionParameters this_arg_conv;
13943 this_arg_conv.inner = (void*)(this_arg & (~1));
13944 this_arg_conv.is_owned = false;
13945 LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_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) {
13955 void __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_free(uint32_t this_ptr) {
13956 LDKHolderCommitmentTransaction this_ptr_conv;
13957 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13958 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
13959 HolderCommitmentTransaction_free(this_ptr_conv);
13962 uint32_t __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_clone(uint32_t orig) {
13963 LDKHolderCommitmentTransaction orig_conv;
13964 orig_conv.inner = (void*)(orig & (~1));
13965 orig_conv.is_owned = false;
13966 LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
13967 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
13968 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
13969 long ret_ref = (long)ret_var.inner;
13970 if (ret_var.is_owned) {
13976 int8_tArray __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_get_counterparty_sig(uint32_t this_ptr) {
13977 LDKHolderCommitmentTransaction this_ptr_conv;
13978 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13979 this_ptr_conv.is_owned = false;
13980 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
13981 memcpy((uint8_t*)(arg_arr + 4), HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form, 64);
13985 void __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_sig(uint32_t this_ptr, int8_tArray val) {
13986 LDKHolderCommitmentTransaction this_ptr_conv;
13987 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13988 this_ptr_conv.is_owned = false;
13989 LDKSignature val_ref;
13990 CHECK(*((uint32_t*)val) == 64);
13991 memcpy(val_ref.compact_form, (uint8_t*)(val + 4), 64);
13992 HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
13995 void __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_set_counterparty_htlc_sigs(uint32_t this_ptr, ptrArray val) {
13996 LDKHolderCommitmentTransaction this_ptr_conv;
13997 this_ptr_conv.inner = (void*)(this_ptr & (~1));
13998 this_ptr_conv.is_owned = false;
13999 LDKCVec_SignatureZ val_constr;
14000 val_constr.datalen = *((uint32_t*)val);
14001 if (val_constr.datalen > 0)
14002 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14004 val_constr.data = NULL;
14005 int8_tArray* val_vals = (int8_tArray*)(val + 4);
14006 for (size_t m = 0; m < val_constr.datalen; m++) {
14007 int8_tArray arr_conv_12 = val_vals[m];
14008 LDKSignature arr_conv_12_ref;
14009 CHECK(*((uint32_t*)arr_conv_12) == 64);
14010 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
14011 val_constr.data[m] = arr_conv_12_ref;
14013 HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
14016 int8_tArray __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_write(uint32_t obj) {
14017 LDKHolderCommitmentTransaction obj_conv;
14018 obj_conv.inner = (void*)(obj & (~1));
14019 obj_conv.is_owned = false;
14020 LDKCVec_u8Z arg_var = HolderCommitmentTransaction_write(&obj_conv);
14021 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14022 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14023 CVec_u8Z_free(arg_var);
14027 uint32_t __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_read(int8_tArray ser) {
14028 LDKu8slice ser_ref;
14029 ser_ref.datalen = *((uint32_t*)ser);
14030 ser_ref.data = (int8_t*)(ser + 4);
14031 LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_read(ser_ref);
14032 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14033 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14034 long ret_ref = (long)ret_var.inner;
14035 if (ret_var.is_owned) {
14041 uint32_t __attribute__((visibility("default"))) TS_HolderCommitmentTransaction_new(uint32_t commitment_tx, int8_tArray counterparty_sig, ptrArray counterparty_htlc_sigs, int8_tArray holder_funding_key, int8_tArray counterparty_funding_key) {
14042 LDKCommitmentTransaction commitment_tx_conv;
14043 commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
14044 commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
14045 if (commitment_tx_conv.inner != NULL)
14046 commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
14047 LDKSignature counterparty_sig_ref;
14048 CHECK(*((uint32_t*)counterparty_sig) == 64);
14049 memcpy(counterparty_sig_ref.compact_form, (uint8_t*)(counterparty_sig + 4), 64);
14050 LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
14051 counterparty_htlc_sigs_constr.datalen = *((uint32_t*)counterparty_htlc_sigs);
14052 if (counterparty_htlc_sigs_constr.datalen > 0)
14053 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
14055 counterparty_htlc_sigs_constr.data = NULL;
14056 int8_tArray* counterparty_htlc_sigs_vals = (int8_tArray*)(counterparty_htlc_sigs + 4);
14057 for (size_t m = 0; m < counterparty_htlc_sigs_constr.datalen; m++) {
14058 int8_tArray arr_conv_12 = counterparty_htlc_sigs_vals[m];
14059 LDKSignature arr_conv_12_ref;
14060 CHECK(*((uint32_t*)arr_conv_12) == 64);
14061 memcpy(arr_conv_12_ref.compact_form, (uint8_t*)(arr_conv_12 + 4), 64);
14062 counterparty_htlc_sigs_constr.data[m] = arr_conv_12_ref;
14064 LDKPublicKey holder_funding_key_ref;
14065 CHECK(*((uint32_t*)holder_funding_key) == 33);
14066 memcpy(holder_funding_key_ref.compressed_form, (uint8_t*)(holder_funding_key + 4), 33);
14067 LDKPublicKey counterparty_funding_key_ref;
14068 CHECK(*((uint32_t*)counterparty_funding_key) == 33);
14069 memcpy(counterparty_funding_key_ref.compressed_form, (uint8_t*)(counterparty_funding_key + 4), 33);
14070 LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
14071 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14072 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14073 long ret_ref = (long)ret_var.inner;
14074 if (ret_var.is_owned) {
14080 void __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_free(uint32_t this_ptr) {
14081 LDKBuiltCommitmentTransaction this_ptr_conv;
14082 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14083 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14084 BuiltCommitmentTransaction_free(this_ptr_conv);
14087 uint32_t __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_clone(uint32_t orig) {
14088 LDKBuiltCommitmentTransaction orig_conv;
14089 orig_conv.inner = (void*)(orig & (~1));
14090 orig_conv.is_owned = false;
14091 LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
14092 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14093 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14094 long ret_ref = (long)ret_var.inner;
14095 if (ret_var.is_owned) {
14101 int8_tArray __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_transaction(uint32_t this_ptr) {
14102 LDKBuiltCommitmentTransaction this_ptr_conv;
14103 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14104 this_ptr_conv.is_owned = false;
14105 LDKTransaction arg_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
14106 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14107 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14108 Transaction_free(arg_var);
14112 void __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_transaction(uint32_t this_ptr, int8_tArray val) {
14113 LDKBuiltCommitmentTransaction this_ptr_conv;
14114 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14115 this_ptr_conv.is_owned = false;
14116 LDKTransaction val_ref;
14117 val_ref.datalen = *((uint32_t*)val);
14118 val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
14119 memcpy(val_ref.data, (uint8_t*)(val + 4), val_ref.datalen);
14120 val_ref.data_is_owned = true;
14121 BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
14124 int8_tArray __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_txid(uint32_t this_ptr) {
14125 LDKBuiltCommitmentTransaction this_ptr_conv;
14126 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14127 this_ptr_conv.is_owned = false;
14128 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14129 memcpy((uint8_t*)(ret_arr + 4), *BuiltCommitmentTransaction_get_txid(&this_ptr_conv), 32);
14133 void __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_set_txid(uint32_t this_ptr, int8_tArray val) {
14134 LDKBuiltCommitmentTransaction this_ptr_conv;
14135 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14136 this_ptr_conv.is_owned = false;
14137 LDKThirtyTwoBytes val_ref;
14138 CHECK(*((uint32_t*)val) == 32);
14139 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
14140 BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
14143 uint32_t __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_new(int8_tArray transaction_arg, int8_tArray txid_arg) {
14144 LDKTransaction transaction_arg_ref;
14145 transaction_arg_ref.datalen = *((uint32_t*)transaction_arg);
14146 transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
14147 memcpy(transaction_arg_ref.data, (uint8_t*)(transaction_arg + 4), transaction_arg_ref.datalen);
14148 transaction_arg_ref.data_is_owned = true;
14149 LDKThirtyTwoBytes txid_arg_ref;
14150 CHECK(*((uint32_t*)txid_arg) == 32);
14151 memcpy(txid_arg_ref.data, (uint8_t*)(txid_arg + 4), 32);
14152 LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
14153 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14154 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14155 long ret_ref = (long)ret_var.inner;
14156 if (ret_var.is_owned) {
14162 int8_tArray __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_write(uint32_t obj) {
14163 LDKBuiltCommitmentTransaction obj_conv;
14164 obj_conv.inner = (void*)(obj & (~1));
14165 obj_conv.is_owned = false;
14166 LDKCVec_u8Z arg_var = BuiltCommitmentTransaction_write(&obj_conv);
14167 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14168 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14169 CVec_u8Z_free(arg_var);
14173 uint32_t __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_read(int8_tArray ser) {
14174 LDKu8slice ser_ref;
14175 ser_ref.datalen = *((uint32_t*)ser);
14176 ser_ref.data = (int8_t*)(ser + 4);
14177 LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_read(ser_ref);
14178 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14179 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14180 long ret_ref = (long)ret_var.inner;
14181 if (ret_var.is_owned) {
14187 int8_tArray __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_get_sighash_all(uint32_t this_arg, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
14188 LDKBuiltCommitmentTransaction this_arg_conv;
14189 this_arg_conv.inner = (void*)(this_arg & (~1));
14190 this_arg_conv.is_owned = false;
14191 LDKu8slice funding_redeemscript_ref;
14192 funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
14193 funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
14194 int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14195 memcpy((uint8_t*)(arg_arr + 4), BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data, 32);
14199 int8_tArray __attribute__((visibility("default"))) TS_BuiltCommitmentTransaction_sign(uint32_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
14200 LDKBuiltCommitmentTransaction this_arg_conv;
14201 this_arg_conv.inner = (void*)(this_arg & (~1));
14202 this_arg_conv.is_owned = false;
14203 unsigned char funding_key_arr[32];
14204 CHECK(*((uint32_t*)funding_key) == 32);
14205 memcpy(funding_key_arr, (uint8_t*)(funding_key + 4), 32);
14206 unsigned char (*funding_key_ref)[32] = &funding_key_arr;
14207 LDKu8slice funding_redeemscript_ref;
14208 funding_redeemscript_ref.datalen = *((uint32_t*)funding_redeemscript);
14209 funding_redeemscript_ref.data = (int8_t*)(funding_redeemscript + 4);
14210 int8_tArray arg_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
14211 memcpy((uint8_t*)(arg_arr + 4), BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form, 64);
14215 void __attribute__((visibility("default"))) TS_CommitmentTransaction_free(uint32_t this_ptr) {
14216 LDKCommitmentTransaction this_ptr_conv;
14217 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14218 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14219 CommitmentTransaction_free(this_ptr_conv);
14222 uint32_t __attribute__((visibility("default"))) TS_CommitmentTransaction_clone(uint32_t orig) {
14223 LDKCommitmentTransaction orig_conv;
14224 orig_conv.inner = (void*)(orig & (~1));
14225 orig_conv.is_owned = false;
14226 LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
14227 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14228 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14229 long ret_ref = (long)ret_var.inner;
14230 if (ret_var.is_owned) {
14236 int8_tArray __attribute__((visibility("default"))) TS_CommitmentTransaction_write(uint32_t obj) {
14237 LDKCommitmentTransaction obj_conv;
14238 obj_conv.inner = (void*)(obj & (~1));
14239 obj_conv.is_owned = false;
14240 LDKCVec_u8Z arg_var = CommitmentTransaction_write(&obj_conv);
14241 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14242 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14243 CVec_u8Z_free(arg_var);
14247 uint32_t __attribute__((visibility("default"))) TS_CommitmentTransaction_read(int8_tArray ser) {
14248 LDKu8slice ser_ref;
14249 ser_ref.datalen = *((uint32_t*)ser);
14250 ser_ref.data = (int8_t*)(ser + 4);
14251 LDKCommitmentTransaction ret_var = CommitmentTransaction_read(ser_ref);
14252 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14253 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14254 long ret_ref = (long)ret_var.inner;
14255 if (ret_var.is_owned) {
14261 int64_t __attribute__((visibility("default"))) TS_CommitmentTransaction_commitment_number(uint32_t this_arg) {
14262 LDKCommitmentTransaction this_arg_conv;
14263 this_arg_conv.inner = (void*)(this_arg & (~1));
14264 this_arg_conv.is_owned = false;
14265 int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
14269 int64_t __attribute__((visibility("default"))) TS_CommitmentTransaction_to_broadcaster_value_sat(uint32_t this_arg) {
14270 LDKCommitmentTransaction this_arg_conv;
14271 this_arg_conv.inner = (void*)(this_arg & (~1));
14272 this_arg_conv.is_owned = false;
14273 int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
14277 int64_t __attribute__((visibility("default"))) TS_CommitmentTransaction_to_countersignatory_value_sat(uint32_t this_arg) {
14278 LDKCommitmentTransaction this_arg_conv;
14279 this_arg_conv.inner = (void*)(this_arg & (~1));
14280 this_arg_conv.is_owned = false;
14281 int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
14285 int32_t __attribute__((visibility("default"))) TS_CommitmentTransaction_feerate_per_kw(uint32_t this_arg) {
14286 LDKCommitmentTransaction this_arg_conv;
14287 this_arg_conv.inner = (void*)(this_arg & (~1));
14288 this_arg_conv.is_owned = false;
14289 int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
14293 uint32_t __attribute__((visibility("default"))) TS_CommitmentTransaction_trust(uint32_t this_arg) {
14294 LDKCommitmentTransaction this_arg_conv;
14295 this_arg_conv.inner = (void*)(this_arg & (~1));
14296 this_arg_conv.is_owned = false;
14297 LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
14298 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14299 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14300 long ret_ref = (long)ret_var.inner;
14301 if (ret_var.is_owned) {
14307 uint32_t __attribute__((visibility("default"))) TS_CommitmentTransaction_verify(uint32_t this_arg, uint32_t channel_parameters, uint32_t broadcaster_keys, uint32_t countersignatory_keys) {
14308 LDKCommitmentTransaction this_arg_conv;
14309 this_arg_conv.inner = (void*)(this_arg & (~1));
14310 this_arg_conv.is_owned = false;
14311 LDKDirectedChannelTransactionParameters channel_parameters_conv;
14312 channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
14313 channel_parameters_conv.is_owned = false;
14314 LDKChannelPublicKeys broadcaster_keys_conv;
14315 broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
14316 broadcaster_keys_conv.is_owned = false;
14317 LDKChannelPublicKeys countersignatory_keys_conv;
14318 countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
14319 countersignatory_keys_conv.is_owned = false;
14320 LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
14321 *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
14322 return (long)ret_conv;
14325 void __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_free(uint32_t this_ptr) {
14326 LDKTrustedCommitmentTransaction this_ptr_conv;
14327 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14328 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14329 TrustedCommitmentTransaction_free(this_ptr_conv);
14332 int8_tArray __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_txid(uint32_t this_arg) {
14333 LDKTrustedCommitmentTransaction this_arg_conv;
14334 this_arg_conv.inner = (void*)(this_arg & (~1));
14335 this_arg_conv.is_owned = false;
14336 int8_tArray arg_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
14337 memcpy((uint8_t*)(arg_arr + 4), TrustedCommitmentTransaction_txid(&this_arg_conv).data, 32);
14341 uint32_t __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_built_transaction(uint32_t this_arg) {
14342 LDKTrustedCommitmentTransaction this_arg_conv;
14343 this_arg_conv.inner = (void*)(this_arg & (~1));
14344 this_arg_conv.is_owned = false;
14345 LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
14346 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14347 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14348 long ret_ref = (long)ret_var.inner;
14349 if (ret_var.is_owned) {
14355 uint32_t __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_keys(uint32_t this_arg) {
14356 LDKTrustedCommitmentTransaction this_arg_conv;
14357 this_arg_conv.inner = (void*)(this_arg & (~1));
14358 this_arg_conv.is_owned = false;
14359 LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
14360 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14361 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14362 long ret_ref = (long)ret_var.inner;
14363 if (ret_var.is_owned) {
14369 uint32_t __attribute__((visibility("default"))) TS_TrustedCommitmentTransaction_get_htlc_sigs(uint32_t this_arg, int8_tArray htlc_base_key, uint32_t channel_parameters) {
14370 LDKTrustedCommitmentTransaction this_arg_conv;
14371 this_arg_conv.inner = (void*)(this_arg & (~1));
14372 this_arg_conv.is_owned = false;
14373 unsigned char htlc_base_key_arr[32];
14374 CHECK(*((uint32_t*)htlc_base_key) == 32);
14375 memcpy(htlc_base_key_arr, (uint8_t*)(htlc_base_key + 4), 32);
14376 unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
14377 LDKDirectedChannelTransactionParameters channel_parameters_conv;
14378 channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
14379 channel_parameters_conv.is_owned = false;
14380 LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
14381 *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
14382 return (long)ret_conv;
14385 int64_t __attribute__((visibility("default"))) TS_get_commitment_transaction_number_obscure_factor(int8_tArray broadcaster_payment_basepoint, int8_tArray countersignatory_payment_basepoint, jboolean outbound_from_broadcaster) {
14386 LDKPublicKey broadcaster_payment_basepoint_ref;
14387 CHECK(*((uint32_t*)broadcaster_payment_basepoint) == 33);
14388 memcpy(broadcaster_payment_basepoint_ref.compressed_form, (uint8_t*)(broadcaster_payment_basepoint + 4), 33);
14389 LDKPublicKey countersignatory_payment_basepoint_ref;
14390 CHECK(*((uint32_t*)countersignatory_payment_basepoint) == 33);
14391 memcpy(countersignatory_payment_basepoint_ref.compressed_form, (uint8_t*)(countersignatory_payment_basepoint + 4), 33);
14392 int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
14396 void __attribute__((visibility("default"))) TS_InitFeatures_free(uint32_t this_ptr) {
14397 LDKInitFeatures this_ptr_conv;
14398 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14399 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14400 InitFeatures_free(this_ptr_conv);
14403 void __attribute__((visibility("default"))) TS_NodeFeatures_free(uint32_t this_ptr) {
14404 LDKNodeFeatures this_ptr_conv;
14405 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14406 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14407 NodeFeatures_free(this_ptr_conv);
14410 void __attribute__((visibility("default"))) TS_ChannelFeatures_free(uint32_t this_ptr) {
14411 LDKChannelFeatures this_ptr_conv;
14412 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14413 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14414 ChannelFeatures_free(this_ptr_conv);
14417 void __attribute__((visibility("default"))) TS_RouteHop_free(uint32_t this_ptr) {
14418 LDKRouteHop this_ptr_conv;
14419 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14420 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14421 RouteHop_free(this_ptr_conv);
14424 uint32_t __attribute__((visibility("default"))) TS_RouteHop_clone(uint32_t orig) {
14425 LDKRouteHop orig_conv;
14426 orig_conv.inner = (void*)(orig & (~1));
14427 orig_conv.is_owned = false;
14428 LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
14429 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14430 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14431 long ret_ref = (long)ret_var.inner;
14432 if (ret_var.is_owned) {
14438 int8_tArray __attribute__((visibility("default"))) TS_RouteHop_get_pubkey(uint32_t this_ptr) {
14439 LDKRouteHop this_ptr_conv;
14440 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14441 this_ptr_conv.is_owned = false;
14442 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14443 memcpy((uint8_t*)(arg_arr + 4), RouteHop_get_pubkey(&this_ptr_conv).compressed_form, 33);
14447 void __attribute__((visibility("default"))) TS_RouteHop_set_pubkey(uint32_t this_ptr, int8_tArray val) {
14448 LDKRouteHop this_ptr_conv;
14449 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14450 this_ptr_conv.is_owned = false;
14451 LDKPublicKey val_ref;
14452 CHECK(*((uint32_t*)val) == 33);
14453 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14454 RouteHop_set_pubkey(&this_ptr_conv, val_ref);
14457 uint32_t __attribute__((visibility("default"))) TS_RouteHop_get_node_features(uint32_t this_ptr) {
14458 LDKRouteHop this_ptr_conv;
14459 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14460 this_ptr_conv.is_owned = false;
14461 LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
14462 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14463 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14464 long ret_ref = (long)ret_var.inner;
14465 if (ret_var.is_owned) {
14471 void __attribute__((visibility("default"))) TS_RouteHop_set_node_features(uint32_t this_ptr, uint32_t val) {
14472 LDKRouteHop this_ptr_conv;
14473 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14474 this_ptr_conv.is_owned = false;
14475 LDKNodeFeatures val_conv;
14476 val_conv.inner = (void*)(val & (~1));
14477 val_conv.is_owned = (val & 1) || (val == 0);
14478 // Warning: we may need a move here but can't clone!
14479 RouteHop_set_node_features(&this_ptr_conv, val_conv);
14482 int64_t __attribute__((visibility("default"))) TS_RouteHop_get_short_channel_id(uint32_t this_ptr) {
14483 LDKRouteHop this_ptr_conv;
14484 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14485 this_ptr_conv.is_owned = false;
14486 int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
14490 void __attribute__((visibility("default"))) TS_RouteHop_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14491 LDKRouteHop this_ptr_conv;
14492 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14493 this_ptr_conv.is_owned = false;
14494 RouteHop_set_short_channel_id(&this_ptr_conv, val);
14497 uint32_t __attribute__((visibility("default"))) TS_RouteHop_get_channel_features(uint32_t this_ptr) {
14498 LDKRouteHop this_ptr_conv;
14499 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14500 this_ptr_conv.is_owned = false;
14501 LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_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) {
14511 void __attribute__((visibility("default"))) TS_RouteHop_set_channel_features(uint32_t this_ptr, uint32_t val) {
14512 LDKRouteHop this_ptr_conv;
14513 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14514 this_ptr_conv.is_owned = false;
14515 LDKChannelFeatures val_conv;
14516 val_conv.inner = (void*)(val & (~1));
14517 val_conv.is_owned = (val & 1) || (val == 0);
14518 // Warning: we may need a move here but can't clone!
14519 RouteHop_set_channel_features(&this_ptr_conv, val_conv);
14522 int64_t __attribute__((visibility("default"))) TS_RouteHop_get_fee_msat(uint32_t this_ptr) {
14523 LDKRouteHop this_ptr_conv;
14524 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14525 this_ptr_conv.is_owned = false;
14526 int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
14530 void __attribute__((visibility("default"))) TS_RouteHop_set_fee_msat(uint32_t this_ptr, int64_t val) {
14531 LDKRouteHop this_ptr_conv;
14532 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14533 this_ptr_conv.is_owned = false;
14534 RouteHop_set_fee_msat(&this_ptr_conv, val);
14537 int32_t __attribute__((visibility("default"))) TS_RouteHop_get_cltv_expiry_delta(uint32_t this_ptr) {
14538 LDKRouteHop this_ptr_conv;
14539 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14540 this_ptr_conv.is_owned = false;
14541 int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
14545 void __attribute__((visibility("default"))) TS_RouteHop_set_cltv_expiry_delta(uint32_t this_ptr, int32_t val) {
14546 LDKRouteHop this_ptr_conv;
14547 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14548 this_ptr_conv.is_owned = false;
14549 RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
14552 uint32_t __attribute__((visibility("default"))) TS_RouteHop_new(int8_tArray pubkey_arg, uint32_t node_features_arg, int64_t short_channel_id_arg, uint32_t channel_features_arg, int64_t fee_msat_arg, int32_t cltv_expiry_delta_arg) {
14553 LDKPublicKey pubkey_arg_ref;
14554 CHECK(*((uint32_t*)pubkey_arg) == 33);
14555 memcpy(pubkey_arg_ref.compressed_form, (uint8_t*)(pubkey_arg + 4), 33);
14556 LDKNodeFeatures node_features_arg_conv;
14557 node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
14558 node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
14559 // Warning: we may need a move here but can't clone!
14560 LDKChannelFeatures channel_features_arg_conv;
14561 channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
14562 channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
14563 // Warning: we may need a move here but can't clone!
14564 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);
14565 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14566 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14567 long ret_ref = (long)ret_var.inner;
14568 if (ret_var.is_owned) {
14574 void __attribute__((visibility("default"))) TS_Route_free(uint32_t this_ptr) {
14575 LDKRoute this_ptr_conv;
14576 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14577 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14578 Route_free(this_ptr_conv);
14581 uint32_t __attribute__((visibility("default"))) TS_Route_clone(uint32_t orig) {
14582 LDKRoute orig_conv;
14583 orig_conv.inner = (void*)(orig & (~1));
14584 orig_conv.is_owned = false;
14585 LDKRoute ret_var = Route_clone(&orig_conv);
14586 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14587 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14588 long ret_ref = (long)ret_var.inner;
14589 if (ret_var.is_owned) {
14595 void __attribute__((visibility("default"))) TS_Route_set_paths(uint32_t this_ptr, ptrArray val) {
14596 LDKRoute this_ptr_conv;
14597 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14598 this_ptr_conv.is_owned = false;
14599 LDKCVec_CVec_RouteHopZZ val_constr;
14600 val_constr.datalen = *((uint32_t*)val);
14601 if (val_constr.datalen > 0)
14602 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14604 val_constr.data = NULL;
14605 uint32_tArray* val_vals = (uint32_tArray*)(val + 4);
14606 for (size_t m = 0; m < val_constr.datalen; m++) {
14607 uint32_tArray arr_conv_12 = val_vals[m];
14608 LDKCVec_RouteHopZ arr_conv_12_constr;
14609 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
14610 if (arr_conv_12_constr.datalen > 0)
14611 arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14613 arr_conv_12_constr.data = NULL;
14614 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
14615 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
14616 uint32_t arr_conv_10 = arr_conv_12_vals[k];
14617 LDKRouteHop arr_conv_10_conv;
14618 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
14619 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
14620 if (arr_conv_10_conv.inner != NULL)
14621 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
14622 arr_conv_12_constr.data[k] = arr_conv_10_conv;
14624 val_constr.data[m] = arr_conv_12_constr;
14626 Route_set_paths(&this_ptr_conv, val_constr);
14629 uint32_t __attribute__((visibility("default"))) TS_Route_new(ptrArray paths_arg) {
14630 LDKCVec_CVec_RouteHopZZ paths_arg_constr;
14631 paths_arg_constr.datalen = *((uint32_t*)paths_arg);
14632 if (paths_arg_constr.datalen > 0)
14633 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
14635 paths_arg_constr.data = NULL;
14636 uint32_tArray* paths_arg_vals = (uint32_tArray*)(paths_arg + 4);
14637 for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
14638 uint32_tArray arr_conv_12 = paths_arg_vals[m];
14639 LDKCVec_RouteHopZ arr_conv_12_constr;
14640 arr_conv_12_constr.datalen = *((uint32_t*)arr_conv_12);
14641 if (arr_conv_12_constr.datalen > 0)
14642 arr_conv_12_constr.data = MALLOC(arr_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
14644 arr_conv_12_constr.data = NULL;
14645 uint32_t* arr_conv_12_vals = (uint32_t*)(arr_conv_12 + 4);
14646 for (size_t k = 0; k < arr_conv_12_constr.datalen; k++) {
14647 uint32_t arr_conv_10 = arr_conv_12_vals[k];
14648 LDKRouteHop arr_conv_10_conv;
14649 arr_conv_10_conv.inner = (void*)(arr_conv_10 & (~1));
14650 arr_conv_10_conv.is_owned = (arr_conv_10 & 1) || (arr_conv_10 == 0);
14651 if (arr_conv_10_conv.inner != NULL)
14652 arr_conv_10_conv = RouteHop_clone(&arr_conv_10_conv);
14653 arr_conv_12_constr.data[k] = arr_conv_10_conv;
14655 paths_arg_constr.data[m] = arr_conv_12_constr;
14657 LDKRoute ret_var = Route_new(paths_arg_constr);
14658 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14659 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14660 long ret_ref = (long)ret_var.inner;
14661 if (ret_var.is_owned) {
14667 int8_tArray __attribute__((visibility("default"))) TS_Route_write(uint32_t obj) {
14669 obj_conv.inner = (void*)(obj & (~1));
14670 obj_conv.is_owned = false;
14671 LDKCVec_u8Z arg_var = Route_write(&obj_conv);
14672 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
14673 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
14674 CVec_u8Z_free(arg_var);
14678 uint32_t __attribute__((visibility("default"))) TS_Route_read(int8_tArray ser) {
14679 LDKu8slice ser_ref;
14680 ser_ref.datalen = *((uint32_t*)ser);
14681 ser_ref.data = (int8_t*)(ser + 4);
14682 LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
14683 *ret_conv = Route_read(ser_ref);
14684 return (long)ret_conv;
14687 void __attribute__((visibility("default"))) TS_RouteHint_free(uint32_t this_ptr) {
14688 LDKRouteHint this_ptr_conv;
14689 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14690 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14691 RouteHint_free(this_ptr_conv);
14694 uint32_t __attribute__((visibility("default"))) TS_RouteHint_clone(uint32_t orig) {
14695 LDKRouteHint orig_conv;
14696 orig_conv.inner = (void*)(orig & (~1));
14697 orig_conv.is_owned = false;
14698 LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
14699 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14700 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14701 long ret_ref = (long)ret_var.inner;
14702 if (ret_var.is_owned) {
14708 int8_tArray __attribute__((visibility("default"))) TS_RouteHint_get_src_node_id(uint32_t this_ptr) {
14709 LDKRouteHint this_ptr_conv;
14710 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14711 this_ptr_conv.is_owned = false;
14712 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
14713 memcpy((uint8_t*)(arg_arr + 4), RouteHint_get_src_node_id(&this_ptr_conv).compressed_form, 33);
14717 void __attribute__((visibility("default"))) TS_RouteHint_set_src_node_id(uint32_t this_ptr, int8_tArray val) {
14718 LDKRouteHint this_ptr_conv;
14719 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14720 this_ptr_conv.is_owned = false;
14721 LDKPublicKey val_ref;
14722 CHECK(*((uint32_t*)val) == 33);
14723 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
14724 RouteHint_set_src_node_id(&this_ptr_conv, val_ref);
14727 int64_t __attribute__((visibility("default"))) TS_RouteHint_get_short_channel_id(uint32_t this_ptr) {
14728 LDKRouteHint this_ptr_conv;
14729 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14730 this_ptr_conv.is_owned = false;
14731 int64_t ret_val = RouteHint_get_short_channel_id(&this_ptr_conv);
14735 void __attribute__((visibility("default"))) TS_RouteHint_set_short_channel_id(uint32_t this_ptr, int64_t val) {
14736 LDKRouteHint this_ptr_conv;
14737 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14738 this_ptr_conv.is_owned = false;
14739 RouteHint_set_short_channel_id(&this_ptr_conv, val);
14742 uint32_t __attribute__((visibility("default"))) TS_RouteHint_get_fees(uint32_t this_ptr) {
14743 LDKRouteHint this_ptr_conv;
14744 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14745 this_ptr_conv.is_owned = false;
14746 LDKRoutingFees ret_var = RouteHint_get_fees(&this_ptr_conv);
14747 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14748 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14749 long ret_ref = (long)ret_var.inner;
14750 if (ret_var.is_owned) {
14756 void __attribute__((visibility("default"))) TS_RouteHint_set_fees(uint32_t this_ptr, uint32_t val) {
14757 LDKRouteHint this_ptr_conv;
14758 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14759 this_ptr_conv.is_owned = false;
14760 LDKRoutingFees val_conv;
14761 val_conv.inner = (void*)(val & (~1));
14762 val_conv.is_owned = (val & 1) || (val == 0);
14763 if (val_conv.inner != NULL)
14764 val_conv = RoutingFees_clone(&val_conv);
14765 RouteHint_set_fees(&this_ptr_conv, val_conv);
14768 int16_t __attribute__((visibility("default"))) TS_RouteHint_get_cltv_expiry_delta(uint32_t this_ptr) {
14769 LDKRouteHint this_ptr_conv;
14770 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14771 this_ptr_conv.is_owned = false;
14772 int16_t ret_val = RouteHint_get_cltv_expiry_delta(&this_ptr_conv);
14776 void __attribute__((visibility("default"))) TS_RouteHint_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
14777 LDKRouteHint this_ptr_conv;
14778 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14779 this_ptr_conv.is_owned = false;
14780 RouteHint_set_cltv_expiry_delta(&this_ptr_conv, val);
14783 int64_t __attribute__((visibility("default"))) TS_RouteHint_get_htlc_minimum_msat(uint32_t this_ptr) {
14784 LDKRouteHint this_ptr_conv;
14785 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14786 this_ptr_conv.is_owned = false;
14787 int64_t ret_val = RouteHint_get_htlc_minimum_msat(&this_ptr_conv);
14791 void __attribute__((visibility("default"))) TS_RouteHint_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
14792 LDKRouteHint this_ptr_conv;
14793 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14794 this_ptr_conv.is_owned = false;
14795 RouteHint_set_htlc_minimum_msat(&this_ptr_conv, val);
14798 uint32_t __attribute__((visibility("default"))) TS_RouteHint_new(int8_tArray src_node_id_arg, int64_t short_channel_id_arg, uint32_t fees_arg, int16_t cltv_expiry_delta_arg, int64_t htlc_minimum_msat_arg) {
14799 LDKPublicKey src_node_id_arg_ref;
14800 CHECK(*((uint32_t*)src_node_id_arg) == 33);
14801 memcpy(src_node_id_arg_ref.compressed_form, (uint8_t*)(src_node_id_arg + 4), 33);
14802 LDKRoutingFees fees_arg_conv;
14803 fees_arg_conv.inner = (void*)(fees_arg & (~1));
14804 fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
14805 if (fees_arg_conv.inner != NULL)
14806 fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
14807 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);
14808 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14809 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14810 long ret_ref = (long)ret_var.inner;
14811 if (ret_var.is_owned) {
14817 uint32_t __attribute__((visibility("default"))) TS_get_route(int8_tArray our_node_id, uint32_t network, int8_tArray target, uint32_tArray first_hops, uint32_tArray last_hops, int64_t final_value_msat, int32_t final_cltv, uint32_t logger) {
14818 LDKPublicKey our_node_id_ref;
14819 CHECK(*((uint32_t*)our_node_id) == 33);
14820 memcpy(our_node_id_ref.compressed_form, (uint8_t*)(our_node_id + 4), 33);
14821 LDKNetworkGraph network_conv;
14822 network_conv.inner = (void*)(network & (~1));
14823 network_conv.is_owned = false;
14824 LDKPublicKey target_ref;
14825 CHECK(*((uint32_t*)target) == 33);
14826 memcpy(target_ref.compressed_form, (uint8_t*)(target + 4), 33);
14827 LDKCVec_ChannelDetailsZ first_hops_constr;
14828 first_hops_constr.datalen = *((uint32_t*)first_hops);
14829 if (first_hops_constr.datalen > 0)
14830 first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
14832 first_hops_constr.data = NULL;
14833 uint32_t* first_hops_vals = (uint32_t*)(first_hops + 4);
14834 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
14835 uint32_t arr_conv_16 = first_hops_vals[q];
14836 LDKChannelDetails arr_conv_16_conv;
14837 arr_conv_16_conv.inner = (void*)(arr_conv_16 & (~1));
14838 arr_conv_16_conv.is_owned = (arr_conv_16 & 1) || (arr_conv_16 == 0);
14839 first_hops_constr.data[q] = arr_conv_16_conv;
14841 LDKCVec_RouteHintZ last_hops_constr;
14842 last_hops_constr.datalen = *((uint32_t*)last_hops);
14843 if (last_hops_constr.datalen > 0)
14844 last_hops_constr.data = MALLOC(last_hops_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
14846 last_hops_constr.data = NULL;
14847 uint32_t* last_hops_vals = (uint32_t*)(last_hops + 4);
14848 for (size_t l = 0; l < last_hops_constr.datalen; l++) {
14849 uint32_t arr_conv_11 = last_hops_vals[l];
14850 LDKRouteHint arr_conv_11_conv;
14851 arr_conv_11_conv.inner = (void*)(arr_conv_11 & (~1));
14852 arr_conv_11_conv.is_owned = (arr_conv_11 & 1) || (arr_conv_11 == 0);
14853 if (arr_conv_11_conv.inner != NULL)
14854 arr_conv_11_conv = RouteHint_clone(&arr_conv_11_conv);
14855 last_hops_constr.data[l] = arr_conv_11_conv;
14857 LDKLogger logger_conv = *(LDKLogger*)logger;
14858 LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
14859 *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);
14860 FREE(first_hops_constr.data);
14861 return (long)ret_conv;
14864 void __attribute__((visibility("default"))) TS_NetworkGraph_free(uint32_t this_ptr) {
14865 LDKNetworkGraph this_ptr_conv;
14866 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14867 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14868 NetworkGraph_free(this_ptr_conv);
14871 void __attribute__((visibility("default"))) TS_LockedNetworkGraph_free(uint32_t this_ptr) {
14872 LDKLockedNetworkGraph this_ptr_conv;
14873 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14874 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14875 LockedNetworkGraph_free(this_ptr_conv);
14878 void __attribute__((visibility("default"))) TS_NetGraphMsgHandler_free(uint32_t this_ptr) {
14879 LDKNetGraphMsgHandler this_ptr_conv;
14880 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14881 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14882 NetGraphMsgHandler_free(this_ptr_conv);
14885 uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_new(int8_tArray genesis_hash, uint32_t chain_access, uint32_t logger) {
14886 LDKThirtyTwoBytes genesis_hash_ref;
14887 CHECK(*((uint32_t*)genesis_hash) == 32);
14888 memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
14889 LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14890 LDKLogger logger_conv = *(LDKLogger*)logger;
14891 LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(genesis_hash_ref, chain_access_conv, logger_conv);
14892 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14893 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14894 long ret_ref = (long)ret_var.inner;
14895 if (ret_var.is_owned) {
14901 uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_from_net_graph(uint32_t chain_access, uint32_t logger, uint32_t network_graph) {
14902 LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
14903 LDKLogger logger_conv = *(LDKLogger*)logger;
14904 LDKNetworkGraph network_graph_conv;
14905 network_graph_conv.inner = (void*)(network_graph & (~1));
14906 network_graph_conv.is_owned = (network_graph & 1) || (network_graph == 0);
14907 // Warning: we may need a move here but can't clone!
14908 LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_from_net_graph(chain_access_conv, logger_conv, network_graph_conv);
14909 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14910 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14911 long ret_ref = (long)ret_var.inner;
14912 if (ret_var.is_owned) {
14918 uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_read_locked_graph(uint32_t this_arg) {
14919 LDKNetGraphMsgHandler this_arg_conv;
14920 this_arg_conv.inner = (void*)(this_arg & (~1));
14921 this_arg_conv.is_owned = false;
14922 LDKLockedNetworkGraph ret_var = NetGraphMsgHandler_read_locked_graph(&this_arg_conv);
14923 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14924 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14925 long ret_ref = (long)ret_var.inner;
14926 if (ret_var.is_owned) {
14932 uint32_t __attribute__((visibility("default"))) TS_LockedNetworkGraph_graph(uint32_t this_arg) {
14933 LDKLockedNetworkGraph this_arg_conv;
14934 this_arg_conv.inner = (void*)(this_arg & (~1));
14935 this_arg_conv.is_owned = false;
14936 LDKNetworkGraph ret_var = LockedNetworkGraph_graph(&this_arg_conv);
14937 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
14938 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
14939 long ret_ref = (long)ret_var.inner;
14940 if (ret_var.is_owned) {
14946 uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_RoutingMessageHandler(uint32_t this_arg) {
14947 LDKNetGraphMsgHandler this_arg_conv;
14948 this_arg_conv.inner = (void*)(this_arg & (~1));
14949 this_arg_conv.is_owned = false;
14950 LDKRoutingMessageHandler* ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
14951 *ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
14955 uint32_t __attribute__((visibility("default"))) TS_NetGraphMsgHandler_as_MessageSendEventsProvider(uint32_t this_arg) {
14956 LDKNetGraphMsgHandler this_arg_conv;
14957 this_arg_conv.inner = (void*)(this_arg & (~1));
14958 this_arg_conv.is_owned = false;
14959 LDKMessageSendEventsProvider* ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
14960 *ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
14964 void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_free(uint32_t this_ptr) {
14965 LDKDirectionalChannelInfo this_ptr_conv;
14966 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14967 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
14968 DirectionalChannelInfo_free(this_ptr_conv);
14971 int32_t __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update(uint32_t this_ptr) {
14972 LDKDirectionalChannelInfo this_ptr_conv;
14973 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14974 this_ptr_conv.is_owned = false;
14975 int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
14979 void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update(uint32_t this_ptr, int32_t val) {
14980 LDKDirectionalChannelInfo this_ptr_conv;
14981 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14982 this_ptr_conv.is_owned = false;
14983 DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
14986 jboolean __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_enabled(uint32_t this_ptr) {
14987 LDKDirectionalChannelInfo this_ptr_conv;
14988 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14989 this_ptr_conv.is_owned = false;
14990 jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
14994 void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_enabled(uint32_t this_ptr, jboolean val) {
14995 LDKDirectionalChannelInfo this_ptr_conv;
14996 this_ptr_conv.inner = (void*)(this_ptr & (~1));
14997 this_ptr_conv.is_owned = false;
14998 DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
15001 int16_t __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_cltv_expiry_delta(uint32_t this_ptr) {
15002 LDKDirectionalChannelInfo this_ptr_conv;
15003 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15004 this_ptr_conv.is_owned = false;
15005 int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
15009 void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_cltv_expiry_delta(uint32_t this_ptr, int16_t val) {
15010 LDKDirectionalChannelInfo this_ptr_conv;
15011 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15012 this_ptr_conv.is_owned = false;
15013 DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
15016 int64_t __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_htlc_minimum_msat(uint32_t this_ptr) {
15017 LDKDirectionalChannelInfo this_ptr_conv;
15018 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15019 this_ptr_conv.is_owned = false;
15020 int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
15024 void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_htlc_minimum_msat(uint32_t this_ptr, int64_t val) {
15025 LDKDirectionalChannelInfo this_ptr_conv;
15026 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15027 this_ptr_conv.is_owned = false;
15028 DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
15031 uint32_t __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_fees(uint32_t this_ptr) {
15032 LDKDirectionalChannelInfo this_ptr_conv;
15033 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15034 this_ptr_conv.is_owned = false;
15035 LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
15036 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15037 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15038 long ret_ref = (long)ret_var.inner;
15039 if (ret_var.is_owned) {
15045 void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_fees(uint32_t this_ptr, uint32_t val) {
15046 LDKDirectionalChannelInfo this_ptr_conv;
15047 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15048 this_ptr_conv.is_owned = false;
15049 LDKRoutingFees val_conv;
15050 val_conv.inner = (void*)(val & (~1));
15051 val_conv.is_owned = (val & 1) || (val == 0);
15052 if (val_conv.inner != NULL)
15053 val_conv = RoutingFees_clone(&val_conv);
15054 DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
15057 uint32_t __attribute__((visibility("default"))) TS_DirectionalChannelInfo_get_last_update_message(uint32_t this_ptr) {
15058 LDKDirectionalChannelInfo this_ptr_conv;
15059 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15060 this_ptr_conv.is_owned = false;
15061 LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
15062 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15063 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15064 long ret_ref = (long)ret_var.inner;
15065 if (ret_var.is_owned) {
15071 void __attribute__((visibility("default"))) TS_DirectionalChannelInfo_set_last_update_message(uint32_t this_ptr, uint32_t val) {
15072 LDKDirectionalChannelInfo this_ptr_conv;
15073 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15074 this_ptr_conv.is_owned = false;
15075 LDKChannelUpdate val_conv;
15076 val_conv.inner = (void*)(val & (~1));
15077 val_conv.is_owned = (val & 1) || (val == 0);
15078 if (val_conv.inner != NULL)
15079 val_conv = ChannelUpdate_clone(&val_conv);
15080 DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
15083 int8_tArray __attribute__((visibility("default"))) TS_DirectionalChannelInfo_write(uint32_t obj) {
15084 LDKDirectionalChannelInfo obj_conv;
15085 obj_conv.inner = (void*)(obj & (~1));
15086 obj_conv.is_owned = false;
15087 LDKCVec_u8Z arg_var = DirectionalChannelInfo_write(&obj_conv);
15088 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15089 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15090 CVec_u8Z_free(arg_var);
15094 uint32_t __attribute__((visibility("default"))) TS_DirectionalChannelInfo_read(int8_tArray ser) {
15095 LDKu8slice ser_ref;
15096 ser_ref.datalen = *((uint32_t*)ser);
15097 ser_ref.data = (int8_t*)(ser + 4);
15098 LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_read(ser_ref);
15099 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15100 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15101 long ret_ref = (long)ret_var.inner;
15102 if (ret_var.is_owned) {
15108 void __attribute__((visibility("default"))) TS_ChannelInfo_free(uint32_t this_ptr) {
15109 LDKChannelInfo this_ptr_conv;
15110 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15111 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15112 ChannelInfo_free(this_ptr_conv);
15115 uint32_t __attribute__((visibility("default"))) TS_ChannelInfo_get_features(uint32_t this_ptr) {
15116 LDKChannelInfo this_ptr_conv;
15117 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15118 this_ptr_conv.is_owned = false;
15119 LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
15120 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15121 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15122 long ret_ref = (long)ret_var.inner;
15123 if (ret_var.is_owned) {
15129 void __attribute__((visibility("default"))) TS_ChannelInfo_set_features(uint32_t this_ptr, uint32_t val) {
15130 LDKChannelInfo this_ptr_conv;
15131 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15132 this_ptr_conv.is_owned = false;
15133 LDKChannelFeatures val_conv;
15134 val_conv.inner = (void*)(val & (~1));
15135 val_conv.is_owned = (val & 1) || (val == 0);
15136 // Warning: we may need a move here but can't clone!
15137 ChannelInfo_set_features(&this_ptr_conv, val_conv);
15140 int8_tArray __attribute__((visibility("default"))) TS_ChannelInfo_get_node_one(uint32_t this_ptr) {
15141 LDKChannelInfo this_ptr_conv;
15142 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15143 this_ptr_conv.is_owned = false;
15144 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15145 memcpy((uint8_t*)(arg_arr + 4), ChannelInfo_get_node_one(&this_ptr_conv).compressed_form, 33);
15149 void __attribute__((visibility("default"))) TS_ChannelInfo_set_node_one(uint32_t this_ptr, int8_tArray val) {
15150 LDKChannelInfo this_ptr_conv;
15151 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15152 this_ptr_conv.is_owned = false;
15153 LDKPublicKey val_ref;
15154 CHECK(*((uint32_t*)val) == 33);
15155 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15156 ChannelInfo_set_node_one(&this_ptr_conv, val_ref);
15159 uint32_t __attribute__((visibility("default"))) TS_ChannelInfo_get_one_to_two(uint32_t this_ptr) {
15160 LDKChannelInfo this_ptr_conv;
15161 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15162 this_ptr_conv.is_owned = false;
15163 LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
15164 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15165 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15166 long ret_ref = (long)ret_var.inner;
15167 if (ret_var.is_owned) {
15173 void __attribute__((visibility("default"))) TS_ChannelInfo_set_one_to_two(uint32_t this_ptr, uint32_t val) {
15174 LDKChannelInfo this_ptr_conv;
15175 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15176 this_ptr_conv.is_owned = false;
15177 LDKDirectionalChannelInfo val_conv;
15178 val_conv.inner = (void*)(val & (~1));
15179 val_conv.is_owned = (val & 1) || (val == 0);
15180 // Warning: we may need a move here but can't clone!
15181 ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
15184 int8_tArray __attribute__((visibility("default"))) TS_ChannelInfo_get_node_two(uint32_t this_ptr) {
15185 LDKChannelInfo this_ptr_conv;
15186 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15187 this_ptr_conv.is_owned = false;
15188 int8_tArray arg_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
15189 memcpy((uint8_t*)(arg_arr + 4), ChannelInfo_get_node_two(&this_ptr_conv).compressed_form, 33);
15193 void __attribute__((visibility("default"))) TS_ChannelInfo_set_node_two(uint32_t this_ptr, int8_tArray val) {
15194 LDKChannelInfo this_ptr_conv;
15195 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15196 this_ptr_conv.is_owned = false;
15197 LDKPublicKey val_ref;
15198 CHECK(*((uint32_t*)val) == 33);
15199 memcpy(val_ref.compressed_form, (uint8_t*)(val + 4), 33);
15200 ChannelInfo_set_node_two(&this_ptr_conv, val_ref);
15203 uint32_t __attribute__((visibility("default"))) TS_ChannelInfo_get_two_to_one(uint32_t this_ptr) {
15204 LDKChannelInfo this_ptr_conv;
15205 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15206 this_ptr_conv.is_owned = false;
15207 LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
15208 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15209 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15210 long ret_ref = (long)ret_var.inner;
15211 if (ret_var.is_owned) {
15217 void __attribute__((visibility("default"))) TS_ChannelInfo_set_two_to_one(uint32_t this_ptr, uint32_t val) {
15218 LDKChannelInfo this_ptr_conv;
15219 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15220 this_ptr_conv.is_owned = false;
15221 LDKDirectionalChannelInfo val_conv;
15222 val_conv.inner = (void*)(val & (~1));
15223 val_conv.is_owned = (val & 1) || (val == 0);
15224 // Warning: we may need a move here but can't clone!
15225 ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
15228 uint32_t __attribute__((visibility("default"))) TS_ChannelInfo_get_announcement_message(uint32_t this_ptr) {
15229 LDKChannelInfo this_ptr_conv;
15230 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15231 this_ptr_conv.is_owned = false;
15232 LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
15233 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15234 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15235 long ret_ref = (long)ret_var.inner;
15236 if (ret_var.is_owned) {
15242 void __attribute__((visibility("default"))) TS_ChannelInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
15243 LDKChannelInfo this_ptr_conv;
15244 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15245 this_ptr_conv.is_owned = false;
15246 LDKChannelAnnouncement val_conv;
15247 val_conv.inner = (void*)(val & (~1));
15248 val_conv.is_owned = (val & 1) || (val == 0);
15249 if (val_conv.inner != NULL)
15250 val_conv = ChannelAnnouncement_clone(&val_conv);
15251 ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
15254 int8_tArray __attribute__((visibility("default"))) TS_ChannelInfo_write(uint32_t obj) {
15255 LDKChannelInfo obj_conv;
15256 obj_conv.inner = (void*)(obj & (~1));
15257 obj_conv.is_owned = false;
15258 LDKCVec_u8Z arg_var = ChannelInfo_write(&obj_conv);
15259 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15260 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15261 CVec_u8Z_free(arg_var);
15265 uint32_t __attribute__((visibility("default"))) TS_ChannelInfo_read(int8_tArray ser) {
15266 LDKu8slice ser_ref;
15267 ser_ref.datalen = *((uint32_t*)ser);
15268 ser_ref.data = (int8_t*)(ser + 4);
15269 LDKChannelInfo ret_var = ChannelInfo_read(ser_ref);
15270 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15271 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15272 long ret_ref = (long)ret_var.inner;
15273 if (ret_var.is_owned) {
15279 void __attribute__((visibility("default"))) TS_RoutingFees_free(uint32_t this_ptr) {
15280 LDKRoutingFees this_ptr_conv;
15281 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15282 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15283 RoutingFees_free(this_ptr_conv);
15286 uint32_t __attribute__((visibility("default"))) TS_RoutingFees_clone(uint32_t orig) {
15287 LDKRoutingFees orig_conv;
15288 orig_conv.inner = (void*)(orig & (~1));
15289 orig_conv.is_owned = false;
15290 LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
15291 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15292 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15293 long ret_ref = (long)ret_var.inner;
15294 if (ret_var.is_owned) {
15300 int32_t __attribute__((visibility("default"))) TS_RoutingFees_get_base_msat(uint32_t this_ptr) {
15301 LDKRoutingFees this_ptr_conv;
15302 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15303 this_ptr_conv.is_owned = false;
15304 int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
15308 void __attribute__((visibility("default"))) TS_RoutingFees_set_base_msat(uint32_t this_ptr, int32_t val) {
15309 LDKRoutingFees this_ptr_conv;
15310 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15311 this_ptr_conv.is_owned = false;
15312 RoutingFees_set_base_msat(&this_ptr_conv, val);
15315 int32_t __attribute__((visibility("default"))) TS_RoutingFees_get_proportional_millionths(uint32_t this_ptr) {
15316 LDKRoutingFees this_ptr_conv;
15317 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15318 this_ptr_conv.is_owned = false;
15319 int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
15323 void __attribute__((visibility("default"))) TS_RoutingFees_set_proportional_millionths(uint32_t this_ptr, int32_t val) {
15324 LDKRoutingFees this_ptr_conv;
15325 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15326 this_ptr_conv.is_owned = false;
15327 RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
15330 uint32_t __attribute__((visibility("default"))) TS_RoutingFees_new(int32_t base_msat_arg, int32_t proportional_millionths_arg) {
15331 LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
15332 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15333 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15334 long ret_ref = (long)ret_var.inner;
15335 if (ret_var.is_owned) {
15341 uint32_t __attribute__((visibility("default"))) TS_RoutingFees_read(int8_tArray ser) {
15342 LDKu8slice ser_ref;
15343 ser_ref.datalen = *((uint32_t*)ser);
15344 ser_ref.data = (int8_t*)(ser + 4);
15345 LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
15346 *ret_conv = RoutingFees_read(ser_ref);
15347 return (long)ret_conv;
15350 int8_tArray __attribute__((visibility("default"))) TS_RoutingFees_write(uint32_t obj) {
15351 LDKRoutingFees obj_conv;
15352 obj_conv.inner = (void*)(obj & (~1));
15353 obj_conv.is_owned = false;
15354 LDKCVec_u8Z arg_var = RoutingFees_write(&obj_conv);
15355 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15356 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15357 CVec_u8Z_free(arg_var);
15361 void __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_free(uint32_t this_ptr) {
15362 LDKNodeAnnouncementInfo this_ptr_conv;
15363 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15364 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15365 NodeAnnouncementInfo_free(this_ptr_conv);
15368 uint32_t __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_features(uint32_t this_ptr) {
15369 LDKNodeAnnouncementInfo this_ptr_conv;
15370 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15371 this_ptr_conv.is_owned = false;
15372 LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
15373 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15374 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15375 long ret_ref = (long)ret_var.inner;
15376 if (ret_var.is_owned) {
15382 void __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_features(uint32_t this_ptr, uint32_t val) {
15383 LDKNodeAnnouncementInfo this_ptr_conv;
15384 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15385 this_ptr_conv.is_owned = false;
15386 LDKNodeFeatures val_conv;
15387 val_conv.inner = (void*)(val & (~1));
15388 val_conv.is_owned = (val & 1) || (val == 0);
15389 // Warning: we may need a move here but can't clone!
15390 NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
15393 int32_t __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_last_update(uint32_t this_ptr) {
15394 LDKNodeAnnouncementInfo this_ptr_conv;
15395 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15396 this_ptr_conv.is_owned = false;
15397 int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
15401 void __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_last_update(uint32_t this_ptr, int32_t val) {
15402 LDKNodeAnnouncementInfo this_ptr_conv;
15403 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15404 this_ptr_conv.is_owned = false;
15405 NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
15408 int8_tArray __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_rgb(uint32_t this_ptr) {
15409 LDKNodeAnnouncementInfo this_ptr_conv;
15410 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15411 this_ptr_conv.is_owned = false;
15412 int8_tArray ret_arr = init_arr(3, sizeof(uint8_t), "Native int8_tArray Bytes");
15413 memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_rgb(&this_ptr_conv), 3);
15417 void __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_rgb(uint32_t this_ptr, int8_tArray val) {
15418 LDKNodeAnnouncementInfo this_ptr_conv;
15419 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15420 this_ptr_conv.is_owned = false;
15421 LDKThreeBytes val_ref;
15422 CHECK(*((uint32_t*)val) == 3);
15423 memcpy(val_ref.data, (uint8_t*)(val + 4), 3);
15424 NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
15427 int8_tArray __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_alias(uint32_t this_ptr) {
15428 LDKNodeAnnouncementInfo this_ptr_conv;
15429 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15430 this_ptr_conv.is_owned = false;
15431 int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
15432 memcpy((uint8_t*)(ret_arr + 4), *NodeAnnouncementInfo_get_alias(&this_ptr_conv), 32);
15436 void __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_alias(uint32_t this_ptr, int8_tArray val) {
15437 LDKNodeAnnouncementInfo this_ptr_conv;
15438 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15439 this_ptr_conv.is_owned = false;
15440 LDKThirtyTwoBytes val_ref;
15441 CHECK(*((uint32_t*)val) == 32);
15442 memcpy(val_ref.data, (uint8_t*)(val + 4), 32);
15443 NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
15446 void __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_addresses(uint32_t this_ptr, uint32_tArray val) {
15447 LDKNodeAnnouncementInfo this_ptr_conv;
15448 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15449 this_ptr_conv.is_owned = false;
15450 LDKCVec_NetAddressZ val_constr;
15451 val_constr.datalen = *((uint32_t*)val);
15452 if (val_constr.datalen > 0)
15453 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15455 val_constr.data = NULL;
15456 uint32_t* val_vals = (uint32_t*)(val + 4);
15457 for (size_t m = 0; m < val_constr.datalen; m++) {
15458 uint32_t arr_conv_12 = val_vals[m];
15459 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
15460 FREE((void*)arr_conv_12);
15461 val_constr.data[m] = arr_conv_12_conv;
15463 NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
15466 uint32_t __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_get_announcement_message(uint32_t this_ptr) {
15467 LDKNodeAnnouncementInfo this_ptr_conv;
15468 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15469 this_ptr_conv.is_owned = false;
15470 LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
15471 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15472 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15473 long ret_ref = (long)ret_var.inner;
15474 if (ret_var.is_owned) {
15480 void __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_set_announcement_message(uint32_t this_ptr, uint32_t val) {
15481 LDKNodeAnnouncementInfo this_ptr_conv;
15482 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15483 this_ptr_conv.is_owned = false;
15484 LDKNodeAnnouncement val_conv;
15485 val_conv.inner = (void*)(val & (~1));
15486 val_conv.is_owned = (val & 1) || (val == 0);
15487 if (val_conv.inner != NULL)
15488 val_conv = NodeAnnouncement_clone(&val_conv);
15489 NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
15492 uint32_t __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_new(uint32_t features_arg, int32_t last_update_arg, int8_tArray rgb_arg, int8_tArray alias_arg, uint32_tArray addresses_arg, uint32_t announcement_message_arg) {
15493 LDKNodeFeatures features_arg_conv;
15494 features_arg_conv.inner = (void*)(features_arg & (~1));
15495 features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
15496 // Warning: we may need a move here but can't clone!
15497 LDKThreeBytes rgb_arg_ref;
15498 CHECK(*((uint32_t*)rgb_arg) == 3);
15499 memcpy(rgb_arg_ref.data, (uint8_t*)(rgb_arg + 4), 3);
15500 LDKThirtyTwoBytes alias_arg_ref;
15501 CHECK(*((uint32_t*)alias_arg) == 32);
15502 memcpy(alias_arg_ref.data, (uint8_t*)(alias_arg + 4), 32);
15503 LDKCVec_NetAddressZ addresses_arg_constr;
15504 addresses_arg_constr.datalen = *((uint32_t*)addresses_arg);
15505 if (addresses_arg_constr.datalen > 0)
15506 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
15508 addresses_arg_constr.data = NULL;
15509 uint32_t* addresses_arg_vals = (uint32_t*)(addresses_arg + 4);
15510 for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
15511 uint32_t arr_conv_12 = addresses_arg_vals[m];
15512 LDKNetAddress arr_conv_12_conv = *(LDKNetAddress*)arr_conv_12;
15513 FREE((void*)arr_conv_12);
15514 addresses_arg_constr.data[m] = arr_conv_12_conv;
15516 LDKNodeAnnouncement announcement_message_arg_conv;
15517 announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
15518 announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
15519 if (announcement_message_arg_conv.inner != NULL)
15520 announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
15521 LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
15522 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15523 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15524 long ret_ref = (long)ret_var.inner;
15525 if (ret_var.is_owned) {
15531 int8_tArray __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_write(uint32_t obj) {
15532 LDKNodeAnnouncementInfo obj_conv;
15533 obj_conv.inner = (void*)(obj & (~1));
15534 obj_conv.is_owned = false;
15535 LDKCVec_u8Z arg_var = NodeAnnouncementInfo_write(&obj_conv);
15536 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15537 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15538 CVec_u8Z_free(arg_var);
15542 uint32_t __attribute__((visibility("default"))) TS_NodeAnnouncementInfo_read(int8_tArray ser) {
15543 LDKu8slice ser_ref;
15544 ser_ref.datalen = *((uint32_t*)ser);
15545 ser_ref.data = (int8_t*)(ser + 4);
15546 LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
15547 *ret_conv = NodeAnnouncementInfo_read(ser_ref);
15548 return (long)ret_conv;
15551 void __attribute__((visibility("default"))) TS_NodeInfo_free(uint32_t this_ptr) {
15552 LDKNodeInfo this_ptr_conv;
15553 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15554 this_ptr_conv.is_owned = (this_ptr & 1) || (this_ptr == 0);
15555 NodeInfo_free(this_ptr_conv);
15558 void __attribute__((visibility("default"))) TS_NodeInfo_set_channels(uint32_t this_ptr, int64_tArray val) {
15559 LDKNodeInfo this_ptr_conv;
15560 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15561 this_ptr_conv.is_owned = false;
15562 LDKCVec_u64Z val_constr;
15563 val_constr.datalen = *((uint32_t*)val);
15564 if (val_constr.datalen > 0)
15565 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15567 val_constr.data = NULL;
15568 int64_t* val_vals = (int64_t*)(val + 4);
15569 for (size_t i = 0; i < val_constr.datalen; i++) {
15570 int64_t arr_conv_8 = val_vals[i];
15571 val_constr.data[i] = arr_conv_8;
15573 NodeInfo_set_channels(&this_ptr_conv, val_constr);
15576 uint32_t __attribute__((visibility("default"))) TS_NodeInfo_get_lowest_inbound_channel_fees(uint32_t this_ptr) {
15577 LDKNodeInfo this_ptr_conv;
15578 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15579 this_ptr_conv.is_owned = false;
15580 LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
15581 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15582 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15583 long ret_ref = (long)ret_var.inner;
15584 if (ret_var.is_owned) {
15590 void __attribute__((visibility("default"))) TS_NodeInfo_set_lowest_inbound_channel_fees(uint32_t this_ptr, uint32_t val) {
15591 LDKNodeInfo this_ptr_conv;
15592 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15593 this_ptr_conv.is_owned = false;
15594 LDKRoutingFees val_conv;
15595 val_conv.inner = (void*)(val & (~1));
15596 val_conv.is_owned = (val & 1) || (val == 0);
15597 if (val_conv.inner != NULL)
15598 val_conv = RoutingFees_clone(&val_conv);
15599 NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
15602 uint32_t __attribute__((visibility("default"))) TS_NodeInfo_get_announcement_info(uint32_t this_ptr) {
15603 LDKNodeInfo this_ptr_conv;
15604 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15605 this_ptr_conv.is_owned = false;
15606 LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
15607 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15608 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15609 long ret_ref = (long)ret_var.inner;
15610 if (ret_var.is_owned) {
15616 void __attribute__((visibility("default"))) TS_NodeInfo_set_announcement_info(uint32_t this_ptr, uint32_t val) {
15617 LDKNodeInfo this_ptr_conv;
15618 this_ptr_conv.inner = (void*)(this_ptr & (~1));
15619 this_ptr_conv.is_owned = false;
15620 LDKNodeAnnouncementInfo val_conv;
15621 val_conv.inner = (void*)(val & (~1));
15622 val_conv.is_owned = (val & 1) || (val == 0);
15623 // Warning: we may need a move here but can't clone!
15624 NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
15627 uint32_t __attribute__((visibility("default"))) TS_NodeInfo_new(int64_tArray channels_arg, uint32_t lowest_inbound_channel_fees_arg, uint32_t announcement_info_arg) {
15628 LDKCVec_u64Z channels_arg_constr;
15629 channels_arg_constr.datalen = *((uint32_t*)channels_arg);
15630 if (channels_arg_constr.datalen > 0)
15631 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
15633 channels_arg_constr.data = NULL;
15634 int64_t* channels_arg_vals = (int64_t*)(channels_arg + 4);
15635 for (size_t i = 0; i < channels_arg_constr.datalen; i++) {
15636 int64_t arr_conv_8 = channels_arg_vals[i];
15637 channels_arg_constr.data[i] = arr_conv_8;
15639 LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
15640 lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
15641 lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
15642 if (lowest_inbound_channel_fees_arg_conv.inner != NULL)
15643 lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
15644 LDKNodeAnnouncementInfo announcement_info_arg_conv;
15645 announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
15646 announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
15647 // Warning: we may need a move here but can't clone!
15648 LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
15649 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15650 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15651 long ret_ref = (long)ret_var.inner;
15652 if (ret_var.is_owned) {
15658 int8_tArray __attribute__((visibility("default"))) TS_NodeInfo_write(uint32_t obj) {
15659 LDKNodeInfo obj_conv;
15660 obj_conv.inner = (void*)(obj & (~1));
15661 obj_conv.is_owned = false;
15662 LDKCVec_u8Z arg_var = NodeInfo_write(&obj_conv);
15663 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15664 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15665 CVec_u8Z_free(arg_var);
15669 uint32_t __attribute__((visibility("default"))) TS_NodeInfo_read(int8_tArray ser) {
15670 LDKu8slice ser_ref;
15671 ser_ref.datalen = *((uint32_t*)ser);
15672 ser_ref.data = (int8_t*)(ser + 4);
15673 LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
15674 *ret_conv = NodeInfo_read(ser_ref);
15675 return (long)ret_conv;
15678 int8_tArray __attribute__((visibility("default"))) TS_NetworkGraph_write(uint32_t obj) {
15679 LDKNetworkGraph obj_conv;
15680 obj_conv.inner = (void*)(obj & (~1));
15681 obj_conv.is_owned = false;
15682 LDKCVec_u8Z arg_var = NetworkGraph_write(&obj_conv);
15683 int8_tArray arg_arr = init_arr(arg_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
15684 memcpy((uint8_t*)(arg_arr + 4), arg_var.data, arg_var.datalen);
15685 CVec_u8Z_free(arg_var);
15689 uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_read(int8_tArray ser) {
15690 LDKu8slice ser_ref;
15691 ser_ref.datalen = *((uint32_t*)ser);
15692 ser_ref.data = (int8_t*)(ser + 4);
15693 LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
15694 *ret_conv = NetworkGraph_read(ser_ref);
15695 return (long)ret_conv;
15698 uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_new(int8_tArray genesis_hash) {
15699 LDKThirtyTwoBytes genesis_hash_ref;
15700 CHECK(*((uint32_t*)genesis_hash) == 32);
15701 memcpy(genesis_hash_ref.data, (uint8_t*)(genesis_hash + 4), 32);
15702 LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
15703 CHECK((((long)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
15704 CHECK((((long)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
15705 long ret_ref = (long)ret_var.inner;
15706 if (ret_var.is_owned) {
15712 uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_announcement(uint32_t this_arg, uint32_t msg) {
15713 LDKNetworkGraph this_arg_conv;
15714 this_arg_conv.inner = (void*)(this_arg & (~1));
15715 this_arg_conv.is_owned = false;
15716 LDKNodeAnnouncement msg_conv;
15717 msg_conv.inner = (void*)(msg & (~1));
15718 msg_conv.is_owned = false;
15719 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15720 *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
15721 return (long)ret_conv;
15724 uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_node_from_unsigned_announcement(uint32_t this_arg, uint32_t msg) {
15725 LDKNetworkGraph this_arg_conv;
15726 this_arg_conv.inner = (void*)(this_arg & (~1));
15727 this_arg_conv.is_owned = false;
15728 LDKUnsignedNodeAnnouncement msg_conv;
15729 msg_conv.inner = (void*)(msg & (~1));
15730 msg_conv.is_owned = false;
15731 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15732 *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
15733 return (long)ret_conv;
15736 uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
15737 LDKNetworkGraph this_arg_conv;
15738 this_arg_conv.inner = (void*)(this_arg & (~1));
15739 this_arg_conv.is_owned = false;
15740 LDKChannelAnnouncement msg_conv;
15741 msg_conv.inner = (void*)(msg & (~1));
15742 msg_conv.is_owned = false;
15743 LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
15744 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15745 *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
15746 return (long)ret_conv;
15749 uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_from_unsigned_announcement(uint32_t this_arg, uint32_t msg, uint32_t chain_access) {
15750 LDKNetworkGraph this_arg_conv;
15751 this_arg_conv.inner = (void*)(this_arg & (~1));
15752 this_arg_conv.is_owned = false;
15753 LDKUnsignedChannelAnnouncement msg_conv;
15754 msg_conv.inner = (void*)(msg & (~1));
15755 msg_conv.is_owned = false;
15756 LDKAccess* chain_access_conv = (LDKAccess*)chain_access;
15757 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15758 *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
15759 return (long)ret_conv;
15762 void __attribute__((visibility("default"))) TS_NetworkGraph_close_channel_from_update(uint32_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
15763 LDKNetworkGraph this_arg_conv;
15764 this_arg_conv.inner = (void*)(this_arg & (~1));
15765 this_arg_conv.is_owned = false;
15766 NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
15769 uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel(uint32_t this_arg, uint32_t msg) {
15770 LDKNetworkGraph this_arg_conv;
15771 this_arg_conv.inner = (void*)(this_arg & (~1));
15772 this_arg_conv.is_owned = false;
15773 LDKChannelUpdate msg_conv;
15774 msg_conv.inner = (void*)(msg & (~1));
15775 msg_conv.is_owned = false;
15776 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15777 *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
15778 return (long)ret_conv;
15781 uint32_t __attribute__((visibility("default"))) TS_NetworkGraph_update_channel_unsigned(uint32_t this_arg, uint32_t msg) {
15782 LDKNetworkGraph this_arg_conv;
15783 this_arg_conv.inner = (void*)(this_arg & (~1));
15784 this_arg_conv.is_owned = false;
15785 LDKUnsignedChannelUpdate msg_conv;
15786 msg_conv.inner = (void*)(msg & (~1));
15787 msg_conv.is_owned = false;
15788 LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
15789 *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
15790 return (long)ret_conv;