From 49a4450d34d835487ac865879efe47cb9ddbec51 Mon Sep 17 00:00:00 2001 From: G8XSU <3442979+G8XSU@users.noreply.github.com> Date: Mon, 25 Nov 2024 12:05:09 -0800 Subject: [PATCH] Rename crates to have ldk-server- prefix. --- Cargo.lock | 58 +++++++++---------- Cargo.toml | 2 +- {cli => ldk-server-cli}/Cargo.toml | 4 +- {cli => ldk-server-cli}/src/main.rs | 6 +- {client => ldk-server-client}/Cargo.toml | 4 +- {client => ldk-server-client}/src/client.rs | 4 +- {client => ldk-server-client}/src/error.rs | 0 {client => ldk-server-client}/src/lib.rs | 6 +- {protos => ldk-server-protos}/Cargo.toml | 2 +- {protos => ldk-server-protos}/build.rs | 0 {protos => ldk-server-protos}/src/api.rs | 0 {protos => ldk-server-protos}/src/error.rs | 4 +- {protos => ldk-server-protos}/src/lib.rs | 0 .../src/proto/api.proto | 0 .../src/proto/error.proto | 0 .../src/proto/types.proto | 0 {protos => ldk-server-protos}/src/types.rs | 0 {server => ldk-server}/Cargo.toml | 2 +- .../src/api/bolt11_receive.rs | 2 +- {server => ldk-server}/src/api/bolt11_send.rs | 2 +- .../src/api/bolt12_receive.rs | 2 +- {server => ldk-server}/src/api/bolt12_send.rs | 2 +- .../src/api/close_channel.rs | 2 +- {server => ldk-server}/src/api/error.rs | 0 .../src/api/get_node_info.rs | 4 +- .../src/api/get_payment_details.rs | 2 +- .../src/api/list_channels.rs | 2 +- .../src/api/list_payments.rs | 2 +- {server => ldk-server}/src/api/mod.rs | 0 .../src/api/onchain_receive.rs | 2 +- .../src/api/onchain_send.rs | 2 +- .../src/api/open_channel.rs | 2 +- .../src/api/update_channel_config.rs | 6 +- {server => ldk-server}/src/io/mod.rs | 0 .../src/io/paginated_kv_store.rs | 0 {server => ldk-server}/src/main.rs | 0 {server => ldk-server}/src/service.rs | 0 {server => ldk-server}/src/util/mod.rs | 0 .../src/util/proto_adapter.rs | 56 ++++++++++-------- 39 files changed, 94 insertions(+), 86 deletions(-) rename {cli => ldk-server-cli}/Cargo.toml (81%) rename {cli => ldk-server-cli}/src/main.rs (96%) rename {client => ldk-server-client}/Cargo.toml (78%) rename {client => ldk-server-client}/src/client.rs (97%) rename {client => ldk-server-client}/src/error.rs (100%) rename {client => ldk-server-client}/src/lib.rs (58%) rename {protos => ldk-server-protos}/Cargo.toml (91%) rename {protos => ldk-server-protos}/build.rs (100%) rename {protos => ldk-server-protos}/src/api.rs (100%) rename {protos => ldk-server-protos}/src/error.rs (94%) rename {protos => ldk-server-protos}/src/lib.rs (100%) rename {protos => ldk-server-protos}/src/proto/api.proto (100%) rename {protos => ldk-server-protos}/src/proto/error.proto (100%) rename {protos => ldk-server-protos}/src/proto/types.proto (100%) rename {protos => ldk-server-protos}/src/types.rs (100%) rename {server => ldk-server}/Cargo.toml (93%) rename {server => ldk-server}/src/api/bolt11_receive.rs (89%) rename {server => ldk-server}/src/api/bolt11_send.rs (91%) rename {server => ldk-server}/src/api/bolt12_receive.rs (89%) rename {server => ldk-server}/src/api/bolt12_send.rs (92%) rename {server => ldk-server}/src/api/close_channel.rs (93%) rename {server => ldk-server}/src/api/error.rs (100%) rename {server => ldk-server}/src/api/get_node_info.rs (90%) rename {server => ldk-server}/src/api/get_payment_details.rs (89%) rename {server => ldk-server}/src/api/list_channels.rs (86%) rename {server => ldk-server}/src/api/list_payments.rs (86%) rename {server => ldk-server}/src/api/mod.rs (100%) rename {server => ldk-server}/src/api/onchain_receive.rs (83%) rename {server => ldk-server}/src/api/onchain_send.rs (92%) rename {server => ldk-server}/src/api/open_channel.rs (94%) rename {server => ldk-server}/src/api/update_channel_config.rs (91%) rename {server => ldk-server}/src/io/mod.rs (100%) rename {server => ldk-server}/src/io/paginated_kv_store.rs (100%) rename {server => ldk-server}/src/main.rs (100%) rename {server => ldk-server}/src/service.rs (100%) rename {server => ldk-server}/src/util/mod.rs (100%) rename {server => ldk-server}/src/util/proto_adapter.rs (72%) diff --git a/Cargo.lock b/Cargo.lock index 084674a..33c2133 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -385,26 +385,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "cli" -version = "0.1.0" -dependencies = [ - "clap", - "client", - "prost", - "tokio", -] - -[[package]] -name = "client" -version = "0.1.0" -dependencies = [ - "prost", - "protos", - "reqwest", - "tokio", -] - [[package]] name = "core-foundation" version = "0.9.4" @@ -964,13 +944,41 @@ dependencies = [ "hyper 1.4.1", "hyper-util", "ldk-node", + "ldk-server-protos", "prost", - "protos", "serde", "serde_json", "tokio", ] +[[package]] +name = "ldk-server-cli" +version = "0.1.0" +dependencies = [ + "clap", + "ldk-server-client", + "prost", + "tokio", +] + +[[package]] +name = "ldk-server-client" +version = "0.1.0" +dependencies = [ + "ldk-server-protos", + "prost", + "reqwest", + "tokio", +] + +[[package]] +name = "ldk-server-protos" +version = "0.1.0" +dependencies = [ + "prost", + "prost-build", +] + [[package]] name = "libc" version = "0.2.155" @@ -1351,14 +1359,6 @@ dependencies = [ "prost", ] -[[package]] -name = "protos" -version = "0.1.0" -dependencies = [ - "prost", - "prost-build", -] - [[package]] name = "quote" version = "1.0.36" diff --git a/Cargo.toml b/Cargo.toml index 61b420c..16d6ced 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [workspace] resolver = "2" -members = [ "cli", "client", "protos", "server"] +members = [ "ldk-server-cli", "ldk-server-client", "ldk-server-protos", "ldk-server"] [profile.release] panic = "abort" diff --git a/cli/Cargo.toml b/ldk-server-cli/Cargo.toml similarity index 81% rename from cli/Cargo.toml rename to ldk-server-cli/Cargo.toml index a8f9df7..a38ca83 100644 --- a/cli/Cargo.toml +++ b/ldk-server-cli/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "cli" +name = "ldk-server-cli" version = "0.1.0" edition = "2021" [dependencies] -client = { path = "../client" } +ldk-server-client = { path = "../ldk-server-client" } clap = { version = "4.0.5", default-features = false, features = ["derive", "std", "error-context", "suggestions", "help"] } tokio = { version = "1.38.0", default-features = false, features = ["rt-multi-thread", "macros"] } prost = { version = "0.11.6", default-features = false} diff --git a/cli/src/main.rs b/ldk-server-cli/src/main.rs similarity index 96% rename from cli/src/main.rs rename to ldk-server-cli/src/main.rs index b8fac37..4255735 100644 --- a/cli/src/main.rs +++ b/ldk-server-cli/src/main.rs @@ -1,7 +1,7 @@ use clap::{Parser, Subcommand}; -use client::client::LdkServerClient; -use client::error::LdkServerError; -use client::protos::api::{ +use ldk_server_client::client::LdkServerClient; +use ldk_server_client::error::LdkServerError; +use ldk_server_client::ldk_server_protos::api::{ Bolt11ReceiveRequest, Bolt11SendRequest, Bolt12ReceiveRequest, Bolt12SendRequest, OnchainReceiveRequest, OnchainSendRequest, OpenChannelRequest, }; diff --git a/client/Cargo.toml b/ldk-server-client/Cargo.toml similarity index 78% rename from client/Cargo.toml rename to ldk-server-client/Cargo.toml index dd823fc..616cc2d 100644 --- a/client/Cargo.toml +++ b/ldk-server-client/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "client" +name = "ldk-server-client" version = "0.1.0" edition = "2021" [dependencies] -protos = { path = "../protos" } +ldk-server-protos = { path = "../ldk-server-protos" } reqwest = { version = "0.11.13", default-features = false, features = ["rustls-tls"] } tokio = { version = "1.38.0", default-features = false } prost = { version = "0.11.6", default-features = false, features = ["std", "prost-derive"] } diff --git a/client/src/client.rs b/ldk-server-client/src/client.rs similarity index 97% rename from client/src/client.rs rename to ldk-server-client/src/client.rs index 2fb9c47..be9b15a 100644 --- a/client/src/client.rs +++ b/ldk-server-client/src/client.rs @@ -1,7 +1,7 @@ use prost::Message; use crate::error::LdkServerError; -use protos::api::{ +use ldk_server_protos::api::{ Bolt11ReceiveRequest, Bolt11ReceiveResponse, Bolt11SendRequest, Bolt11SendResponse, Bolt12ReceiveRequest, Bolt12ReceiveResponse, Bolt12SendRequest, Bolt12SendResponse, CloseChannelRequest, CloseChannelResponse, ListChannelsRequest, ListChannelsResponse, @@ -31,7 +31,7 @@ pub struct LdkServerClient { } impl LdkServerClient { - /// Constructs a [`LdkServerClient`] using `base_url` as the server endpoint. + /// Constructs a [`LdkServerClient`] using `base_url` as the ldk-server endpoint. pub fn new(base_url: String) -> Self { Self { base_url, client: Client::new() } } diff --git a/client/src/error.rs b/ldk-server-client/src/error.rs similarity index 100% rename from client/src/error.rs rename to ldk-server-client/src/error.rs diff --git a/client/src/lib.rs b/ldk-server-client/src/lib.rs similarity index 58% rename from client/src/lib.rs rename to ldk-server-client/src/lib.rs index 96d7938..19540ee 100644 --- a/client/src/lib.rs +++ b/ldk-server-client/src/lib.rs @@ -4,11 +4,11 @@ #![deny(rustdoc::private_intra_doc_links)] #![deny(missing_docs)] -/// Implements a client ([`client::LdkServerClient`]) to access a hosted instance of LDK Server. +/// Implements a ldk-ldk-server-client ([`client::LdkServerClient`]) to access a hosted instance of LDK Server. pub mod client; /// Implements the error type ([`error::LdkServerError`]) returned on interacting with [`client::LdkServerClient`] pub mod error; -/// Request/Response structs required for interacting with the client. -pub use protos; +/// Request/Response structs required for interacting with the ldk-ldk-server-client. +pub use ldk_server_protos; diff --git a/protos/Cargo.toml b/ldk-server-protos/Cargo.toml similarity index 91% rename from protos/Cargo.toml rename to ldk-server-protos/Cargo.toml index 7a69b66..5d16484 100644 --- a/protos/Cargo.toml +++ b/ldk-server-protos/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "protos" +name = "ldk-server-protos" version = "0.1.0" edition = "2021" diff --git a/protos/build.rs b/ldk-server-protos/build.rs similarity index 100% rename from protos/build.rs rename to ldk-server-protos/build.rs diff --git a/protos/src/api.rs b/ldk-server-protos/src/api.rs similarity index 100% rename from protos/src/api.rs rename to ldk-server-protos/src/api.rs diff --git a/protos/src/error.rs b/ldk-server-protos/src/error.rs similarity index 94% rename from protos/src/error.rs rename to ldk-server-protos/src/error.rs index a78c75a..e6e848f 100644 --- a/protos/src/error.rs +++ b/ldk-server-protos/src/error.rs @@ -20,7 +20,7 @@ pub struct ErrorResponse { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum ErrorCode { - /// Will neve be used as `error_code` by server. + /// Will neve be used as `error_code` by ldk-server. /// /// **Caution**: If a new type of `error_code` is introduced in the `ErrorCode` enum, `error_code` field will be set to /// `UnknownError`. @@ -35,7 +35,7 @@ pub enum ErrorCode { AuthError = 2, /// Used to represent an error while doing a Lightning operation. LightningError = 3, - /// Used when an internal server error occurred. The client is probably at no fault. + /// Used when an internal ldk-server error occurred. The ldk-ldk-server-client is probably at no fault. InternalServerError = 4, } impl ErrorCode { diff --git a/protos/src/lib.rs b/ldk-server-protos/src/lib.rs similarity index 100% rename from protos/src/lib.rs rename to ldk-server-protos/src/lib.rs diff --git a/protos/src/proto/api.proto b/ldk-server-protos/src/proto/api.proto similarity index 100% rename from protos/src/proto/api.proto rename to ldk-server-protos/src/proto/api.proto diff --git a/protos/src/proto/error.proto b/ldk-server-protos/src/proto/error.proto similarity index 100% rename from protos/src/proto/error.proto rename to ldk-server-protos/src/proto/error.proto diff --git a/protos/src/proto/types.proto b/ldk-server-protos/src/proto/types.proto similarity index 100% rename from protos/src/proto/types.proto rename to ldk-server-protos/src/proto/types.proto diff --git a/protos/src/types.rs b/ldk-server-protos/src/types.rs similarity index 100% rename from protos/src/types.rs rename to ldk-server-protos/src/types.rs diff --git a/server/Cargo.toml b/ldk-server/Cargo.toml similarity index 93% rename from server/Cargo.toml rename to ldk-server/Cargo.toml index daf71d8..984e207 100644 --- a/server/Cargo.toml +++ b/ldk-server/Cargo.toml @@ -12,6 +12,6 @@ http-body-util = { version = "0.1", default-features = false } hyper-util = { version = "0.1", default-features = false, features = ["server-graceful"] } tokio = { version = "1.38.0", default-features = false, features = ["time", "signal", "rt-multi-thread"] } prost = { version = "0.11.6", default-features = false, features = ["std"] } -protos = { path = "../protos" } +ldk-server-protos = { path = "../ldk-server-protos" } bytes = "1.4.0" hex = { package = "hex-conservative", version = "0.2.1", default-features = false } diff --git a/server/src/api/bolt11_receive.rs b/ldk-server/src/api/bolt11_receive.rs similarity index 89% rename from server/src/api/bolt11_receive.rs rename to ldk-server/src/api/bolt11_receive.rs index 7c8ef29..ff2c03f 100644 --- a/server/src/api/bolt11_receive.rs +++ b/ldk-server/src/api/bolt11_receive.rs @@ -1,5 +1,5 @@ use ldk_node::Node; -use protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse}; +use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse}; use std::sync::Arc; pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive"; diff --git a/server/src/api/bolt11_send.rs b/ldk-server/src/api/bolt11_send.rs similarity index 91% rename from server/src/api/bolt11_send.rs rename to ldk-server/src/api/bolt11_send.rs index 2376f16..8e12096 100644 --- a/server/src/api/bolt11_send.rs +++ b/ldk-server/src/api/bolt11_send.rs @@ -1,7 +1,7 @@ use bytes::Bytes; use ldk_node::lightning_invoice::Bolt11Invoice; use ldk_node::Node; -use protos::api::{Bolt11SendRequest, Bolt11SendResponse}; +use ldk_server_protos::api::{Bolt11SendRequest, Bolt11SendResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/bolt12_receive.rs b/ldk-server/src/api/bolt12_receive.rs similarity index 89% rename from server/src/api/bolt12_receive.rs rename to ldk-server/src/api/bolt12_receive.rs index 5d49531..8cac1b7 100644 --- a/server/src/api/bolt12_receive.rs +++ b/ldk-server/src/api/bolt12_receive.rs @@ -1,5 +1,5 @@ use ldk_node::Node; -use protos::api::{Bolt12ReceiveRequest, Bolt12ReceiveResponse}; +use ldk_server_protos::api::{Bolt12ReceiveRequest, Bolt12ReceiveResponse}; use std::sync::Arc; pub(crate) const BOLT12_RECEIVE_PATH: &str = "Bolt12Receive"; diff --git a/server/src/api/bolt12_send.rs b/ldk-server/src/api/bolt12_send.rs similarity index 92% rename from server/src/api/bolt12_send.rs rename to ldk-server/src/api/bolt12_send.rs index 423c579..ea0f85c 100644 --- a/server/src/api/bolt12_send.rs +++ b/ldk-server/src/api/bolt12_send.rs @@ -1,7 +1,7 @@ use bytes::Bytes; use ldk_node::lightning::offers::offer::Offer; use ldk_node::Node; -use protos::api::{Bolt12SendRequest, Bolt12SendResponse}; +use ldk_server_protos::api::{Bolt12SendRequest, Bolt12SendResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/close_channel.rs b/ldk-server/src/api/close_channel.rs similarity index 93% rename from server/src/api/close_channel.rs rename to ldk-server/src/api/close_channel.rs index e9f6e3d..d373535 100644 --- a/server/src/api/close_channel.rs +++ b/ldk-server/src/api/close_channel.rs @@ -1,6 +1,6 @@ use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::{Node, UserChannelId}; -use protos::api::{CloseChannelRequest, CloseChannelResponse}; +use ldk_server_protos::api::{CloseChannelRequest, CloseChannelResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/error.rs b/ldk-server/src/api/error.rs similarity index 100% rename from server/src/api/error.rs rename to ldk-server/src/api/error.rs diff --git a/server/src/api/get_node_info.rs b/ldk-server/src/api/get_node_info.rs similarity index 90% rename from server/src/api/get_node_info.rs rename to ldk-server/src/api/get_node_info.rs index eabc25e..ed612f8 100644 --- a/server/src/api/get_node_info.rs +++ b/ldk-server/src/api/get_node_info.rs @@ -1,6 +1,6 @@ use ldk_node::Node; -use protos::api::{GetNodeInfoRequest, GetNodeInfoResponse}; -use protos::types::BestBlock; +use ldk_server_protos::api::{GetNodeInfoRequest, GetNodeInfoResponse}; +use ldk_server_protos::types::BestBlock; use std::sync::Arc; pub(crate) const GET_NODE_INFO: &str = "GetNodeInfo"; diff --git a/server/src/api/get_payment_details.rs b/ldk-server/src/api/get_payment_details.rs similarity index 89% rename from server/src/api/get_payment_details.rs rename to ldk-server/src/api/get_payment_details.rs index d1f2734..6a43df2 100644 --- a/server/src/api/get_payment_details.rs +++ b/ldk-server/src/api/get_payment_details.rs @@ -2,7 +2,7 @@ use crate::util::proto_adapter::payment_to_proto; use hex::FromHex; use ldk_node::lightning::ln::channelmanager::PaymentId; use ldk_node::Node; -use protos::api::{GetPaymentDetailsRequest, GetPaymentDetailsResponse}; +use ldk_server_protos::api::{GetPaymentDetailsRequest, GetPaymentDetailsResponse}; use std::sync::Arc; pub(crate) const GET_PAYMENT_DETAILS_PATH: &str = "GetPaymentDetails"; diff --git a/server/src/api/list_channels.rs b/ldk-server/src/api/list_channels.rs similarity index 86% rename from server/src/api/list_channels.rs rename to ldk-server/src/api/list_channels.rs index 90520c5..318eb38 100644 --- a/server/src/api/list_channels.rs +++ b/ldk-server/src/api/list_channels.rs @@ -1,6 +1,6 @@ use crate::util::proto_adapter::channel_to_proto; use ldk_node::Node; -use protos::api::{ListChannelsRequest, ListChannelsResponse}; +use ldk_server_protos::api::{ListChannelsRequest, ListChannelsResponse}; use std::sync::Arc; pub(crate) const LIST_CHANNELS_PATH: &str = "ListChannels"; diff --git a/server/src/api/list_payments.rs b/ldk-server/src/api/list_payments.rs similarity index 86% rename from server/src/api/list_payments.rs rename to ldk-server/src/api/list_payments.rs index 671741d..89da42d 100644 --- a/server/src/api/list_payments.rs +++ b/ldk-server/src/api/list_payments.rs @@ -1,6 +1,6 @@ use crate::util::proto_adapter::payment_to_proto; use ldk_node::Node; -use protos::api::{ListPaymentsRequest, ListPaymentsResponse}; +use ldk_server_protos::api::{ListPaymentsRequest, ListPaymentsResponse}; use std::sync::Arc; pub(crate) const LIST_PAYMENTS_PATH: &str = "ListPayments"; diff --git a/server/src/api/mod.rs b/ldk-server/src/api/mod.rs similarity index 100% rename from server/src/api/mod.rs rename to ldk-server/src/api/mod.rs diff --git a/server/src/api/onchain_receive.rs b/ldk-server/src/api/onchain_receive.rs similarity index 83% rename from server/src/api/onchain_receive.rs rename to ldk-server/src/api/onchain_receive.rs index 884552f..b7d7676 100644 --- a/server/src/api/onchain_receive.rs +++ b/ldk-server/src/api/onchain_receive.rs @@ -1,5 +1,5 @@ use ldk_node::Node; -use protos::api::{OnchainReceiveRequest, OnchainReceiveResponse}; +use ldk_server_protos::api::{OnchainReceiveRequest, OnchainReceiveResponse}; use std::sync::Arc; pub(crate) const ONCHAIN_RECEIVE_PATH: &str = "OnchainReceive"; diff --git a/server/src/api/onchain_send.rs b/ldk-server/src/api/onchain_send.rs similarity index 92% rename from server/src/api/onchain_send.rs rename to ldk-server/src/api/onchain_send.rs index 7d9348f..fd1ef5f 100644 --- a/server/src/api/onchain_send.rs +++ b/ldk-server/src/api/onchain_send.rs @@ -1,6 +1,6 @@ use ldk_node::bitcoin::Address; use ldk_node::Node; -use protos::api::{OnchainSendRequest, OnchainSendResponse}; +use ldk_server_protos::api::{OnchainSendRequest, OnchainSendResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/open_channel.rs b/ldk-server/src/api/open_channel.rs similarity index 94% rename from server/src/api/open_channel.rs rename to ldk-server/src/api/open_channel.rs index 214746d..927ea0b 100644 --- a/server/src/api/open_channel.rs +++ b/ldk-server/src/api/open_channel.rs @@ -2,7 +2,7 @@ use bytes::Bytes; use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::lightning::ln::msgs::SocketAddress; use ldk_node::Node; -use protos::api::{OpenChannelRequest, OpenChannelResponse}; +use ldk_server_protos::api::{OpenChannelRequest, OpenChannelResponse}; use std::str::FromStr; use std::sync::Arc; diff --git a/server/src/api/update_channel_config.rs b/ldk-server/src/api/update_channel_config.rs similarity index 91% rename from server/src/api/update_channel_config.rs rename to ldk-server/src/api/update_channel_config.rs index 306cdbb..0d6c510 100644 --- a/server/src/api/update_channel_config.rs +++ b/ldk-server/src/api/update_channel_config.rs @@ -1,8 +1,8 @@ use ldk_node::bitcoin::secp256k1::PublicKey; use ldk_node::config::{ChannelConfig, MaxDustHTLCExposure}; use ldk_node::{Node, UserChannelId}; -use protos::api::{UpdateChannelConfigRequest, UpdateChannelConfigResponse}; -use protos::types::channel_config::MaxDustHtlcExposure; +use ldk_server_protos::api::{UpdateChannelConfigRequest, UpdateChannelConfigResponse}; +use ldk_server_protos::types::channel_config::MaxDustHtlcExposure; use std::str::FromStr; use std::sync::Arc; @@ -38,7 +38,7 @@ pub(crate) fn handle_update_channel_config_request( } fn build_updated_channel_config( - current_config: ChannelConfig, proto_channel_config: protos::types::ChannelConfig, + current_config: ChannelConfig, proto_channel_config: ldk_server_protos::types::ChannelConfig, ) -> ChannelConfig { let max_dust_htlc_exposure = proto_channel_config .max_dust_htlc_exposure diff --git a/server/src/io/mod.rs b/ldk-server/src/io/mod.rs similarity index 100% rename from server/src/io/mod.rs rename to ldk-server/src/io/mod.rs diff --git a/server/src/io/paginated_kv_store.rs b/ldk-server/src/io/paginated_kv_store.rs similarity index 100% rename from server/src/io/paginated_kv_store.rs rename to ldk-server/src/io/paginated_kv_store.rs diff --git a/server/src/main.rs b/ldk-server/src/main.rs similarity index 100% rename from server/src/main.rs rename to ldk-server/src/main.rs diff --git a/server/src/service.rs b/ldk-server/src/service.rs similarity index 100% rename from server/src/service.rs rename to ldk-server/src/service.rs diff --git a/server/src/util/mod.rs b/ldk-server/src/util/mod.rs similarity index 100% rename from server/src/util/mod.rs rename to ldk-server/src/util/mod.rs diff --git a/server/src/util/proto_adapter.rs b/ldk-server/src/util/proto_adapter.rs similarity index 72% rename from server/src/util/proto_adapter.rs rename to ldk-server/src/util/proto_adapter.rs index e785564..5446bc6 100644 --- a/server/src/util/proto_adapter.rs +++ b/ldk-server/src/util/proto_adapter.rs @@ -3,10 +3,10 @@ use hex::prelude::*; use ldk_node::config::{ChannelConfig, MaxDustHTLCExposure}; use ldk_node::payment::{PaymentDetails, PaymentDirection, PaymentKind, PaymentStatus}; use ldk_node::ChannelDetails; -use protos::types::payment_kind::Kind::{ +use ldk_server_protos::types::payment_kind::Kind::{ Bolt11, Bolt11Jit, Bolt12Offer, Bolt12Refund, Onchain, Spontaneous, }; -use protos::types::{Channel, LspFeeLimits, OutPoint, Payment}; +use ldk_server_protos::types::{Channel, LspFeeLimits, OutPoint, Payment}; pub(crate) fn channel_to_proto(channel: ChannelDetails) -> Channel { Channel { @@ -47,8 +47,8 @@ pub(crate) fn channel_to_proto(channel: ChannelDetails) -> Channel { pub(crate) fn channel_config_to_proto( channel_config: ChannelConfig, -) -> protos::types::ChannelConfig { - protos::types::ChannelConfig { +) -> ldk_server_protos::types::ChannelConfig { + ldk_server_protos::types::ChannelConfig { forwarding_fee_proportional_millionths: Some( channel_config.forwarding_fee_proportional_millionths, ), @@ -60,10 +60,14 @@ pub(crate) fn channel_config_to_proto( accept_underpaying_htlcs: Some(channel_config.accept_underpaying_htlcs), max_dust_htlc_exposure: match channel_config.max_dust_htlc_exposure { MaxDustHTLCExposure::FixedLimit { limit_msat } => { - Some(protos::types::channel_config::MaxDustHtlcExposure::FixedLimitMsat(limit_msat)) + Some(ldk_server_protos::types::channel_config::MaxDustHtlcExposure::FixedLimitMsat( + limit_msat, + )) }, MaxDustHTLCExposure::FeeRateMultiplier { multiplier } => Some( - protos::types::channel_config::MaxDustHtlcExposure::FeeRateMultiplier(multiplier), + ldk_server_protos::types::channel_config::MaxDustHtlcExposure::FeeRateMultiplier( + multiplier, + ), ), }, } @@ -75,33 +79,37 @@ pub(crate) fn payment_to_proto(payment: PaymentDetails) -> Payment { kind: Some(payment_kind_to_proto(payment.kind)), amount_msat: payment.amount_msat, direction: match payment.direction { - PaymentDirection::Inbound => protos::types::PaymentDirection::Inbound.into(), - PaymentDirection::Outbound => protos::types::PaymentDirection::Outbound.into(), + PaymentDirection::Inbound => ldk_server_protos::types::PaymentDirection::Inbound.into(), + PaymentDirection::Outbound => { + ldk_server_protos::types::PaymentDirection::Outbound.into() + }, }, status: match payment.status { - PaymentStatus::Pending => protos::types::PaymentStatus::Pending.into(), - PaymentStatus::Succeeded => protos::types::PaymentStatus::Succeeded.into(), - PaymentStatus::Failed => protos::types::PaymentStatus::Failed.into(), + PaymentStatus::Pending => ldk_server_protos::types::PaymentStatus::Pending.into(), + PaymentStatus::Succeeded => ldk_server_protos::types::PaymentStatus::Succeeded.into(), + PaymentStatus::Failed => ldk_server_protos::types::PaymentStatus::Failed.into(), }, latest_update_timestamp: payment.latest_update_timestamp, } } -pub(crate) fn payment_kind_to_proto(payment_kind: PaymentKind) -> protos::types::PaymentKind { +pub(crate) fn payment_kind_to_proto( + payment_kind: PaymentKind, +) -> ldk_server_protos::types::PaymentKind { match payment_kind { - PaymentKind::Onchain => { - protos::types::PaymentKind { kind: Some(Onchain(protos::types::Onchain {})) } + PaymentKind::Onchain => ldk_server_protos::types::PaymentKind { + kind: Some(Onchain(ldk_server_protos::types::Onchain {})), }, - PaymentKind::Bolt11 { hash, preimage, secret } => protos::types::PaymentKind { - kind: Some(Bolt11(protos::types::Bolt11 { + PaymentKind::Bolt11 { hash, preimage, secret } => ldk_server_protos::types::PaymentKind { + kind: Some(Bolt11(ldk_server_protos::types::Bolt11 { hash: hash.to_string(), preimage: preimage.map(|p| p.to_string()), secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), })), }, PaymentKind::Bolt11Jit { hash, preimage, secret, lsp_fee_limits } => { - protos::types::PaymentKind { - kind: Some(Bolt11Jit(protos::types::Bolt11Jit { + ldk_server_protos::types::PaymentKind { + kind: Some(Bolt11Jit(ldk_server_protos::types::Bolt11Jit { hash: hash.to_string(), preimage: preimage.map(|p| p.to_string()), secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), @@ -114,8 +122,8 @@ pub(crate) fn payment_kind_to_proto(payment_kind: PaymentKind) -> protos::types: } }, PaymentKind::Bolt12Offer { hash, preimage, secret, offer_id, payer_note, quantity } => { - protos::types::PaymentKind { - kind: Some(Bolt12Offer(protos::types::Bolt12Offer { + ldk_server_protos::types::PaymentKind { + kind: Some(Bolt12Offer(ldk_server_protos::types::Bolt12Offer { hash: hash.map(|h| h.to_string()), preimage: preimage.map(|p| p.to_string()), secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), @@ -126,8 +134,8 @@ pub(crate) fn payment_kind_to_proto(payment_kind: PaymentKind) -> protos::types: } }, PaymentKind::Bolt12Refund { hash, preimage, secret, payer_note, quantity } => { - protos::types::PaymentKind { - kind: Some(Bolt12Refund(protos::types::Bolt12Refund { + ldk_server_protos::types::PaymentKind { + kind: Some(Bolt12Refund(ldk_server_protos::types::Bolt12Refund { hash: hash.map(|h| h.to_string()), preimage: preimage.map(|p| p.to_string()), secret: secret.map(|s| Bytes::copy_from_slice(&s.0)), @@ -136,8 +144,8 @@ pub(crate) fn payment_kind_to_proto(payment_kind: PaymentKind) -> protos::types: })), } }, - PaymentKind::Spontaneous { hash, preimage } => protos::types::PaymentKind { - kind: Some(Spontaneous(protos::types::Spontaneous { + PaymentKind::Spontaneous { hash, preimage } => ldk_server_protos::types::PaymentKind { + kind: Some(Spontaneous(ldk_server_protos::types::Spontaneous { hash: hash.to_string(), preimage: preimage.map(|p| p.to_string()), })),