Skip to content

Commit a5178ec

Browse files
authored
Merge pull request #24 from G8XSU/ldk-server-rename
Rename to LdkServer.
2 parents f2c5baf + 144d732 commit a5178ec

6 files changed

Lines changed: 32 additions & 32 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clap::{Parser, Subcommand};
2-
use client::client::LdkNodeServerClient;
3-
use client::error::LdkNodeServerError;
2+
use client::client::LdkServerClient;
3+
use client::error::LdkServerError;
44
use client::protos::api::{
55
Bolt11ReceiveRequest, Bolt11SendRequest, Bolt12ReceiveRequest, Bolt12SendRequest,
66
OnchainReceiveRequest, OnchainSendRequest, OpenChannelRequest,
@@ -78,7 +78,7 @@ enum Commands {
7878
#[tokio::main]
7979
async fn main() {
8080
let cli = Cli::parse();
81-
let client = LdkNodeServerClient::new(cli.base_url);
81+
let client = LdkServerClient::new(cli.base_url);
8282

8383
match cli.command {
8484
Commands::OnchainReceive => {
@@ -141,7 +141,7 @@ async fn main() {
141141
}
142142
}
143143

144-
fn handle_response<Rs: ::prost::Message>(response: Result<Rs, LdkNodeServerError>) {
144+
fn handle_response<Rs: ::prost::Message>(response: Result<Rs, LdkServerError>) {
145145
match response {
146146
Ok(response) => {
147147
println!("{:?}", response);

client/src/client.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use prost::Message;
22

3-
use crate::error::LdkNodeServerError;
3+
use crate::error::LdkServerError;
44
use protos::api::{
55
Bolt11ReceiveRequest, Bolt11ReceiveResponse, Bolt11SendRequest, Bolt11SendResponse,
66
Bolt12ReceiveRequest, Bolt12ReceiveResponse, Bolt12SendRequest, Bolt12SendResponse,
@@ -23,15 +23,15 @@ const OPEN_CHANNEL_PATH: &str = "OpenChannel";
2323
const CLOSE_CHANNEL_PATH: &str = "CloseChannel";
2424
const LIST_CHANNELS_PATH: &str = "ListChannels";
2525

26-
/// Client to access a hosted instance of LDK Node Server.
26+
/// Client to access a hosted instance of LDK Server.
2727
#[derive(Clone)]
28-
pub struct LdkNodeServerClient {
28+
pub struct LdkServerClient {
2929
base_url: String,
3030
client: Client,
3131
}
3232

33-
impl LdkNodeServerClient {
34-
/// Constructs a [`LdkNodeServerClient`] using `base_url` as the server endpoint.
33+
impl LdkServerClient {
34+
/// Constructs a [`LdkServerClient`] using `base_url` as the server endpoint.
3535
pub fn new(base_url: String) -> Self {
3636
Self { base_url, client: Client::new() }
3737
}
@@ -40,7 +40,7 @@ impl LdkNodeServerClient {
4040
/// For API contract/usage, refer to docs for [`OnchainReceiveRequest`] and [`OnchainReceiveResponse`].
4141
pub async fn onchain_receive(
4242
&self, request: OnchainReceiveRequest,
43-
) -> Result<OnchainReceiveResponse, LdkNodeServerError> {
43+
) -> Result<OnchainReceiveResponse, LdkServerError> {
4444
let url = format!("http://{}/{ONCHAIN_RECEIVE_PATH}", self.base_url);
4545
self.post_request(&request, &url).await
4646
}
@@ -49,7 +49,7 @@ impl LdkNodeServerClient {
4949
/// For API contract/usage, refer to docs for [`OnchainSendRequest`] and [`OnchainSendResponse`].
5050
pub async fn onchain_send(
5151
&self, request: OnchainSendRequest,
52-
) -> Result<OnchainSendResponse, LdkNodeServerError> {
52+
) -> Result<OnchainSendResponse, LdkServerError> {
5353
let url = format!("http://{}/{ONCHAIN_SEND_PATH}", self.base_url);
5454
self.post_request(&request, &url).await
5555
}
@@ -58,7 +58,7 @@ impl LdkNodeServerClient {
5858
/// For API contract/usage, refer to docs for [`Bolt11ReceiveRequest`] and [`Bolt11ReceiveResponse`].
5959
pub async fn bolt11_receive(
6060
&self, request: Bolt11ReceiveRequest,
61-
) -> Result<Bolt11ReceiveResponse, LdkNodeServerError> {
61+
) -> Result<Bolt11ReceiveResponse, LdkServerError> {
6262
let url = format!("http://{}/{BOLT11_RECEIVE_PATH}", self.base_url);
6363
self.post_request(&request, &url).await
6464
}
@@ -67,7 +67,7 @@ impl LdkNodeServerClient {
6767
/// For API contract/usage, refer to docs for [`Bolt11SendRequest`] and [`Bolt11SendResponse`].
6868
pub async fn bolt11_send(
6969
&self, request: Bolt11SendRequest,
70-
) -> Result<Bolt11SendResponse, LdkNodeServerError> {
70+
) -> Result<Bolt11SendResponse, LdkServerError> {
7171
let url = format!("http://{}/{BOLT11_SEND_PATH}", self.base_url);
7272
self.post_request(&request, &url).await
7373
}
@@ -76,7 +76,7 @@ impl LdkNodeServerClient {
7676
/// For API contract/usage, refer to docs for [`Bolt12ReceiveRequest`] and [`Bolt12ReceiveResponse`].
7777
pub async fn bolt12_receive(
7878
&self, request: Bolt12ReceiveRequest,
79-
) -> Result<Bolt12ReceiveResponse, LdkNodeServerError> {
79+
) -> Result<Bolt12ReceiveResponse, LdkServerError> {
8080
let url = format!("http://{}/{BOLT12_RECEIVE_PATH}", self.base_url);
8181
self.post_request(&request, &url).await
8282
}
@@ -85,7 +85,7 @@ impl LdkNodeServerClient {
8585
/// For API contract/usage, refer to docs for [`Bolt12SendRequest`] and [`Bolt12SendResponse`].
8686
pub async fn bolt12_send(
8787
&self, request: Bolt12SendRequest,
88-
) -> Result<Bolt12SendResponse, LdkNodeServerError> {
88+
) -> Result<Bolt12SendResponse, LdkServerError> {
8989
let url = format!("http://{}/{BOLT12_SEND_PATH}", self.base_url);
9090
self.post_request(&request, &url).await
9191
}
@@ -94,7 +94,7 @@ impl LdkNodeServerClient {
9494
/// For API contract/usage, refer to docs for [`OpenChannelRequest`] and [`OpenChannelResponse`].
9595
pub async fn open_channel(
9696
&self, request: OpenChannelRequest,
97-
) -> Result<OpenChannelResponse, LdkNodeServerError> {
97+
) -> Result<OpenChannelResponse, LdkServerError> {
9898
let url = format!("http://{}/{OPEN_CHANNEL_PATH}", self.base_url);
9999
self.post_request(&request, &url).await
100100
}
@@ -103,7 +103,7 @@ impl LdkNodeServerClient {
103103
/// For API contract/usage, refer to docs for [`CloseChannelRequest`] and [`CloseChannelResponse`].
104104
pub async fn close_channel(
105105
&self, request: CloseChannelRequest,
106-
) -> Result<CloseChannelResponse, LdkNodeServerError> {
106+
) -> Result<CloseChannelResponse, LdkServerError> {
107107
let url = format!("http://{}/{CLOSE_CHANNEL_PATH}", self.base_url);
108108
self.post_request(&request, &url).await
109109
}
@@ -112,14 +112,14 @@ impl LdkNodeServerClient {
112112
/// For API contract/usage, refer to docs for [`ListChannelsRequest`] and [`ListChannelsResponse`].
113113
pub async fn list_channels(
114114
&self, request: ListChannelsRequest,
115-
) -> Result<ListChannelsResponse, LdkNodeServerError> {
115+
) -> Result<ListChannelsResponse, LdkServerError> {
116116
let url = format!("http://{}/{LIST_CHANNELS_PATH}", self.base_url);
117117
self.post_request(&request, &url).await
118118
}
119119

120120
async fn post_request<Rq: Message, Rs: Message + Default>(
121121
&self, request: &Rq, url: &str,
122-
) -> Result<Rs, LdkNodeServerError> {
122+
) -> Result<Rs, LdkServerError> {
123123
let request_body = request.encode_to_vec();
124124
let response_raw = match self
125125
.client
@@ -131,7 +131,7 @@ impl LdkNodeServerClient {
131131
{
132132
Ok(response) => response,
133133
Err(e) => {
134-
return Err(LdkNodeServerError::InternalError(e.to_string()));
134+
return Err(LdkServerError::InternalError(e.to_string()));
135135
},
136136
};
137137
let status = response_raw.status();
@@ -141,7 +141,7 @@ impl LdkNodeServerClient {
141141
Ok(Rs::decode(&payload[..])?)
142142
} else {
143143
//TODO: Error handling and error response parsing.
144-
Err(LdkNodeServerError::InternalError("Unknown Error".to_string()))
144+
Err(LdkServerError::InternalError("Unknown Error".to_string()))
145145
}
146146
}
147147
}

client/src/error.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use prost::DecodeError;
22

3-
/// When there is an error in request to LDK Node Server, the response contains a relevant error code.
3+
/// When there is an error in request to LDK Server, the response contains a relevant error code.
44
#[derive(Debug)]
5-
pub enum LdkNodeServerError {
5+
pub enum LdkServerError {
66
/// There is an unknown error. (Placeholder until error handling is done.)
77
InternalError(String),
88
}
99

10-
impl From<DecodeError> for LdkNodeServerError {
10+
impl From<DecodeError> for LdkServerError {
1111
fn from(err: DecodeError) -> Self {
12-
LdkNodeServerError::InternalError(err.to_string())
12+
LdkServerError::InternalError(err.to_string())
1313
}
1414
}
1515

16-
impl From<reqwest::Error> for LdkNodeServerError {
16+
impl From<reqwest::Error> for LdkServerError {
1717
fn from(err: reqwest::Error) -> Self {
18-
LdkNodeServerError::InternalError(err.to_string())
18+
LdkServerError::InternalError(err.to_string())
1919
}
2020
}

client/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
//! Client-side library to interact with LDK Node Server.
1+
//! Client-side library to interact with LDK Server.
22
33
#![deny(rustdoc::broken_intra_doc_links)]
44
#![deny(rustdoc::private_intra_doc_links)]
55
#![deny(missing_docs)]
66

7-
/// Implements a client ([`client::LdkNodeServerClient`]) to access a hosted instance of LDK Node Server.
7+
/// Implements a client ([`client::LdkServerClient`]) to access a hosted instance of LDK Server.
88
pub mod client;
99

10-
/// Implements the error type ([`error::LdkNodeServerError`]) returned on interacting with [`client::LdkNodeServerClient`]
10+
/// Implements the error type ([`error::LdkServerError`]) returned on interacting with [`client::LdkServerClient`]
1111
pub mod error;
1212

1313
/// Request/Response structs required for interacting with the client.

server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "ldk-node-server"
2+
name = "ldk-server"
33
version = "0.1.0"
44
edition = "2021"
55

0 commit comments

Comments
 (0)