+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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKErrorAction_ref_from_ptr(uint32_t ptr) {
+ LDKErrorAction *obj = (LDKErrorAction*)ptr;
+ switch(obj->tag) {
+ case LDKErrorAction_DisconnectPeer: {
+ LDKErrorMessage msg_var = obj->disconnect_peer.msg;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner & ~1;
+ return 0 /* LDKErrorAction - DisconnectPeer */; (void) msg_ref;
+ }
+ case LDKErrorAction_IgnoreError: {
+ return 0 /* LDKErrorAction - IgnoreError */;
+ }
+ case LDKErrorAction_SendErrorMessage: {
+ LDKErrorMessage msg_var = obj->send_error_message.msg;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner & ~1;
+ return 0 /* LDKErrorAction - SendErrorMessage */; (void) msg_ref;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKHTLCFailChannelUpdate_ref_from_ptr(uint32_t ptr) {
+ LDKHTLCFailChannelUpdate *obj = (LDKHTLCFailChannelUpdate*)ptr;
+ switch(obj->tag) {
+ case LDKHTLCFailChannelUpdate_ChannelUpdateMessage: {
+ LDKChannelUpdate msg_var = obj->channel_update_message.msg;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner & ~1;
+ return 0 /* LDKHTLCFailChannelUpdate - ChannelUpdateMessage */; (void) msg_ref;
+ }
+ case LDKHTLCFailChannelUpdate_ChannelClosed: {
+ return 0 /* LDKHTLCFailChannelUpdate - ChannelClosed */; (void) obj->channel_closed.short_channel_id; (void) obj->channel_closed.is_permanent;
+ }
+ case LDKHTLCFailChannelUpdate_NodeFailure: {
+ int8_tArray node_id_arr = init_arr(33, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(node_id_arr + 4), obj->node_failure.node_id.compressed_form, 33);
+ return 0 /* LDKHTLCFailChannelUpdate - NodeFailure */; (void) node_id_arr; (void) obj->node_failure.is_permanent;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKMessageSendEvent_ref_from_ptr(uint32_t ptr) {
+ LDKMessageSendEvent *obj = (LDKMessageSendEvent*)ptr;
+ 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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long updates_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner & ~1;
+ LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
+ CHECK((((long)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long update_msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - BroadcastNodeAnnouncement */; (void) msg_ref;
+ }
+ case LDKMessageSendEvent_BroadcastChannelUpdate: {
+ LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - BroadcastChannelUpdate */; (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);
+ long action_ref = ((long)&obj->handle_error.action) | 1;
+ return 0 /* LDKMessageSendEvent - HandleError */; (void) node_id_arr; (void) action_ref;
+ }
+ case LDKMessageSendEvent_PaymentFailureNetworkUpdate: {
+ long update_ref = ((long)&obj->payment_failure_network_update.update) | 1;
+ return 0 /* LDKMessageSendEvent - PaymentFailureNetworkUpdate */; (void) update_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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)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;
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner & ~1;
+ return 0 /* LDKMessageSendEvent - SendShortIdsQuery */; (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];
+ LDKMessageSendEvent arr_elem_conv = *(LDKMessageSendEvent*)(((uint64_t)arr_elem) & ~1);
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (long)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_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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKNetAddress_ref_from_ptr(uint32_t ptr) {
+ LDKNetAddress *obj = (LDKNetAddress*)ptr;
+ 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];
+ LDKNetAddress arr_elem_conv = *(LDKNetAddress*)(((uint64_t)arr_elem) & ~1);
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (long)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;
+}
+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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)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 (long)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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_new(int64_t a, int8_tArray b) {
+ LDKC2Tuple_usizeTransactionZ* ret = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
+ ret->a = a;
+ LDKTransaction b_ref;
+ b_ref.datalen = *((uint32_t*)b);
+ b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
+ memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
+ b_ref.data_is_owned = false;
+ ret->b = b_ref;
+ return (long)ret;
+}
+int64_t __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_a(uint32_t ptr) {
+ LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
+ return tuple->a;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_usizeTransactionZ_get_b(uint32_t ptr) {
+ LDKC2Tuple_usizeTransactionZ *tuple = (LDKC2Tuple_usizeTransactionZ*)(ptr & ~1);
+ LDKTransaction b_var = tuple->b;
+ int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
+ return b_arr;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_C2Tuple_usizeTransactionZZ_new(uint32_tArray elems) {
+ LDKCVec_C2Tuple_usizeTransactionZZ *ret = MALLOC(sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "LDKCVec_C2Tuple_usizeTransactionZZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * ret->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ 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];
+ LDKC2Tuple_usizeTransactionZ arr_elem_conv = *(LDKC2Tuple_usizeTransactionZ*)(((uint64_t)arr_elem) & ~1);
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (long)ret;
+}
+jboolean __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_result_ok(uint32_t arg) {
+ return ((LDKCResult_NoneChannelMonitorUpdateErrZ*)arg)->result_ok;
+}
+void __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_ok(uint32_t arg) {
+ LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
+ CHECK(val->result_ok);
+ return *val->contents.result;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCResult_NoneChannelMonitorUpdateErrZ_get_err(uint32_t arg) {
+ LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
+ CHECK(!val->result_ok);
+ uint32_t err_conv = LDKChannelMonitorUpdateErr_to_js((*val->contents.err));
+ return err_conv;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKMonitorEvent_ref_from_ptr(uint32_t ptr) {
+ LDKMonitorEvent *obj = (LDKMonitorEvent*)ptr;
+ switch(obj->tag) {
+ case LDKMonitorEvent_HTLCEvent: {
+ return 0 /* LDKMonitorEvent - HTLCEvent */;
+ }
+ case LDKMonitorEvent_CommitmentTxBroadcasted: {
+ return 0 /* LDKMonitorEvent - CommitmentTxBroadcasted */;
+ }
+ default: abort();
+ }
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKCVec_MonitorEventZ_new(uint32_tArray elems) {
+ LDKCVec_MonitorEventZ *ret = MALLOC(sizeof(LDKCVec_MonitorEventZ), "LDKCVec_MonitorEventZ");
+ ret->datalen = *((uint32_t*)elems);
+ if (ret->datalen == 0) {
+ ret->data = NULL;
+ } else {
+ ret->data = MALLOC(sizeof(LDKMonitorEvent) * ret->datalen, "LDKCVec_MonitorEventZ 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];
+ LDKMonitorEvent arr_elem_conv = *(LDKMonitorEvent*)(((uint64_t)arr_elem) & ~1);
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (long)ret;
+}
+static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
+ LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
+ for (size_t i = 0; i < ret.datalen; i++) {
+ ret.data[i] = MonitorEvent_clone(&orig->data[i]);
+ }
+ return ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKSpendableOutputDescriptor_ref_from_ptr(uint32_t ptr) {
+ LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)ptr;
+ switch(obj->tag) {
+ case LDKSpendableOutputDescriptor_StaticOutput: {
+ LDKOutPoint outpoint_var = obj->static_output.outpoint;
+ CHECK((((long)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long outpoint_ref = (long)outpoint_var.inner & ~1;
+ long output_ref = ((long)&obj->static_output.output) | 1;
+ return 0 /* LDKSpendableOutputDescriptor - StaticOutput */; (void) outpoint_ref; (void) (long)output_ref;
+ }
+ case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
+ return 0 /* LDKSpendableOutputDescriptor - DelayedPaymentOutput */;
+ }
+ case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
+ return 0 /* LDKSpendableOutputDescriptor - StaticPaymentOutput */;
+ }
+ default: abort();
+ }
+}
+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];
+ LDKSpendableOutputDescriptor arr_elem_conv = *(LDKSpendableOutputDescriptor*)(((uint64_t)arr_elem) & ~1);
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (long)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_LDKEvent_ref_from_ptr(uint32_t ptr) {
+ LDKEvent *obj = (LDKEvent*)ptr;
+ 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_FundingBroadcastSafe: {
+ LDKOutPoint funding_txo_var = obj->funding_broadcast_safe.funding_txo;
+ CHECK((((long)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long funding_txo_ref = (long)funding_txo_var.inner & ~1;
+ return 0 /* LDKEvent - FundingBroadcastSafe */; (void) funding_txo_ref; (void) obj->funding_broadcast_safe.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);
+ int8_tArray payment_secret_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_secret_arr + 4), obj->payment_received.payment_secret.data, 32);
+ return 0 /* LDKEvent - PaymentReceived */; (void) payment_hash_arr; (void) payment_secret_arr; (void) obj->payment_received.amt;
+ }
+ case LDKEvent_PaymentSent: {
+ 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);
+ return 0 /* LDKEvent - PaymentSent */; (void) payment_preimage_arr;
+ }
+ case LDKEvent_PaymentFailed: {
+ int8_tArray payment_hash_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(payment_hash_arr + 4), obj->payment_failed.payment_hash.data, 32);
+ return 0 /* LDKEvent - PaymentFailed */; (void) payment_hash_arr; (void) obj->payment_failed.rejected_by_dest;
+ }
+ 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 = 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++) {
+ long outputs_conv_27_ref = ((long)&outputs_var.data[b]) | 1;
+ outputs_arr_ptr[b] = outputs_conv_27_ref;
+ }
+ return 0 /* LDKEvent - SpendableOutputs */; (void) outputs_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];
+ LDKEvent arr_elem_conv = *(LDKEvent*)(((uint64_t)arr_elem) & ~1);
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (long)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;
+}
+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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)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);
+ CHECK((((long)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long res_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)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);
+ CHECK((((long)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long err_ref = (long)err_var.inner & ~1;
+ return err_ref;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_new(uint32_t a, int8_tArray b) {
+ LDKC2Tuple_OutPointScriptZ* ret = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
+ LDKOutPoint a_conv;
+ a_conv.inner = (void*)(a & (~1));
+ a_conv.is_owned = (a & 1) || (a == 0);
+ a_conv = OutPoint_clone(&a_conv);
+ ret->a = a_conv;
+ LDKCVec_u8Z b_ref;
+ b_ref.datalen = *((uint32_t*)b);
+ b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
+ memcpy(b_ref.data, (uint8_t*)(b + 4), b_ref.datalen);
+ ret->b = b_ref;
+ return (long)ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_a(uint32_t ptr) {
+ LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
+ LDKOutPoint a_var = tuple->a;
+ CHECK((((long)a_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&a_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long a_ref = (long)a_var.inner & ~1;
+ return a_ref;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_OutPointScriptZ_get_b(uint32_t ptr) {
+ LDKC2Tuple_OutPointScriptZ *tuple = (LDKC2Tuple_OutPointScriptZ*)(ptr & ~1);
+ LDKCVec_u8Z b_var = tuple->b;
+ int8_tArray b_arr = init_arr(b_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(b_arr + 4), b_var.data, b_var.datalen);
+ return b_arr;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_new(int32_t a, uint32_t b) {
+ LDKC2Tuple_u32TxOutZ* ret = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
+ ret->a = a;
+ LDKTxOut b_conv = *(LDKTxOut*)(((uint64_t)b) & ~1);
+ FREE((void*)b);
+ ret->b = b_conv;
+ return (long)ret;
+}
+int32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_a(uint32_t ptr) {
+ LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
+ return tuple->a;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_u32TxOutZ_get_b(uint32_t ptr) {
+ LDKC2Tuple_u32TxOutZ *tuple = (LDKC2Tuple_u32TxOutZ*)(ptr & ~1);
+ long b_ref = ((long)&tuple->b) | 1;
+ return (long)b_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];
+ LDKC2Tuple_u32TxOutZ arr_elem_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)arr_elem) & ~1);
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (long)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;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(int8_tArray a, uint32_tArray b) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
+ LDKThirtyTwoBytes a_ref;
+ CHECK(*((uint32_t*)a) == 32);
+ memcpy(a_ref.data, (uint8_t*)(a + 4), 32);
+ ret->a = a_ref;
+ LDKCVec_C2Tuple_u32TxOutZZ b_constr;
+ b_constr.datalen = *((uint32_t*)b);
+ if (b_constr.datalen > 0)
+ b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
+ else
+ b_constr.data = NULL;
+ uint32_t* b_vals = (uint32_t*)(b + 4);
+ for (size_t z = 0; z < b_constr.datalen; z++) {
+ uint32_t b_conv_25 = b_vals[z];
+ LDKC2Tuple_u32TxOutZ b_conv_25_conv = *(LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_25) & ~1);
+ FREE((void*)b_conv_25);
+ b_constr.data[z] = b_conv_25_conv;
+ }
+ ret->b = b_constr;
+ return (long)ret;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(uint32_t ptr) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
+ int8_tArray a_arr = init_arr(32, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(a_arr + 4), tuple->a.data, 32);
+ return a_arr;
+}
+uint32_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(uint32_t ptr) {
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *tuple = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(ptr & ~1);
+ LDKCVec_C2Tuple_u32TxOutZZ b_var = tuple->b;
+ uint32_tArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native uint32_tArray Bytes");
+ uint32_t *b_arr_ptr = (uint32_t*)(b_arr + 4);
+ for (size_t z = 0; z < b_var.datalen; z++) {
+ long b_conv_25_ref = (long)(&b_var.data[z]) | 1;
+ b_arr_ptr[z] = b_conv_25_ref;
+ }
+ return b_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];
+ LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ arr_elem_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(((uint64_t)arr_elem) & ~1);
+ FREE((void*)arr_elem);
+ ret->data[i] = arr_elem_conv;
+ }
+ }
+ return (long)ret;
+}
+uint32_t __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_new(int8_tArray a, ptrArray b) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ* ret = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
+ LDKSignature a_ref;
+ CHECK(*((uint32_t*)a) == 64);
+ memcpy(a_ref.compact_form, (uint8_t*)(a + 4), 64);
+ ret->a = a_ref;
+ LDKCVec_SignatureZ b_constr;
+ b_constr.datalen = *((uint32_t*)b);
+ if (b_constr.datalen > 0)
+ b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
+ else
+ b_constr.data = NULL;
+ int8_tArray* b_vals = (int8_tArray*)(b + 4);
+ for (size_t m = 0; m < b_constr.datalen; m++) {
+ int8_tArray b_conv_12 = b_vals[m];
+ LDKSignature b_conv_12_ref;
+ CHECK(*((uint32_t*)b_conv_12) == 64);
+ memcpy(b_conv_12_ref.compact_form, (uint8_t*)(b_conv_12 + 4), 64);
+ b_constr.data[m] = b_conv_12_ref;
+ }
+ ret->b = b_constr;
+ return (long)ret;
+}
+int8_tArray __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_a(uint32_t ptr) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
+ int8_tArray a_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(a_arr + 4), tuple->a.compact_form, 64);
+ return a_arr;
+}
+ptrArray __attribute__((visibility("default"))) TS_LDKC2Tuple_SignatureCVec_SignatureZZ_get_b(uint32_t ptr) {
+ LDKC2Tuple_SignatureCVec_SignatureZZ *tuple = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(ptr & ~1);
+ LDKCVec_SignatureZ b_var = tuple->b;
+ ptrArray b_arr = init_arr(b_var.datalen, sizeof(uint32_t), "Native ptrArray Bytes");
+ int8_tArray *b_arr_ptr = (int8_tArray*)(b_arr + 4);
+ for (size_t m = 0; m < b_var.datalen; m++) {
+ int8_tArray b_conv_12_arr = init_arr(64, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(b_conv_12_arr + 4), b_var.data[m].compact_form, 64);
+ b_arr_ptr[m] = b_conv_12_arr;
+ }
+ return b_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);
+ long res_ref = (long)(&(*val->contents.result)) | 1;
+ return res_ref;
+}
+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 LDKSign_JCalls {
+ atomic_size_t refcnt;
+ uint32_t get_per_commitment_point_meth;
+ uint32_t release_commitment_secret_meth;
+ uint32_t channel_keys_id_meth;
+ uint32_t sign_counterparty_commitment_meth;
+ uint32_t sign_holder_commitment_and_htlcs_meth;
+ uint32_t sign_justice_transaction_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;
+ 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->get_per_commitment_point_meth);
+ js_free(j_calls->release_commitment_secret_meth);
+ js_free(j_calls->channel_keys_id_meth);
+ js_free(j_calls->sign_counterparty_commitment_meth);
+ js_free(j_calls->sign_holder_commitment_and_htlcs_meth);
+ js_free(j_calls->sign_justice_transaction_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);
+ js_free(j_calls->write_meth);
+ FREE(j_calls);
+ }
+}
+LDKPublicKey get_per_commitment_point_jcall(const void* this_arg, uint64_t idx) {
+ LDKSign_JCalls *j_calls = (LDKSign_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_jcall(const void* this_arg, uint64_t idx) {
+ LDKSign_JCalls *j_calls = (LDKSign_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;
+}
+LDKThirtyTwoBytes channel_keys_id_jcall(const void* this_arg) {
+ LDKSign_JCalls *j_calls = (LDKSign_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_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
+ commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
+ CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long commitment_tx_ref = (long)commitment_tx_var.inner;
+ if (commitment_tx_var.is_owned) {
+ commitment_tx_ref |= 1;
+ }
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
+ return ret_conv;
+}
+LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
+ commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
+ CHECK((((long)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long commitment_tx_ref = (long)commitment_tx_var.inner;
+ if (commitment_tx_var.is_owned) {
+ commitment_tx_ref |= 1;
+ }
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)js_invoke_function_1(j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
+ LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone((LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_justice_transaction_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
+ LDKSign_JCalls *j_calls = (LDKSign_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;
+ htlc_var = HTLCOutputInCommitment_clone(htlc);
+ CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long htlc_ref = (long)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_justice_transaction_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
+ LDKSign_JCalls *j_calls = (LDKSign_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;
+ htlc_var = HTLCOutputInCommitment_clone(htlc);
+ CHECK((((long)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long htlc_ref = (long)htlc_var.inner;
+ if (htlc_var.is_owned) {
+ htlc_ref |= 1;
+ }
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_5(j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_closing_transaction_jcall(const void* this_arg, LDKTransaction closing_tx) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ LDKTransaction closing_tx_var = closing_tx;
+ int8_tArray closing_tx_arr = init_arr(closing_tx_var.datalen, sizeof(uint8_t), "Native int8_tArray Bytes");
+ memcpy((uint8_t*)(closing_tx_arr + 4), closing_tx_var.data, closing_tx_var.datalen);
+ Transaction_free(closing_tx_var);
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_closing_transaction_meth, closing_tx_arr);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
+ return ret_conv;
+}
+LDKCResult_SignatureNoneZ sign_channel_announcement_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ LDKUnsignedChannelAnnouncement msg_var = *msg;
+ msg_var = UnsignedChannelAnnouncement_clone(msg);
+ CHECK((((long)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long msg_ref = (long)msg_var.inner;
+ if (msg_var.is_owned) {
+ msg_ref |= 1;
+ }
+ LDKCResult_SignatureNoneZ* ret = (LDKCResult_SignatureNoneZ*)js_invoke_function_1(j_calls->sign_channel_announcement_meth, msg_ref);
+ LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(((uint64_t)ret) & ~1);
+ ret_conv = CResult_SignatureNoneZ_clone((LDKCResult_SignatureNoneZ*)ret);
+ return ret_conv;
+}
+void ready_channel_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
+ channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
+ CHECK((((long)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
+ CHECK((((long)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
+ long channel_parameters_ref = (long)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);
+}
+LDKCVec_u8Z write_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_clone(const void* this_arg) {
+ LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
+ atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
+ return (void*) this_arg;
+}
+static inline LDKSign LDKSign_init (/*TODO: JS Object Reference */void* o, 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,
+ .get_per_commitment_point = get_per_commitment_point_jcall,
+ .release_commitment_secret = release_commitment_secret_jcall,
+ .channel_keys_id = channel_keys_id_jcall,
+ .sign_counterparty_commitment = sign_counterparty_commitment_jcall,
+ .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_jcall,
+ .sign_justice_transaction = sign_justice_transaction_jcall,
+ .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_jcall,