+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_SpendableOutputDescriptorZ_new(uint32_tArray elems) {
+ LDKCVec_SpendableOutputDescriptorZ *ret = MALLOC(sizeof(LDKCVec_SpendableOutputDescriptorZ), "LDKCVec_SpendableOutputDescriptorZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * ret->datalen, "LDKCVec_SpendableOutputDescriptorZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(arr_elem_ptr);
+ arr_elem_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
+ LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
+ LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKErrorAction_DisconnectPeer: {
+ LDKErrorMessage msg_var = obj->disconnect_peer.msg;
+ uint64_t msg_ref = 0;
+ if ((uint64_t)msg_var.inner > 4096) {
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ }
+ return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
+ }
+ case LDKErrorAction_IgnoreError: {
+ return 0 /* LDKErrorAction - IgnoreError */;
+ }
+ case LDKErrorAction_IgnoreAndLog: {
+ uint32_t ignore_and_log_conv = LDKLevel_to_js(obj->ignore_and_log);
+ return 0 /* LDKErrorAction - IgnoreAndLog */; (void) ignore_and_log_conv;
+ }
+ case LDKErrorAction_SendErrorMessage: {
+ LDKErrorMessage msg_var = obj->send_error_message.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
+ LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKMessageSendEvent_SendAcceptChannel: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_accept_channel.node_id.compressed_form, 33);
+ LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendAcceptChannel */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendOpenChannel: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_open_channel.node_id.compressed_form, 33);
+ LDKOpenChannel msg_var = obj->send_open_channel.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendOpenChannel */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendFundingCreated: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_created.node_id.compressed_form, 33);
+ LDKFundingCreated msg_var = obj->send_funding_created.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingCreated */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendFundingSigned: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_signed.node_id.compressed_form, 33);
+ LDKFundingSigned msg_var = obj->send_funding_signed.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingSigned */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendFundingLocked: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_funding_locked.node_id.compressed_form, 33);
+ LDKFundingLocked msg_var = obj->send_funding_locked.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendFundingLocked */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendAnnouncementSignatures: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_announcement_signatures.node_id.compressed_form, 33);
+ LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendAnnouncementSignatures */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_UpdateHTLCs: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->update_htl_cs.node_id.compressed_form, 33);
+ LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
+ uint64_t updates_ref = 0;
+ CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ updates_ref = (uint64_t)updates_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - UpdateHTLCs */; (void) node_id_arr; (void) updates_ref;
+ }
+ case LDKMessageSendEvent_SendRevokeAndACK: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_revoke_and_ack.node_id.compressed_form, 33);
+ LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendRevokeAndACK */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendClosingSigned: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_closing_signed.node_id.compressed_form, 33);
+ LDKClosingSigned msg_var = obj->send_closing_signed.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendClosingSigned */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendShutdown: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_shutdown.node_id.compressed_form, 33);
+ LDKShutdown msg_var = obj->send_shutdown.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendShutdown */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendChannelReestablish: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_reestablish.node_id.compressed_form, 33);
+ LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendChannelReestablish */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
+ LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
+ uint64_t update_msg_ref = 0;
+ CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - BroadcastChannelAnnouncement */; (void) msg_ref; (void) update_msg_ref;
+ }
+ case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
+ LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_BroadcastChannelUpdate: {
+ LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendChannelUpdate: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_update.node_id.compressed_form, 33);
+ LDKChannelUpdate msg_var = obj->send_channel_update.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendChannelUpdate */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_HandleError: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->handle_error.node_id.compressed_form, 33);
+ uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
+ return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
+ }
+ case LDKMessageSendEvent_SendChannelRangeQuery: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_channel_range_query.node_id.compressed_form, 33);
+ LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendChannelRangeQuery */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendShortIdsQuery: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_short_ids_query.node_id.compressed_form, 33);
+ LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (void) node_id_arr; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_SendReplyChannelRange: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->send_reply_channel_range.node_id.compressed_form, 33);
+ LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
+ uint64_t msg_ref = 0;
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendReplyChannelRange */; (void) node_id_arr; (void) msg_ref;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_MessageSendEventZ_new(uint32_tArray elems) {
+ LDKCVec_MessageSendEventZ *ret = MALLOC(sizeof(LDKCVec_MessageSendEventZ), "LDKCVec_MessageSendEventZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKMessageSendEvent) * ret->datalen, "LDKCVec_MessageSendEventZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(arr_elem_ptr);
+ arr_elem_conv = MessageSendEvent_clone((LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
+ LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_InitFeaturesDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKInitFeatures res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InitFeaturesDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NodeFeaturesDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNodeFeatures res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeFeaturesDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ChannelFeaturesDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKChannelFeatures res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelFeaturesDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_InvoiceFeaturesDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKInvoiceFeatures res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceFeaturesDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ScoringParametersDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKScoringParameters res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ScoringParametersDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ScorerDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKScorer res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ScorerDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SpendableOutputDescriptorDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NoneNoneZ*)arg)->result_ok;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NoneNoneZ_get_err(uint32_t arg) {
+ LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
+ return tuple->a;
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form, 64);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
+ return tuple->b;
+}
+ptrArray __attribute__((visibility("default"))) TS_C2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
+ LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
+ ptrArray ret_arr = NULL;
+ ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+ int8_tArray *ret_arr_ptr = (int8_tArray*)(ret_arr + 4);
+ for (size_t m = 0; m < ret_var.datalen; m++) {
+ int8_tArray ret_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_conv_12_arr + 4), ret_var.data[m].compact_form, 64);
+ ret_arr_ptr[m] = ret_conv_12_arr;
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
+ *res_conv = (*val->contents.result);
+ *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
+ return ((uint64_t)res_conv);
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(uint32_t arg) {
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_SignatureNoneZ*)arg)->result_ok;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ int8_tArray res_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).compact_form, 64);
+ return res_arr;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_SignatureNoneZ_get_err(uint32_t arg) {
+ LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+typedef struct LDKBaseSign_JCalls {
+ atomic_size_t refcnt;
+ uint32_t get_per_commitment_point_meth;
+ uint32_t release_commitment_secret_meth;
+ uint32_t validate_holder_commitment_meth;
+ uint32_t channel_keys_id_meth;
+ uint32_t sign_counterparty_commitment_meth;
+ uint32_t validate_counterparty_revocation_meth;
+ uint32_t sign_holder_commitment_and_htlcs_meth;
+ uint32_t sign_justice_revoked_output_meth;
+ uint32_t sign_justice_revoked_htlc_meth;
+ uint32_t sign_counterparty_htlc_transaction_meth;
+ uint32_t sign_closing_transaction_meth;
+ uint32_t sign_channel_announcement_meth;
+ uint32_t ready_channel_meth;
+} LDKBaseSign_JCalls;
+static void LDKBaseSign_JCalls_free(void* this_arg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->get_per_commitment_point_meth);
+ js_free(j_calls->release_commitment_secret_meth);
+ js_free(j_calls->validate_holder_commitment_meth);
+ js_free(j_calls->channel_keys_id_meth);
+ js_free(j_calls->sign_counterparty_commitment_meth);
+ js_free(j_calls->validate_counterparty_revocation_meth);
+ js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
+ js_free(j_calls->sign_justice_revoked_output_meth);
+ js_free(j_calls->sign_justice_revoked_htlc_meth);
+ js_free(j_calls->sign_counterparty_htlc_transaction_meth);
+ js_free(j_calls->sign_closing_transaction_meth);
+ js_free(j_calls->sign_channel_announcement_meth);
+ js_free(j_calls->ready_channel_meth);
+ FREE(j_calls);
+ }
+}
+LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ int8_tArray ret = js_invoke_function_1(j_calls->get_per_commitment_point_meth, idx);
+ LDKPublicKey ret_ref;
+ CHECK(*((uint32_t*)ret) == 33);
+ memcpy(ret_ref.compressed_form, (uint8_t*)(ret + 4), 33);
+ return ret_ref;
+}
+LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ int8_tArray ret = js_invoke_function_1(j_calls->release_commitment_secret_meth, idx);
+ LDKThirtyTwoBytes ret_ref;
+ CHECK(*((uint32_t*)ret) == 32);
+ memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
+ return ret_ref;
+}
+LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
+ uint64_t holder_tx_ref = 0;
+ holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
+ CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ holder_tx_ref = (uint64_t)holder_tx_var.inner;
+ if (holder_tx_var.is_owned) {
+ holder_tx_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->validate_holder_commitment_meth, holder_tx_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
+ ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ int8_tArray ret = js_invoke_function_0(j_calls->channel_keys_id_meth);
+ LDKThirtyTwoBytes ret_ref;
+ CHECK(*((uint32_t*)ret) == 32);
+ memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
+ return ret_ref;
+}
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+ uint64_t commitment_tx_ref = 0;
+ commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
+ CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+ if (commitment_tx_var.is_owned) {
+ commitment_tx_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
+ ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ int8_tArray secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(secret_arr + 4), *secret, 32);
+ uint32_t ret = js_invoke_function_2(j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
+ ret_conv = CResult_NoneNoneZ_clone((LDKCResult_NoneNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
+ uint64_t commitment_tx_ref = 0;
+ commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
+ CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
+ if (commitment_tx_var.is_owned) {
+ commitment_tx_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
+ ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKTransaction justice_tx_var = justice_tx;
+ int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
+ Transaction_free(justice_tx_var);
+ int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
+ uint32_t ret = js_invoke_function_4(j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKTransaction justice_tx_var = justice_tx;
+ int8_tArray justice_tx_arr = init_arr(justice_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(justice_tx_arr + 4), justice_tx_var.data, justice_tx_var.datalen);
+ Transaction_free(justice_tx_var);
+ int8_tArray per_commitment_key_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(per_commitment_key_arr + 4), *per_commitment_key, 32);
+ LDKHTLCOutputInCommitment htlc_var = *htlc;
+ uint64_t htlc_ref = 0;
+ htlc_var = HTLCOutputInCommitment_clone(htlc);
+ CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ htlc_ref = (uint64_t)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_5(j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKTransaction htlc_tx_var = htlc_tx;
+ int8_tArray htlc_tx_arr = init_arr(htlc_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(htlc_tx_arr + 4), htlc_tx_var.data, htlc_tx_var.datalen);
+ Transaction_free(htlc_tx_var);
+ int8_tArray per_commitment_point_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(per_commitment_point_arr + 4), per_commitment_point.compressed_form, 33);
+ LDKHTLCOutputInCommitment htlc_var = *htlc;
+ uint64_t htlc_ref = 0;
+ htlc_var = HTLCOutputInCommitment_clone(htlc);
+ CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ htlc_ref = (uint64_t)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKClosingTransaction closing_tx_var = *closing_tx;
+ uint64_t closing_tx_ref = 0;
+ closing_tx_var = ClosingTransaction_clone(closing_tx);
+ CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ closing_tx_ref = (uint64_t)closing_tx_var.inner;
+ if (closing_tx_var.is_owned) {
+ closing_tx_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKUnsignedChannelAnnouncement msg_var = *msg;
+ uint64_t msg_ref = 0;
+ msg_var = UnsignedChannelAnnouncement_clone(msg);
+ CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ msg_ref = (uint64_t)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
+ LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+ uint64_t channel_parameters_ref = 0;
+ channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
+ CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
+ if (channel_parameters_var.is_owned) {
+ channel_parameters_ref |= 1;
+ }
+ js_invoke_function_1(j_calls->ready_channel_meth, channel_parameters_ref);
+}
+static void LDKBaseSign_JCalls_cloned(LDKBaseSign* new_obj) {
+ LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKBaseSign LDKBaseSign_init (/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
+ LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKChannelPublicKeys pubkeys_conv;
+ pubkeys_conv.inner = (void*)(pubkeys & (~1));
+ pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
+ pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
+
+ LDKBaseSign ret = {
+ .this_arg = (void*) calls,
+ .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
+ .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
+ .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
+ .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
+ .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
+ .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
+ .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
+ .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
+ .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
+ .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
+ .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
+ .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
+ .ready_channel = ready_channel_LDKBaseSign_jcall,
+ .free = LDKBaseSign_JCalls_free,
+ .pubkeys = pubkeys_conv,
+ .set_pubkeys = NULL,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKBaseSign_new(/*TODO: JS Object Reference */void* o, uint32_t pubkeys) {
+ LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
+ *res_ptr = LDKBaseSign_init(o, pubkeys);
+ return (long)res_ptr;
+}
+int8_tArray __attribute__((visibility("default"))) TS_BaseSign_get_per_commitment_point(uint32_t this_arg, int64_t idx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form, 33);
+ return ret_arr;
+}
+
+int8_tArray __attribute__((visibility("default"))) TS_BaseSign_release_commitment_secret(uint32_t this_arg, int64_t idx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data, 32);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_validate_holder_commitment(uint32_t this_arg, uint32_t holder_tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKHolderCommitmentTransaction holder_tx_conv;
+ holder_tx_conv.inner = (void*)(holder_tx & (~1));
+ holder_tx_conv.is_owned = false;
+ LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
+ *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
+ return (uint64_t)ret_conv;
+}
+
+int8_tArray __attribute__((visibility("default"))) TS_BaseSign_channel_keys_id(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data, 32);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_commitment(uint32_t this_arg, uint32_t commitment_tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
+ *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_validate_counterparty_revocation(uint32_t this_arg, int64_t idx, int8_tArray secret) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ unsigned char secret_arr[32];
+ CHECK(*((uint32_t*)secret) == 32);
+ memcpy(secret_arr, (uint8_t*)(secret + 4), 32);
+ unsigned char (*secret_ref)[32] = &secret_arr;
+ LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
+ *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_holder_commitment_and_htlcs(uint32_t this_arg, uint32_t commitment_tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKHolderCommitmentTransaction commitment_tx_conv;
+ commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
+ commitment_tx_conv.is_owned = false;
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
+ *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_output(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction justice_tx_ref;
+ justice_tx_ref.datalen = *((uint32_t*)justice_tx);
+ justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
+ memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
+ justice_tx_ref.data_is_owned = true;
+ unsigned char per_commitment_key_arr[32];
+ CHECK(*((uint32_t*)per_commitment_key) == 32);
+ memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
+ unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_justice_revoked_htlc(uint32_t this_arg, int8_tArray justice_tx, int64_t input, int64_t amount, int8_tArray per_commitment_key, uint32_t htlc) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction justice_tx_ref;
+ justice_tx_ref.datalen = *((uint32_t*)justice_tx);
+ justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
+ memcpy(justice_tx_ref.data, (uint8_t*)(justice_tx + 4), justice_tx_ref.datalen);
+ justice_tx_ref.data_is_owned = true;
+ unsigned char per_commitment_key_arr[32];
+ CHECK(*((uint32_t*)per_commitment_key) == 32);
+ memcpy(per_commitment_key_arr, (uint8_t*)(per_commitment_key + 4), 32);
+ unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
+ LDKHTLCOutputInCommitment htlc_conv;
+ htlc_conv.inner = (void*)(htlc & (~1));
+ htlc_conv.is_owned = false;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_justice_revoked_htlc)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref, &htlc_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_counterparty_htlc_transaction(uint32_t this_arg, int8_tArray htlc_tx, int64_t input, int64_t amount, int8_tArray per_commitment_point, uint32_t htlc) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKTransaction htlc_tx_ref;
+ htlc_tx_ref.datalen = *((uint32_t*)htlc_tx);
+ htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
+ memcpy(htlc_tx_ref.data, (uint8_t*)(htlc_tx + 4), htlc_tx_ref.datalen);
+ htlc_tx_ref.data_is_owned = true;
+ LDKPublicKey per_commitment_point_ref;
+ CHECK(*((uint32_t*)per_commitment_point) == 33);
+ memcpy(per_commitment_point_ref.compressed_form, (uint8_t*)(per_commitment_point + 4), 33);
+ LDKHTLCOutputInCommitment htlc_conv;
+ htlc_conv.inner = (void*)(htlc & (~1));
+ htlc_conv.is_owned = false;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *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);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_closing_transaction(uint32_t this_arg, uint32_t closing_tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKClosingTransaction closing_tx_conv;
+ closing_tx_conv.inner = (void*)(closing_tx & (~1));
+ closing_tx_conv.is_owned = false;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_sign_channel_announcement(uint32_t this_arg, uint32_t msg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKUnsignedChannelAnnouncement msg_conv;
+ msg_conv.inner = (void*)(msg & (~1));
+ msg_conv.is_owned = false;
+ LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
+ return (uint64_t)ret_conv;
+}
+
+void __attribute__((visibility("default"))) TS_BaseSign_ready_channel(uint32_t this_arg, uint32_t channel_parameters) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKChannelTransactionParameters channel_parameters_conv;
+ channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
+ channel_parameters_conv.is_owned = false;
+ (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
+}
+
+LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
+ if (this_arg->set_pubkeys != NULL)
+ this_arg->set_pubkeys(this_arg);
+ return this_arg->pubkeys;
+}
+uint32_t __attribute__((visibility("default"))) TS_BaseSign_get_pubkeys(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
+ LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+typedef struct LDKSign_JCalls {
+ atomic_size_t refcnt;
+ LDKBaseSign_JCalls* BaseSign;
+ uint32_t write_meth;
+} LDKSign_JCalls;
+static void LDKSign_JCalls_free(void* this_arg) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->write_meth);
+ FREE(j_calls);
+ }
+}
+LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = *((uint32_t*)ret);
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
+ return ret_ref;
+}
+static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
+}
+static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */void* BaseSign, uint32_t pubkeys) {
+ LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKChannelPublicKeys pubkeys_conv;
+ pubkeys_conv.inner = (void*)(pubkeys & (~1));
+ pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
+ pubkeys_conv = ChannelPublicKeys_clone(&pubkeys_conv);
+
+ LDKSign ret = {
+ .this_arg = (void*) calls,
+ .write = write_LDKSign_jcall,
+ .cloned = LDKSign_JCalls_cloned,
+ .free = LDKSign_JCalls_free,
+ .BaseSign = LDKBaseSign_init(BaseSign, pubkeys),
+ };
+ calls->BaseSign = ret.BaseSign.this_arg;
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKSign_new(/*TODO: JS Object Reference */void* o, /*TODO: JS Object Reference */ void* BaseSign, uint32_t pubkeys) {
+ LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
+ *res_ptr = LDKSign_init(o, BaseSign, pubkeys);
+ return (long)res_ptr;
+}
+int8_tArray __attribute__((visibility("default"))) TS_Sign_write(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_SignDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
+ *res_ret = Sign_clone(&(*val->contents.result));
+ return (uint64_t)res_ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SignDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_RecoverableSignatureNoneZ*)arg)->result_ok;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ int8_tArray es_arr = init_arr(68, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(es_arr + 4), (*val->contents.result).serialized_form, 68);
+ return es_arr;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_RecoverableSignatureNoneZ_get_err(uint32_t arg) {
+ LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
+ LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_CVec_CVec_u8ZZNoneZ*)arg)->result_ok;
+}
+ptrArray __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
+ ptrArray res_arr = NULL;
+ res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+ int8_tArray *res_arr_ptr = (int8_tArray*)(res_arr + 4);
+ for (size_t m = 0; m < res_var.datalen; m++) {
+ LDKCVec_u8Z res_conv_12_var = res_var.data[m];
+ int8_tArray res_conv_12_arr = init_arr(res_conv_12_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(res_conv_12_arr + 4), res_conv_12_var.data, res_conv_12_var.datalen);
+ res_arr_ptr[m] = res_conv_12_arr;
+ }
+
+ return res_arr;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_CVec_CVec_u8ZZNoneZ_get_err(uint32_t arg) {
+ LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_InMemorySignerDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKInMemorySigner res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InMemorySignerDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_TxOutZ_new(uint32_tArray elems) {
+ LDKCVec_TxOutZ *ret = MALLOC(sizeof(LDKCVec_TxOutZ), "LDKCVec_TxOutZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKTxOut) * ret->datalen, "LDKCVec_TxOutZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKTxOut arr_elem_conv = *(LDKTxOut*)(arr_elem_ptr);
+ arr_elem_conv = TxOut_clone((LDKTxOut*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
+ LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = TxOut_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_TransactionNoneZ*)arg)->result_ok;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKTransaction res_var = (*val->contents.result);
+ int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
+ return res_arr;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_TransactionNoneZ_get_err(uint32_t arg) {
+ LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
+ return ChannelMonitor_clone(&tuple->b);
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelMonitorZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
+ LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_BlockHashChannelMonitorZZ_new(uint32_tArray elems) {
+ LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_BlockHashChannelMonitorZZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * ret->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKC2Tuple_BlockHashChannelMonitorZ arr_elem_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(arr_elem_ptr);
+ arr_elem_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
+ LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)arg)->result_ok;
+}
+uint32_tArray __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
+ uint32_tArray res_arr = NULL;
+ res_arr = init_arr(res_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *res_arr_ptr = (uint32_t*)(res_arr + 4);
+ for (size_t j = 0; j < res_var.datalen; j++) {
+ LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
+ *res_conv_35_conv = res_var.data[j];
+ *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
+ res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
+ }
+
+ return res_arr;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(uint32_t arg) {
+ LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKIOError_to_js((*val->contents.err));
+ return err_conv;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_u16Z_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_u16Z_Some: {
+ return 0 /* LDKCOption_u16Z - Some */; (void) obj->some;
+ }
+ case LDKCOption_u16Z_None: {
+ return 0 /* LDKCOption_u16Z - None */;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKAPIError_ref_from_ptr(uint32_t ptr) {
+ LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKAPIError_APIMisuseError: {
+ LDKStr err_str = obj->api_misuse_error.err;
+ jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
+ return 0 /* LDKAPIError - APIMisuseError */; (void) err_conv;
+ }
+ case LDKAPIError_FeeRateTooHigh: {
+ LDKStr err_str = obj->fee_rate_too_high.err;
+ jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
+ return 0 /* LDKAPIError - FeeRateTooHigh */; (void) err_conv; (void) obj->fee_rate_too_high.feerate;
+ }
+ case LDKAPIError_RouteError: {
+ LDKStr err_str = obj->route_error.err;
+ jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
+ return 0 /* LDKAPIError - RouteError */; (void) err_conv;
+ }
+ case LDKAPIError_ChannelUnavailable: {
+ LDKStr err_str = obj->channel_unavailable.err;
+ jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
+ return 0 /* LDKAPIError - ChannelUnavailable */; (void) err_conv;
+ }
+ case LDKAPIError_MonitorUpdateFailed: {
+ return 0 /* LDKAPIError - MonitorUpdateFailed */;
+ }
+ case LDKAPIError_IncompatibleShutdownScript: {
+ LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
+ uint64_t script_ref = 0;
+ CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ script_ref = (uint64_t)script_var.inner & ~1;
+ return 0 /* LDKAPIError - IncompatibleShutdownScript */; (void) script_ref;
+ }
+ default: abort();
+ }
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NoneAPIErrorZ*)arg)->result_ok;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneAPIErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_CResult_NoneAPIErrorZZ_new(uint32_tArray elems) {
+ LDKCVec_CResult_NoneAPIErrorZZ *ret = MALLOC(sizeof(LDKCVec_CResult_NoneAPIErrorZZ), "LDKCVec_CResult_NoneAPIErrorZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * ret->datalen, "LDKCVec_CResult_NoneAPIErrorZZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKCResult_NoneAPIErrorZ arr_elem_conv = *(LDKCResult_NoneAPIErrorZ*)(arr_elem_ptr);
+ arr_elem_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
+ LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_APIErrorZ_new(uint32_tArray elems) {
+ LDKCVec_APIErrorZ *ret = MALLOC(sizeof(LDKCVec_APIErrorZ), "LDKCVec_APIErrorZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKAPIError) * ret->datalen, "LDKCVec_APIErrorZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKAPIError arr_elem_conv = *(LDKAPIError*)(arr_elem_ptr);
+ arr_elem_conv = APIError_clone((LDKAPIError*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
+ LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = APIError_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult__u832APIErrorZ*)arg)->result_ok;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_ok(uint32_t arg) {
+ LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
+ return res_arr;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult__u832APIErrorZ_get_err(uint32_t arg) {
+ LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKPaymentSendFailure_ref_from_ptr(uint32_t ptr) {
+ LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKPaymentSendFailure_ParameterError: {
+ uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
+ return 0 /* LDKPaymentSendFailure - ParameterError */; (void) parameter_error_ref;
+ }
+ case LDKPaymentSendFailure_PathParameterError: {
+ LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
+ uint32_tArray path_parameter_error_arr = NULL;
+ path_parameter_error_arr = init_arr(path_parameter_error_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *path_parameter_error_arr_ptr = (uint32_t*)(path_parameter_error_arr + 4);
+ for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
+ LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+ *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
+ *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
+ path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
+ }
+
+ return 0 /* LDKPaymentSendFailure - PathParameterError */; (void) path_parameter_error_arr;
+ }
+ case LDKPaymentSendFailure_AllFailedRetrySafe: {
+ LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
+ uint32_tArray all_failed_retry_safe_arr = NULL;
+ all_failed_retry_safe_arr = init_arr(all_failed_retry_safe_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *all_failed_retry_safe_arr_ptr = (uint32_t*)(all_failed_retry_safe_arr + 4);
+ for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
+ uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
+ all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
+ }
+
+ return 0 /* LDKPaymentSendFailure - AllFailedRetrySafe */; (void) all_failed_retry_safe_arr;
+ }
+ case LDKPaymentSendFailure_PartialFailure: {
+ LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
+ uint32_tArray results_arr = NULL;
+ results_arr = init_arr(results_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *results_arr_ptr = (uint32_t*)(results_arr + 4);
+ for (size_t w = 0; w < results_var.datalen; w++) {
+ LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
+ *results_conv_22_conv = results_var.data[w];
+ *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
+ results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
+ }
+
+ LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
+ uint64_t failed_paths_retry_ref = 0;
+ if ((uint64_t)failed_paths_retry_var.inner > 4096) {
+ CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
+ }
+ int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_id_arr + 4), obj->partial_failure.payment_id.data, 32);
+ return 0 /* LDKPaymentSendFailure - PartialFailure */; (void) results_arr; (void) failed_paths_retry_ref; (void) payment_id_arr;
+ }
+ default: abort();
+ }
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_PaymentIdPaymentSendFailureZ*)arg)->result_ok;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_ok(uint32_t arg) {
+ LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
+ return res_arr;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentSendFailureZ_get_err(uint32_t arg) {
+ LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NonePaymentSendFailureZ*)arg)->result_ok;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_ok(uint32_t arg) {
+ LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NonePaymentSendFailureZ_get_err(uint32_t arg) {
+ LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
+ return err_ref;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->b);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentIdZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(uint32_t arg) {
+ LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
+ *res_conv = (*val->contents.result);
+ *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
+ return ((uint64_t)res_conv);
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(uint32_t arg) {
+ LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
+ LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKNetAddress_IPv4: {
+ int8_tArray addr_arr = init_arr(4, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(addr_arr + 4), obj->i_pv4.addr.data, 4);
+ return 0 /* LDKNetAddress - IPv4 */; (void) addr_arr; (void) obj->i_pv4.port;
+ }
+ case LDKNetAddress_IPv6: {
+ int8_tArray addr_arr = init_arr(16, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(addr_arr + 4), obj->i_pv6.addr.data, 16);
+ return 0 /* LDKNetAddress - IPv6 */; (void) addr_arr; (void) obj->i_pv6.port;
+ }
+ case LDKNetAddress_OnionV2: {
+ int8_tArray addr_arr = init_arr(10, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(addr_arr + 4), obj->onion_v2.addr.data, 10);
+ return 0 /* LDKNetAddress - OnionV2 */; (void) addr_arr; (void) obj->onion_v2.port;
+ }
+ case LDKNetAddress_OnionV3: {
+ int8_tArray ed25519_pubkey_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ed25519_pubkey_arr + 4), obj->onion_v3.ed25519_pubkey.data, 32);
+ return 0 /* LDKNetAddress - OnionV3 */; (void) ed25519_pubkey_arr; (void) obj->onion_v3.checksum; (void) obj->onion_v3.version; (void) obj->onion_v3.port;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_NetAddressZ_new(uint32_tArray elems) {
+ LDKCVec_NetAddressZ *ret = MALLOC(sizeof(LDKCVec_NetAddressZ), "LDKCVec_NetAddressZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKNetAddress) * ret->datalen, "LDKCVec_NetAddressZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(arr_elem_ptr);
+ arr_elem_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
+ LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = NetAddress_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->b);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_PaymentHashPaymentSecretZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_PaymentSecretAPIErrorZ*)arg)->result_ok;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
+ return res_arr;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PaymentSecretAPIErrorZ_get_err(uint32_t arg) {
+ LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_ChannelMonitorZ_new(uint32_tArray elems) {
+ LDKCVec_ChannelMonitorZ *ret = MALLOC(sizeof(LDKCVec_ChannelMonitorZ), "LDKCVec_ChannelMonitorZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKChannelMonitor) * ret->datalen, "LDKCVec_ChannelMonitorZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ LDKChannelMonitor arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = ChannelMonitor_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
+ LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
+ }
+ return ret;
+}
+typedef struct LDKWatch_JCalls {
+ atomic_size_t refcnt;
+ uint32_t watch_channel_meth;
+ uint32_t update_channel_meth;
+ uint32_t release_pending_monitor_events_meth;
+} LDKWatch_JCalls;
+static void LDKWatch_JCalls_free(void* this_arg) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->watch_channel_meth);
+ js_free(j_calls->update_channel_meth);
+ js_free(j_calls->release_pending_monitor_events_meth);
+ FREE(j_calls);
+ }
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ LDKOutPoint funding_txo_var = funding_txo;
+ uint64_t funding_txo_ref = 0;
+ CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ funding_txo_ref = (uint64_t)funding_txo_var.inner;
+ if (funding_txo_var.is_owned) {
+ funding_txo_ref |= 1;
+ }
+ LDKChannelMonitor monitor_var = monitor;
+ uint64_t monitor_ref = 0;
+ CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ monitor_ref = (uint64_t)monitor_var.inner;
+ if (monitor_var.is_owned) {
+ monitor_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_2(j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
+ ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ LDKOutPoint funding_txo_var = funding_txo;
+ uint64_t funding_txo_ref = 0;
+ CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ funding_txo_ref = (uint64_t)funding_txo_var.inner;
+ if (funding_txo_var.is_owned) {
+ funding_txo_ref |= 1;
+ }
+ LDKChannelMonitorUpdate update_var = update;
+ uint64_t update_ref = 0;
+ CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ update_ref = (uint64_t)update_var.inner;
+ if (update_var.is_owned) {
+ update_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_2(j_calls->update_channel_meth, funding_txo_ref, update_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
+ ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone((LDKCResult_NoneChannelMonitorUpdateErrZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
+ uint32_tArray ret = js_invoke_function_0(j_calls->release_pending_monitor_events_meth);
+ LDKCVec_MonitorEventZ ret_constr;
+ ret_constr.datalen = *((uint32_t*)ret);
+ if (ret_constr.datalen > 0)
+ ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
+ else
+ ret_constr.data = NULL;
+ uint32_t* ret_vals = (uint32_t*)(ret + 4);
+ for (size_t o = 0; o < ret_constr.datalen; o++) {
+ uint32_t ret_conv_14 = ret_vals[o];
+ void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
+ CHECK_ACCESS(ret_conv_14_ptr);
+ LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
+ ret_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)ret_conv_14) & ~1));
+ ret_constr.data[o] = ret_conv_14_conv;
+ }
+ return ret_constr;
+}
+static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
+ LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKWatch LDKWatch_init (/*TODO: JS Object Reference */void* o) {
+ LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKWatch ret = {
+ .this_arg = (void*) calls,
+ .watch_channel = watch_channel_LDKWatch_jcall,
+ .update_channel = update_channel_LDKWatch_jcall,
+ .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
+ .free = LDKWatch_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKWatch_new(/*TODO: JS Object Reference */void* o) {
+ LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
+ *res_ptr = LDKWatch_init(o);
+ return (long)res_ptr;
+}
+uint32_t __attribute__((visibility("default"))) TS_Watch_watch_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t monitor) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
+ LDKOutPoint funding_txo_conv;
+ funding_txo_conv.inner = (void*)(funding_txo & (~1));
+ funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+ funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+ LDKChannelMonitor monitor_conv;
+ monitor_conv.inner = (void*)(monitor & (~1));
+ monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
+ monitor_conv = ChannelMonitor_clone(&monitor_conv);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_Watch_update_channel(uint32_t this_arg, uint32_t funding_txo, uint32_t update) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
+ LDKOutPoint funding_txo_conv;
+ funding_txo_conv.inner = (void*)(funding_txo & (~1));
+ funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
+ funding_txo_conv = OutPoint_clone(&funding_txo_conv);
+ LDKChannelMonitorUpdate update_conv;
+ update_conv.inner = (void*)(update & (~1));
+ update_conv.is_owned = (update & 1) || (update == 0);
+ update_conv = ChannelMonitorUpdate_clone(&update_conv);
+ LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
+ *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
+ return (uint64_t)ret_conv;
+}
+
+uint32_tArray __attribute__((visibility("default"))) TS_Watch_release_pending_monitor_events(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
+ LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
+ uint32_tArray ret_arr = NULL;
+ ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
+ for (size_t o = 0; o < ret_var.datalen; o++) {
+ LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
+ *ret_conv_14_copy = ret_var.data[o];
+ uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
+ ret_arr_ptr[o] = ret_conv_14_ref;
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+typedef struct LDKBroadcasterInterface_JCalls {
+ atomic_size_t refcnt;
+ uint32_t broadcast_transaction_meth;
+} LDKBroadcasterInterface_JCalls;
+static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
+ LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->broadcast_transaction_meth);
+ FREE(j_calls);
+ }
+}
+void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
+ LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
+ LDKTransaction tx_var = tx;
+ int8_tArray tx_arr = init_arr(tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(tx_arr + 4), tx_var.data, tx_var.datalen);
+ Transaction_free(tx_var);
+ js_invoke_function_1(j_calls->broadcast_transaction_meth, tx_arr);
+}
+static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
+ LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (/*TODO: JS Object Reference */void* o) {
+ LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKBroadcasterInterface ret = {
+ .this_arg = (void*) calls,
+ .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
+ .free = LDKBroadcasterInterface_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKBroadcasterInterface_new(/*TODO: JS Object Reference */void* o) {
+ LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
+ *res_ptr = LDKBroadcasterInterface_init(o);
+ return (long)res_ptr;
+}
+void __attribute__((visibility("default"))) TS_BroadcasterInterface_broadcast_transaction(uint32_t this_arg, int8_tArray tx) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
+ LDKTransaction tx_ref;
+ tx_ref.datalen = *((uint32_t*)tx);
+ tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
+ memcpy(tx_ref.data, (uint8_t*)(tx + 4), tx_ref.datalen);
+ tx_ref.data_is_owned = true;
+ (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
+}
+
+typedef struct LDKKeysInterface_JCalls {
+ atomic_size_t refcnt;
+ uint32_t get_node_secret_meth;
+ uint32_t get_destination_script_meth;
+ uint32_t get_shutdown_scriptpubkey_meth;
+ uint32_t get_channel_signer_meth;
+ uint32_t get_secure_random_bytes_meth;
+ uint32_t read_chan_signer_meth;
+ uint32_t sign_invoice_meth;
+} LDKKeysInterface_JCalls;
+static void LDKKeysInterface_JCalls_free(void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->get_node_secret_meth);
+ js_free(j_calls->get_destination_script_meth);
+ js_free(j_calls->get_shutdown_scriptpubkey_meth);
+ js_free(j_calls->get_channel_signer_meth);
+ js_free(j_calls->get_secure_random_bytes_meth);
+ js_free(j_calls->read_chan_signer_meth);
+ js_free(j_calls->sign_invoice_meth);
+ FREE(j_calls);
+ }
+}
+LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ int8_tArray ret = js_invoke_function_0(j_calls->get_node_secret_meth);
+ LDKSecretKey ret_ref;
+ CHECK(*((uint32_t*)ret) == 32);
+ memcpy(ret_ref.bytes, (uint8_t*)(ret + 4), 32);
+ return ret_ref;
+}
+LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ int8_tArray ret = js_invoke_function_0(j_calls->get_destination_script_meth);
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = *((uint32_t*)ret);
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
+ return ret_ref;
+}
+LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ uint32_t ret = js_invoke_function_0(j_calls->get_shutdown_scriptpubkey_meth);
+ LDKShutdownScript ret_conv;
+ ret_conv.inner = (void*)(ret & (~1));
+ ret_conv.is_owned = (ret & 1) || (ret == 0);
+ ret_conv = ShutdownScript_clone(&ret_conv);
+ return ret_conv;
+}
+LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ uint32_t ret = js_invoke_function_2(j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKSign ret_conv = *(LDKSign*)(ret_ptr);
+ ret_conv = Sign_clone(&ret_conv);
+ return ret_conv;
+}
+LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ int8_tArray ret = js_invoke_function_0(j_calls->get_secure_random_bytes_meth);
+ LDKThirtyTwoBytes ret_ref;
+ CHECK(*((uint32_t*)ret) == 32);
+ memcpy(ret_ref.data, (uint8_t*)(ret + 4), 32);
+ return ret_ref;
+}
+LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ LDKu8slice reader_var = reader;
+ int8_tArray reader_arr = init_arr(reader_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(reader_arr + 4), reader_var.data, reader_var.datalen);
+ uint32_t ret = js_invoke_function_1(j_calls->read_chan_signer_meth, reader_arr);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
+ ret_conv = CResult_SignDecodeErrorZ_clone((LDKCResult_SignDecodeErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
+ LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
+ int8_tArray invoice_preimage_arr = init_arr(invoice_preimage_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(invoice_preimage_arr + 4), invoice_preimage_var.data, invoice_preimage_var.datalen);
+ CVec_u8Z_free(invoice_preimage_var);
+ uint32_t ret = js_invoke_function_1(j_calls->sign_invoice_meth, invoice_preimage_arr);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
+ ret_conv = CResult_RecoverableSignatureNoneZ_clone((LDKCResult_RecoverableSignatureNoneZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
+ LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKKeysInterface LDKKeysInterface_init (/*TODO: JS Object Reference */void* o) {
+ LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKKeysInterface ret = {
+ .this_arg = (void*) calls,
+ .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
+ .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
+ .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
+ .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
+ .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
+ .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
+ .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
+ .free = LDKKeysInterface_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKKeysInterface_new(/*TODO: JS Object Reference */void* o) {
+ LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
+ *res_ptr = LDKKeysInterface_init(o);
+ return (long)res_ptr;
+}
+int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_node_secret(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes, 32);
+ return ret_arr;
+}
+
+int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_destination_script(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_shutdown_scriptpubkey(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_KeysInterface_get_channel_signer(uint32_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
+ *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
+ return (uint64_t)ret_ret;
+}
+
+int8_tArray __attribute__((visibility("default"))) TS_KeysInterface_get_secure_random_bytes(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data, 32);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_KeysInterface_read_chan_signer(uint32_t this_arg, int8_tArray reader) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKu8slice reader_ref;
+ reader_ref.datalen = *((uint32_t*)reader);
+ reader_ref.data = (int8_t*)(reader + 4);
+ LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
+ *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_KeysInterface_sign_invoice(uint32_t this_arg, int8_tArray invoice_preimage) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
+ LDKCVec_u8Z invoice_preimage_ref;
+ invoice_preimage_ref.datalen = *((uint32_t*)invoice_preimage);
+ invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
+ memcpy(invoice_preimage_ref.data, (uint8_t*)(invoice_preimage + 4), invoice_preimage_ref.datalen);
+ LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
+ *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
+ return (uint64_t)ret_conv;
+}
+
+typedef struct LDKFeeEstimator_JCalls {
+ atomic_size_t refcnt;
+ uint32_t get_est_sat_per_1000_weight_meth;
+} LDKFeeEstimator_JCalls;
+static void LDKFeeEstimator_JCalls_free(void* this_arg) {
+ LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->get_est_sat_per_1000_weight_meth);
+ FREE(j_calls);
+ }
+}
+uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
+ LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
+ uint32_t confirmation_target_conv = LDKConfirmationTarget_to_js(confirmation_target);
+ return js_invoke_function_1(j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
+}
+static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
+ LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKFeeEstimator LDKFeeEstimator_init (/*TODO: JS Object Reference */void* o) {
+ LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKFeeEstimator ret = {
+ .this_arg = (void*) calls,
+ .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
+ .free = LDKFeeEstimator_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKFeeEstimator_new(/*TODO: JS Object Reference */void* o) {
+ LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
+ *res_ptr = LDKFeeEstimator_init(o);
+ return (long)res_ptr;
+}
+int32_t __attribute__((visibility("default"))) TS_FeeEstimator_get_est_sat_per_1000_weight(uint32_t this_arg, uint32_t confirmation_target) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
+ LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_js(confirmation_target);
+ int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
+ return ret_val;
+}
+
+typedef struct LDKLogger_JCalls {
+ atomic_size_t refcnt;
+ uint32_t log_meth;
+} LDKLogger_JCalls;
+static void LDKLogger_JCalls_free(void* this_arg) {
+ LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->log_meth);
+ FREE(j_calls);
+ }
+}
+void log_LDKLogger_jcall(const void* this_arg, const char* record) {
+ LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
+ const char* record_str = record;
+ jstring record_conv = str_ref_to_ts(record_str, strlen(record_str));
+ js_invoke_function_1(j_calls->log_meth, record_conv);
+}
+static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
+ LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKLogger LDKLogger_init (/*TODO: JS Object Reference */void* o) {
+ LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKLogger ret = {
+ .this_arg = (void*) calls,
+ .log = log_LDKLogger_jcall,
+ .free = LDKLogger_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKLogger_new(/*TODO: JS Object Reference */void* o) {
+ LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
+ *res_ptr = LDKLogger_init(o);
+ return (long)res_ptr;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
+ return &tuple->b;
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_BlockHashChannelManagerZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
+ LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner & ~1;
+ return ret_ref;
+}
+
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
+ // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
+ return ((uint64_t)res_conv) | 1;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ChannelConfigDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKChannelConfig res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelConfigDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_OutPointDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKOutPoint res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_OutPointDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+typedef struct LDKType_JCalls {
+ atomic_size_t refcnt;
+ uint32_t type_id_meth;
+ uint32_t debug_str_meth;
+ uint32_t write_meth;
+} LDKType_JCalls;
+static void LDKType_JCalls_free(void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->type_id_meth);
+ js_free(j_calls->debug_str_meth);
+ js_free(j_calls->write_meth);
+ FREE(j_calls);
+ }
+}
+uint16_t type_id_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ return js_invoke_function_0(j_calls->type_id_meth);
+}
+LDKStr debug_str_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ uint32_t ret = js_invoke_function_0(j_calls->debug_str_meth);
+ LDKStr ret_conv = str_ref_to_owned_c(ret);
+ return ret_conv;
+}
+LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
+ int8_tArray ret = js_invoke_function_0(j_calls->write_meth);
+ LDKCVec_u8Z ret_ref;
+ ret_ref.datalen = *((uint32_t*)ret);
+ ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
+ memcpy(ret_ref.data, (uint8_t*)(ret + 4), ret_ref.datalen);
+ return ret_ref;
+}
+static void LDKType_JCalls_cloned(LDKType* new_obj) {
+ LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKType LDKType_init (/*TODO: JS Object Reference */void* o) {
+ LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKType ret = {
+ .this_arg = (void*) calls,
+ .type_id = type_id_LDKType_jcall,
+ .debug_str = debug_str_LDKType_jcall,
+ .write = write_LDKType_jcall,
+ .cloned = LDKType_JCalls_cloned,
+ .free = LDKType_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKType_new(/*TODO: JS Object Reference */void* o) {
+ LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
+ *res_ptr = LDKType_init(o);
+ return (long)res_ptr;
+}
+int16_t __attribute__((visibility("default"))) TS_Type_type_id(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
+ return ret_val;
+}
+
+jstring __attribute__((visibility("default"))) TS_Type_debug_str(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
+ jstring ret_conv = str_ref_to_ts(ret_str.chars, ret_str.len);
+ Str_free(ret_str);
+ return ret_conv;
+}
+
+int8_tArray __attribute__((visibility("default"))) TS_Type_write(uint32_t this_arg) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
+ LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
+ int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_TypeZ_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_TypeZ_Some: {
+ LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
+ *some_ret = Type_clone(&obj->some);
+ return 0 /* LDKCOption_TypeZ - Some */; (void) (uint64_t)some_ret;
+ }
+ case LDKCOption_TypeZ_None: {
+ return 0 /* LDKCOption_TypeZ - None */;
+ }
+ default: abort();
+ }
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_COption_TypeZDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_COption_TypeZDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKPaymentError_ref_from_ptr(uint32_t ptr) {
+ LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKPaymentError_Invoice: {
+ LDKStr invoice_str = obj->invoice;
+ jstring invoice_conv = str_ref_to_ts(invoice_str.chars, invoice_str.len);
+ return 0 /* LDKPaymentError - Invoice */; (void) invoice_conv;
+ }
+ case LDKPaymentError_Routing: {
+ LDKLightningError routing_var = obj->routing;
+ uint64_t routing_ref = 0;
+ CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ routing_ref = (uint64_t)routing_var.inner & ~1;
+ return 0 /* LDKPaymentError - Routing */; (void) routing_ref;
+ }
+ case LDKPaymentError_Sending: {
+ uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
+ return 0 /* LDKPaymentError - Sending */; (void) sending_ref;
+ }
+ default: abort();
+ }
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_PaymentIdPaymentErrorZ*)arg)->result_ok;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ int8_tArray res_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(res_arr + 4), (*val->contents.result).data, 32);
+ return res_arr;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PaymentIdPaymentErrorZ_get_err(uint32_t arg) {
+ LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_SiPrefixNoneZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ uint32_t res_conv = LDKSiPrefix_to_js((*val->contents.result));
+ return res_conv;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_SiPrefixNoneZ_get_err(uint32_t arg) {
+ LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_InvoiceNoneZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKInvoice res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_InvoiceNoneZ_get_err(uint32_t arg) {
+ LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_SignedRawInvoiceNoneZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKSignedRawInvoice res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_SignedRawInvoiceNoneZ_get_err(uint32_t arg) {
+ LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ return *val->contents.err;
+}
+static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
+ return RawInvoice_clone(&tuple->a);
+}
+uint32_t __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(uint32_t tuple) {
+ LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
+ LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->b);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(uint32_t tuple) {
+ LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
+ return InvoiceSignature_clone(&tuple->c);
+}
+uint32_t __attribute__((visibility("default"))) TS_C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(uint32_t tuple) {
+ LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
+ LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_PayeePubKeyErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKPayeePubKey res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PayeePubKeyErrorZ_get_err(uint32_t arg) {
+ LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
+ return err_conv;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_PrivateRouteZ_new(uint32_tArray elems) {
+ LDKCVec_PrivateRouteZ *ret = MALLOC(sizeof(LDKCVec_PrivateRouteZ), "LDKCVec_PrivateRouteZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKPrivateRoute) * ret->datalen, "LDKCVec_PrivateRouteZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ LDKPrivateRoute arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = PrivateRoute_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
+ LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = PrivateRoute_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_PositiveTimestampCreationErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKPositiveTimestamp res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PositiveTimestampCreationErrorZ_get_err(uint32_t arg) {
+ LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
+ return err_conv;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NoneSemanticErrorZ*)arg)->result_ok;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneSemanticErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
+ return err_conv;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_InvoiceSemanticErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKInvoice res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSemanticErrorZ_get_err(uint32_t arg) {
+ LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKSemanticError_to_js((*val->contents.err));
+ return err_conv;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_DescriptionCreationErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKDescription res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DescriptionCreationErrorZ_get_err(uint32_t arg) {
+ LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
+ return err_conv;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ExpiryTimeCreationErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKExpiryTime res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ExpiryTimeCreationErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
+ return err_conv;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_PrivateRouteCreationErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKPrivateRoute res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PrivateRouteCreationErrorZ_get_err(uint32_t arg) {
+ LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKCreationError_to_js((*val->contents.err));
+ return err_conv;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_StringErrorZ*)arg)->result_ok;
+}
+jstring __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKStr res_str = (*val->contents.result);
+ jstring res_conv = str_ref_to_ts(res_str.chars, res_str.len);
+ return res_conv;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_StringErrorZ_get_err(uint32_t arg) {
+ LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKSecp256k1Error_to_js((*val->contents.err));
+ return err_conv;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKChannelMonitorUpdate res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelMonitorUpdateDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_HTLCUpdateDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKHTLCUpdate res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_HTLCUpdateDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NoneMonitorUpdateErrorZ*)arg)->result_ok;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneMonitorUpdateErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKMonitorUpdateError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
+ return OutPoint_clone(&tuple->a);
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
+ LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
+ return CVec_u8Z_clone(&tuple->b);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_OutPointScriptZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
+ LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
+ int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
+ return tuple->a;
+}
+int32_t __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
+ int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
+ return ret_val;
+}
+
+static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
+ return CVec_u8Z_clone(&tuple->b);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_u32ScriptZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
+ LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
+ int8_tArray ret_arr = init_arr(ret_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), ret_var.data, ret_var.datalen);
+ CVec_u8Z_free(ret_var);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32ScriptZZ_new(uint32_tArray elems) {
+ LDKCVec_C2Tuple_u32ScriptZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32ScriptZZ), "LDKCVec_C2Tuple_u32ScriptZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * ret->datalen, "LDKCVec_C2Tuple_u32ScriptZZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKC2Tuple_u32ScriptZ arr_elem_conv = *(LDKC2Tuple_u32ScriptZ*)(arr_elem_ptr);
+ arr_elem_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
+ LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
+ return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
+}
+uint32_tArray __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
+ LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
+ uint32_tArray ret_arr = NULL;
+ ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
+ for (size_t v = 0; v < ret_var.datalen; v++) {
+ LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
+ *ret_conv_21_conv = ret_var.data[v];
+ ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_new(uint32_tArray elems) {
+ LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arr_elem_ptr);
+ arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
+ LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKPaymentPurpose_ref_from_ptr(uint32_t ptr) {
+ LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKPaymentPurpose_InvoicePayment: {
+ int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_preimage_arr + 4), obj->invoice_payment.payment_preimage.data, 32);
+ int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_secret_arr + 4), obj->invoice_payment.payment_secret.data, 32);
+ return 0 /* LDKPaymentPurpose - InvoicePayment */; (void) payment_preimage_arr; (void) payment_secret_arr; (void) obj->invoice_payment.user_payment_id;
+ }
+ case LDKPaymentPurpose_SpontaneousPayment: {
+ int8_tArray spontaneous_payment_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(spontaneous_payment_arr + 4), obj->spontaneous_payment.data, 32);
+ return 0 /* LDKPaymentPurpose - SpontaneousPayment */; (void) spontaneous_payment_arr;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKClosureReason_ref_from_ptr(uint32_t ptr) {
+ LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKClosureReason_CounterpartyForceClosed: {
+ LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
+ jstring peer_msg_conv = str_ref_to_ts(peer_msg_str.chars, peer_msg_str.len);
+ return 0 /* LDKClosureReason - CounterpartyForceClosed */; (void) peer_msg_conv;
+ }
+ case LDKClosureReason_HolderForceClosed: {
+ return 0 /* LDKClosureReason - HolderForceClosed */;
+ }
+ case LDKClosureReason_CooperativeClosure: {
+ return 0 /* LDKClosureReason - CooperativeClosure */;
+ }
+ case LDKClosureReason_CommitmentTxConfirmed: {
+ return 0 /* LDKClosureReason - CommitmentTxConfirmed */;
+ }
+ case LDKClosureReason_ProcessingError: {
+ LDKStr err_str = obj->processing_error.err;
+ jstring err_conv = str_ref_to_ts(err_str.chars, err_str.len);
+ return 0 /* LDKClosureReason - ProcessingError */; (void) err_conv;
+ }
+ case LDKClosureReason_DisconnectedPeer: {
+ return 0 /* LDKClosureReason - DisconnectedPeer */;
+ }
+ case LDKClosureReason_OutdatedChannelManager: {
+ return 0 /* LDKClosureReason - OutdatedChannelManager */;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKEvent_ref_from_ptr(uint32_t ptr) {
+ LDKEvent *obj = (LDKEvent*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKEvent_FundingGenerationReady: {
+ int8_tArray temporary_channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(temporary_channel_id_arr + 4), obj->funding_generation_ready.temporary_channel_id.data, 32);
+ LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
+ int8_tArray output_script_arr = init_arr(output_script_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(output_script_arr + 4), output_script_var.data, output_script_var.datalen);
+ 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;
+ }
+ case LDKEvent_PaymentReceived: {
+ int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_received.payment_hash.data, 32);
+ uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
+ return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) obj->payment_received.amt; (void) purpose_ref;
+ }
+ case LDKEvent_PaymentSent: {
+ int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_sent.payment_id.data, 32);
+ int8_tArray payment_preimage_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_preimage_arr + 4), obj->payment_sent.payment_preimage.data, 32);
+ int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_sent.payment_hash.data, 32);
+ uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
+ return 0 /* LDKEvent - PaymentSent */; (void) payment_id_arr; (void) payment_preimage_arr; (void) payment_hash_arr; (void) fee_paid_msat_ref;
+ }
+ case LDKEvent_PaymentPathFailed: {
+ int8_tArray payment_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_id_arr + 4), obj->payment_path_failed.payment_id.data, 32);
+ int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_path_failed.payment_hash.data, 32);
+ uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
+ LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
+ uint32_tArray path_arr = NULL;
+ path_arr = init_arr(path_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *path_arr_ptr = (uint32_t*)(path_arr + 4);
+ for (size_t k = 0; k < path_var.datalen; k++) {
+ LDKRouteHop path_conv_10_var = path_var.data[k];
+ uint64_t path_conv_10_ref = 0;
+ CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
+ path_arr_ptr[k] = path_conv_10_ref;
+ }
+
+ uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
+ LDKRouteParameters retry_var = obj->payment_path_failed.retry;
+ uint64_t retry_ref = 0;
+ if ((uint64_t)retry_var.inner > 4096) {
+ CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ retry_ref = (uint64_t)retry_var.inner & ~1;
+ }
+ return 0 /* LDKEvent - PaymentPathFailed */; (void) payment_id_arr; (void) payment_hash_arr; (void) obj->payment_path_failed.rejected_by_dest; (void) network_update_ref; (void) obj->payment_path_failed.all_paths_failed; (void) path_arr; (void) short_channel_id_ref; (void) retry_ref;
+ }
+ case LDKEvent_PendingHTLCsForwardable: {
+ return 0 /* LDKEvent - PendingHTLCsForwardable */; (void) obj->pending_htl_cs_forwardable.time_forwardable;
+ }
+ case LDKEvent_SpendableOutputs: {
+ LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
+ uint32_tArray outputs_arr = NULL;
+ outputs_arr = init_arr(outputs_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *outputs_arr_ptr = (uint32_t*)(outputs_arr + 4);
+ for (size_t b = 0; b < outputs_var.datalen; b++) {
+ uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
+ outputs_arr_ptr[b] = outputs_conv_27_ref;
+ }
+
+ return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_arr;
+ }
+ case LDKEvent_PaymentForwarded: {
+ uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
+ return 0 /* LDKEvent - PaymentForwarded */; (void) fee_earned_msat_ref; (void) obj->payment_forwarded.claim_from_onchain_tx;
+ }
+ case LDKEvent_ChannelClosed: {
+ int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(channel_id_arr + 4), obj->channel_closed.channel_id.data, 32);
+ uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
+ return 0 /* LDKEvent - ChannelClosed */; (void) channel_id_arr; (void) obj->channel_closed.user_channel_id; (void) reason_ref;
+ }
+ case LDKEvent_DiscardFunding: {
+ int8_tArray channel_id_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(channel_id_arr + 4), obj->discard_funding.channel_id.data, 32);
+ LDKTransaction transaction_var = obj->discard_funding.transaction;
+ int8_tArray transaction_arr = init_arr(transaction_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(transaction_arr + 4), transaction_var.data, transaction_var.datalen);
+ return 0 /* LDKEvent - DiscardFunding */; (void) channel_id_arr; (void) transaction_arr;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_EventZ_new(uint32_tArray elems) {
+ LDKCVec_EventZ *ret = MALLOC(sizeof(LDKCVec_EventZ), "LDKCVec_EventZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKEvent) * ret->datalen, "LDKCVec_EventZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKEvent arr_elem_conv = *(LDKEvent*)(arr_elem_ptr);
+ arr_elem_conv = Event_clone((LDKEvent*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
+ LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = Event_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
+ return tuple->a;
+}
+int32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
+ int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
+ return ret_val;
+}
+
+static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
+ return TxOut_clone(&tuple->b);
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_u32TxOutZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
+ LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
+ *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
+ return (uint64_t)ret_ref;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_u32TxOutZZ_new(uint32_tArray elems) {
+ LDKCVec_C2Tuple_u32TxOutZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_u32TxOutZZ), "LDKCVec_C2Tuple_u32TxOutZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * ret->datalen, "LDKCVec_C2Tuple_u32TxOutZZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(arr_elem_ptr);
+ arr_elem_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
+ LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
+ return ThirtyTwoBytes_clone(&tuple->a);
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data, 32);
+ return ret_arr;
+}
+
+static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
+ return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
+}
+uint32_tArray __attribute__((visibility("default"))) TS_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
+ LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
+ uint32_tArray ret_arr = NULL;
+ ret_arr = init_arr(ret_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *ret_arr_ptr = (uint32_t*)(ret_arr + 4);
+ for (size_t u = 0; u < ret_var.datalen; u++) {
+ LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
+ *ret_conv_20_conv = ret_var.data[u];
+ ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
+ }
+
+ FREE(ret_var.data);
+ return ret_arr;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_new(uint32_tArray elems) {
+ LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * ret->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arr_elem_ptr);
+ arr_elem_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone((LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
+ LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ) * orig->datalen, "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKBalance_ref_from_ptr(uint32_t ptr) {
+ LDKBalance *obj = (LDKBalance*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKBalance_ClaimableOnChannelClose: {
+ return 0 /* LDKBalance - ClaimableOnChannelClose */; (void) obj->claimable_on_channel_close.claimable_amount_satoshis;
+ }
+ case LDKBalance_ClaimableAwaitingConfirmations: {
+ return 0 /* LDKBalance - ClaimableAwaitingConfirmations */; (void) obj->claimable_awaiting_confirmations.claimable_amount_satoshis; (void) obj->claimable_awaiting_confirmations.confirmation_height;
+ }
+ case LDKBalance_ContentiousClaimable: {
+ return 0 /* LDKBalance - ContentiousClaimable */; (void) obj->contentious_claimable.claimable_amount_satoshis; (void) obj->contentious_claimable.timeout_height;
+ }
+ case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
+ return 0 /* LDKBalance - MaybeClaimableHTLCAwaitingTimeout */; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis; (void) obj->maybe_claimable_htlc_awaiting_timeout.claimable_height;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_BalanceZ_new(uint32_tArray elems) {
+ LDKCVec_BalanceZ *ret = MALLOC(sizeof(LDKCVec_BalanceZ), "LDKCVec_BalanceZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKBalance) * ret->datalen, "LDKCVec_BalanceZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKBalance arr_elem_conv = *(LDKBalance*)(arr_elem_ptr);
+ arr_elem_conv = Balance_clone((LDKBalance*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
+ LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = Balance_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
+ *res_conv = (*val->contents.result);
+ *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
+ return ((uint64_t)res_conv);
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NoneLightningErrorZ*)arg)->result_ok;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneLightningErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKLightningError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
+ return tuple->a;
+}
+int8_tArray __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_a(uint32_t tuple) {
+ LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
+ int8_tArray ret_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(ret_arr + 4), C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form, 33);
+ return ret_arr;
+}
+
+static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
+ return Type_clone(&tuple->b);
+}
+uint32_t __attribute__((visibility("default"))) TS_C2Tuple_PublicKeyTypeZ_get_b(uint32_t tuple) {
+ LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
+ LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
+ *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
+ return (uint64_t)ret_ret;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_PublicKeyTypeZZ_new(uint32_tArray elems) {
+ LDKCVec_C2Tuple_PublicKeyTypeZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_PublicKeyTypeZZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * ret->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKC2Tuple_PublicKeyTypeZ arr_elem_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(arr_elem_ptr);
+ arr_elem_conv = C2Tuple_PublicKeyTypeZ_clone((LDKC2Tuple_PublicKeyTypeZ*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
+ LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_boolLightningErrorZ*)arg)->result_ok;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_boolLightningErrorZ_get_err(uint32_t arg) {
+ LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKLightningError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
+ return ChannelAnnouncement_clone(&tuple->a);
+}
+uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(uint32_t tuple) {
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
+ LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
+ return ChannelUpdate_clone(&tuple->b);
+}
+uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(uint32_t tuple) {
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
+ LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
+ return ChannelUpdate_clone(&tuple->c);
+}
+uint32_t __attribute__((visibility("default"))) TS_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(uint32_t tuple) {
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
+ LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
+ uint64_t ret_ref = 0;
+ CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ ret_ref = (uint64_t)ret_var.inner;
+ if (ret_var.is_owned) {
+ ret_ref |= 1;
+ }
+ return ret_ref;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_new(uint32_tArray elems) {
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret = MALLOC(sizeof(LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * ret->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ void* arr_elem_ptr = (void*)(((uint64_t)arr_elem) & ~1);
+ CHECK_ACCESS(arr_elem_ptr);
+ LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ arr_elem_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arr_elem_ptr);
+ arr_elem_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(((uint64_t)arr_elem) & ~1));
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
+ LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_NodeAnnouncementZ_new(uint32_tArray elems) {
+ LDKCVec_NodeAnnouncementZ *ret = MALLOC(sizeof(LDKCVec_NodeAnnouncementZ), "LDKCVec_NodeAnnouncementZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKNodeAnnouncement) * ret->datalen, "LDKCVec_NodeAnnouncementZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ LDKNodeAnnouncement arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = NodeAnnouncement_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
+ LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_CVec_u8ZPeerHandleErrorZ*)arg)->result_ok;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKCVec_u8Z res_var = (*val->contents.result);
+ int8_tArray res_arr = init_arr(res_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(res_arr + 4), res_var.data, res_var.datalen);
+ return res_arr;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CVec_u8ZPeerHandleErrorZ_get_err(uint32_t arg) {
+ LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKPeerHandleError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NonePeerHandleErrorZ*)arg)->result_ok;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NonePeerHandleErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKPeerHandleError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_boolPeerHandleErrorZ*)arg)->result_ok;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_boolPeerHandleErrorZ_get_err(uint32_t arg) {
+ LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKPeerHandleError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NodeIdDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNodeId res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeIdDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+typedef struct LDKAccess_JCalls {
+ atomic_size_t refcnt;
+ uint32_t get_utxo_meth;
+} LDKAccess_JCalls;
+static void LDKAccess_JCalls_free(void* this_arg) {
+ LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->get_utxo_meth);
+ FREE(j_calls);
+ }
+}
+LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
+ LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
+ int8_tArray genesis_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(genesis_hash_arr + 4), *genesis_hash, 32);
+ uint32_t ret = js_invoke_function_2(j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
+ ret_conv = CResult_TxOutAccessErrorZ_clone((LDKCResult_TxOutAccessErrorZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
+ LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKAccess LDKAccess_init (/*TODO: JS Object Reference */void* o) {
+ LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKAccess ret = {
+ .this_arg = (void*) calls,
+ .get_utxo = get_utxo_LDKAccess_jcall,
+ .free = LDKAccess_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKAccess_new(/*TODO: JS Object Reference */void* o) {
+ LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
+ *res_ptr = LDKAccess_init(o);
+ return (long)res_ptr;
+}
+uint32_t __attribute__((visibility("default"))) TS_Access_get_utxo(uint32_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
+ unsigned char genesis_hash_arr[32];
+ CHECK(*((uint32_t*)genesis_hash) == 32);
+ memcpy(genesis_hash_arr, (uint8_t*)(genesis_hash + 4), 32);
+ unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
+ LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
+ *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
+ return (uint64_t)ret_conv;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_AccessZ_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_AccessZ_Some: {
+ LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
+ *some_ret = obj->some;
+ // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
+ return 0 /* LDKCOption_AccessZ - Some */; (void) (uint64_t)some_ret;
+ }
+ case LDKCOption_AccessZ_None: {
+ return 0 /* LDKCOption_AccessZ - None */;
+ }
+ default: abort();
+ }
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_DirectionalChannelInfoDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKDirectionalChannelInfo res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_DirectionalChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ChannelInfoDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKChannelInfo res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelInfoDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_RoutingFeesDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKRoutingFees res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RoutingFeesDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNodeAnnouncementInfo res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementInfoDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_u64Z_new(int64_tArray elems) {
+ LDKCVec_u64Z *ret = MALLOC(sizeof(LDKCVec_u64Z), "LDKCVec_u64Z");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(uint64_t) * ret->datalen, "LDKCVec_u64Z Data");
+ int64_t *java_elems = (int64_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ ret->data[i] = java_elems[i];
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
+ LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
+ memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NodeInfoDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNodeInfo res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeInfoDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NetworkGraphDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNetworkGraph res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NetworkGraphDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_CVec_NetAddressZZ_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_CVec_NetAddressZZ_Some: {
+ LDKCVec_NetAddressZ some_var = obj->some;
+ uint32_tArray some_arr = NULL;
+ some_arr = init_arr(some_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *some_arr_ptr = (uint32_t*)(some_arr + 4);
+ for (size_t m = 0; m < some_var.datalen; m++) {
+ uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
+ some_arr_ptr[m] = some_conv_12_ref;
+ }
+
+ return 0 /* LDKCOption_CVec_NetAddressZZ - Some */; (void) some_arr;
+ }
+ case LDKCOption_CVec_NetAddressZZ_None: {
+ return 0 /* LDKCOption_CVec_NetAddressZZ - None */;
+ }
+ default: abort();
+ }
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NetAddressDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NetAddressDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_UpdateAddHTLCZ_new(uint32_tArray elems) {
+ LDKCVec_UpdateAddHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateAddHTLCZ), "LDKCVec_UpdateAddHTLCZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKUpdateAddHTLC) * ret->datalen, "LDKCVec_UpdateAddHTLCZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ LDKUpdateAddHTLC arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = UpdateAddHTLC_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
+ LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_UpdateFulfillHTLCZ_new(uint32_tArray elems) {
+ LDKCVec_UpdateFulfillHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFulfillHTLCZ), "LDKCVec_UpdateFulfillHTLCZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * ret->datalen, "LDKCVec_UpdateFulfillHTLCZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ LDKUpdateFulfillHTLC arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = UpdateFulfillHTLC_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
+ LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailHTLCZ_new(uint32_tArray elems) {
+ LDKCVec_UpdateFailHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailHTLCZ), "LDKCVec_UpdateFailHTLCZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKUpdateFailHTLC) * ret->datalen, "LDKCVec_UpdateFailHTLCZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ LDKUpdateFailHTLC arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = UpdateFailHTLC_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
+ LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_UpdateFailMalformedHTLCZ_new(uint32_tArray elems) {
+ LDKCVec_UpdateFailMalformedHTLCZ *ret = MALLOC(sizeof(LDKCVec_UpdateFailMalformedHTLCZ), "LDKCVec_UpdateFailMalformedHTLCZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * ret->datalen, "LDKCVec_UpdateFailMalformedHTLCZ Data");
+ uint32_t *java_elems = (uint32_t*)(elems + 4);
+ for (size_t i = 0; i < ret->datalen; i++) {
+ uint32_t arr_elem = java_elems[i];
+ LDKUpdateFailMalformedHTLC arr_elem_conv;
+ arr_elem_conv.inner = (void*)(arr_elem & (~1));
+ arr_elem_conv.is_owned = (arr_elem & 1) || (arr_elem == 0);
+ arr_elem_conv = UpdateFailMalformedHTLC_clone(&arr_elem_conv);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (uint64_t)ret;
+}
+static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
+ LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
+ }
+ return ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_AcceptChannelDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKAcceptChannel res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_AcceptChannelDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_AnnouncementSignaturesDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKAnnouncementSignatures res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_AnnouncementSignaturesDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ChannelReestablishDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKChannelReestablish res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelReestablishDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ClosingSignedDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKClosingSigned res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKClosingSignedFeeRange res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_CommitmentSignedDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKCommitmentSigned res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_CommitmentSignedDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_FundingCreatedDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKFundingCreated res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_FundingCreatedDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_FundingSignedDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKFundingSigned res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_FundingSignedDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_FundingLockedDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKFundingLocked res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_FundingLockedDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_InitDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKInit res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InitDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_OpenChannelDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKOpenChannel res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_OpenChannelDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_RevokeAndACKDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKRevokeAndACK res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_RevokeAndACKDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ShutdownDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKShutdown res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ShutdownDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_UpdateFailHTLCDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUpdateFailHTLC res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailHTLCDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_UpdateFeeDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUpdateFee res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateFeeDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUpdateFulfillHTLC res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateFulfillHTLCDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_UpdateAddHTLCDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUpdateAddHTLC res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UpdateAddHTLCDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_PingDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKPing res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PingDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_PongDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKPong res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_PongDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ChannelAnnouncementDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKChannelAnnouncement res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUnsignedChannelUpdate res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ChannelUpdateDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKChannelUpdate res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ChannelUpdateDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ErrorMessageDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKErrorMessage res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ErrorMessageDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NodeAnnouncementDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKNodeAnnouncement res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NodeAnnouncementDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_QueryShortChannelIdsDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKQueryShortChannelIds res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_QueryShortChannelIdsDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_QueryChannelRangeDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKQueryChannelRange res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_QueryChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_ReplyChannelRangeDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKReplyChannelRange res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_ReplyChannelRangeDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_GossipTimestampFilterDecodeErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKGossipTimestampFilter res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_GossipTimestampFilterDecodeErrorZ_get_err(uint32_t arg) {
+ LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ LDKDecodeError err_var = (*val->contents.err);
+ uint64_t err_ref = 0;
+ CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ err_ref = (uint64_t)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKSignOrCreationError_ref_from_ptr(uint32_t ptr) {
+ LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKSignOrCreationError_SignError: {
+ return 0 /* LDKSignOrCreationError - SignError */;
+ }
+ case LDKSignOrCreationError_CreationError: {
+ uint32_t creation_error_conv = LDKCreationError_to_js(obj->creation_error);
+ return 0 /* LDKSignOrCreationError - CreationError */; (void) creation_error_conv;
+ }
+ default: abort();
+ }
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_InvoiceSignOrCreationErrorZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_ok(uint32_t arg) {
+ LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKInvoice res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_InvoiceSignOrCreationErrorZ_get_err(uint32_t arg) {
+ LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
+ return err_ref;
+}
+typedef struct LDKFilter_JCalls {
+ atomic_size_t refcnt;
+ uint32_t register_tx_meth;
+ uint32_t register_output_meth;
+} LDKFilter_JCalls;
+static void LDKFilter_JCalls_free(void* this_arg) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
+ js_free(j_calls->register_tx_meth);
+ js_free(j_calls->register_output_meth);
+ FREE(j_calls);
+ }
+}
+void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ int8_tArray txid_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(txid_arr + 4), *txid, 32);
+ LDKu8slice script_pubkey_var = script_pubkey;
+ int8_tArray script_pubkey_arr = init_arr(script_pubkey_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(script_pubkey_arr + 4), script_pubkey_var.data, script_pubkey_var.datalen);
+ js_invoke_function_2(j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
+}
+LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
+ LDKWatchedOutput output_var = output;
+ uint64_t output_ref = 0;
+ CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ output_ref = (uint64_t)output_var.inner;
+ if (output_var.is_owned) {
+ output_ref |= 1;
+ }
+ uint32_t ret = js_invoke_function_1(j_calls->register_output_meth, output_ref);
+ void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
+ CHECK_ACCESS(ret_ptr);
+ LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
+ ret_conv = COption_C2Tuple_usizeTransactionZZ_clone((LDKCOption_C2Tuple_usizeTransactionZZ*)(((uint64_t)ret) & ~1));
+ return ret_conv;
+}
+static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
+ LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+}
+static inline LDKFilter LDKFilter_init (/*TODO: JS Object Reference */void* o) {
+ LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
+ atomic_init(&calls->refcnt, 1);
+ //TODO: Assign calls->o from o
+
+ LDKFilter ret = {
+ .this_arg = (void*) calls,
+ .register_tx = register_tx_LDKFilter_jcall,
+ .register_output = register_output_LDKFilter_jcall,
+ .free = LDKFilter_JCalls_free,
+ };
+ return ret;
+}
+long __attribute__((visibility("default"))) TS_LDKFilter_new(/*TODO: JS Object Reference */void* o) {
+ LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
+ *res_ptr = LDKFilter_init(o);
+ return (long)res_ptr;
+}
+void __attribute__((visibility("default"))) TS_Filter_register_tx(uint32_t this_arg, int8_tArray txid, int8_tArray script_pubkey) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
+ unsigned char txid_arr[32];
+ CHECK(*((uint32_t*)txid) == 32);
+ memcpy(txid_arr, (uint8_t*)(txid + 4), 32);
+ unsigned char (*txid_ref)[32] = &txid_arr;
+ LDKu8slice script_pubkey_ref;
+ script_pubkey_ref.datalen = *((uint32_t*)script_pubkey);
+ script_pubkey_ref.data = (int8_t*)(script_pubkey + 4);
+ (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
+}
+
+uint32_t __attribute__((visibility("default"))) TS_Filter_register_output(uint32_t this_arg, uint32_t output) {
+ void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
+ if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
+ LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
+ LDKWatchedOutput output_conv;
+ output_conv.inner = (void*)(output & (~1));
+ output_conv.is_owned = (output & 1) || (output == 0);
+ output_conv = WatchedOutput_clone(&output_conv);
+ LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
+ *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
+ uint64_t ret_ref = (uint64_t)ret_copy;
+ return ret_ref;
+}
+
+uint32_t __attribute__((visibility("default"))) TS_LDKCOption_FilterZ_ref_from_ptr(uint32_t ptr) {
+ LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
+ switch(obj->tag) {
+ case LDKCOption_FilterZ_Some: {
+ LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
+ *some_ret = obj->some;
+ // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
+ return 0 /* LDKCOption_FilterZ - Some */; (void) (uint64_t)some_ret;
+ }
+ case LDKCOption_FilterZ_None: {
+ return 0 /* LDKCOption_FilterZ - None */;
+ }
+ default: abort();
+ }
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_LockedChannelMonitorNoneZ*)arg)->result_ok;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_ok(uint32_t arg) {
+ LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ LDKLockedChannelMonitor res_var = (*val->contents.result);
+ uint64_t res_ref = 0;
+ CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ res_ref = (uint64_t)res_var.inner & ~1;
+ return res_ref;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_LockedChannelMonitorNoneZ_get_err(uint32_t arg) {
+ LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
+ CHECK(!val->result_ok);