Skip to content

Commit a88e44d

Browse files
authored
Merge pull request #82 from benthecarman/shared-endpoints
Move endpoint path constants to shared defintion
2 parents 611433c + 35cd3f0 commit a88e44d

19 files changed

+51
-71
lines changed

ldk-server-client/src/client.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,18 @@ use ldk_server_protos::api::{
1313
OnchainReceiveRequest, OnchainReceiveResponse, OnchainSendRequest, OnchainSendResponse,
1414
OpenChannelRequest, OpenChannelResponse,
1515
};
16+
use ldk_server_protos::endpoints::{
17+
BOLT11_RECEIVE_PATH, BOLT11_SEND_PATH, BOLT12_RECEIVE_PATH, BOLT12_SEND_PATH,
18+
CLOSE_CHANNEL_PATH, FORCE_CLOSE_CHANNEL_PATH, GET_BALANCES_PATH, GET_NODE_INFO_PATH,
19+
LIST_CHANNELS_PATH, LIST_PAYMENTS_PATH, ONCHAIN_RECEIVE_PATH, ONCHAIN_SEND_PATH,
20+
OPEN_CHANNEL_PATH,
21+
};
1622
use ldk_server_protos::error::{ErrorCode, ErrorResponse};
1723
use reqwest::header::CONTENT_TYPE;
1824
use reqwest::Client;
1925

2026
const APPLICATION_OCTET_STREAM: &str = "application/octet-stream";
2127

22-
const GET_NODE_INFO_PATH: &str = "GetNodeInfo";
23-
const GET_BALANCES_PATH: &str = "GetBalances";
24-
const ONCHAIN_RECEIVE_PATH: &str = "OnchainReceive";
25-
const ONCHAIN_SEND_PATH: &str = "OnchainSend";
26-
const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";
27-
const BOLT11_SEND_PATH: &str = "Bolt11Send";
28-
const BOLT12_RECEIVE_PATH: &str = "Bolt12Receive";
29-
const BOLT12_SEND_PATH: &str = "Bolt12Send";
30-
const OPEN_CHANNEL_PATH: &str = "OpenChannel";
31-
const CLOSE_CHANNEL_PATH: &str = "CloseChannel";
32-
const FORCE_CLOSE_CHANNEL_PATH: &str = "ForceCloseChannel";
33-
const LIST_CHANNELS_PATH: &str = "ListChannels";
34-
const LIST_PAYMENTS_PATH: &str = "ListPayments";
35-
3628
/// Client to access a hosted instance of LDK Server.
3729
#[derive(Clone)]
3830
pub struct LdkServerClient {

ldk-server-protos/src/endpoints.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
pub const GET_NODE_INFO_PATH: &str = "GetNodeInfo";
2+
pub const GET_BALANCES_PATH: &str = "GetBalances";
3+
pub const ONCHAIN_RECEIVE_PATH: &str = "OnchainReceive";
4+
pub const ONCHAIN_SEND_PATH: &str = "OnchainSend";
5+
pub const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";
6+
pub const BOLT11_SEND_PATH: &str = "Bolt11Send";
7+
pub const BOLT12_RECEIVE_PATH: &str = "Bolt12Receive";
8+
pub const BOLT12_SEND_PATH: &str = "Bolt12Send";
9+
pub const OPEN_CHANNEL_PATH: &str = "OpenChannel";
10+
pub const CLOSE_CHANNEL_PATH: &str = "CloseChannel";
11+
pub const FORCE_CLOSE_CHANNEL_PATH: &str = "ForceCloseChannel";
12+
pub const LIST_CHANNELS_PATH: &str = "ListChannels";
13+
pub const LIST_PAYMENTS_PATH: &str = "ListPayments";
14+
pub const LIST_FORWARDED_PAYMENTS_PATH: &str = "ListForwardedPayments";
15+
pub const UPDATE_CHANNEL_CONFIG_PATH: &str = "UpdateChannelConfig";
16+
pub const GET_PAYMENT_DETAILS_PATH: &str = "GetPaymentDetails";

ldk-server-protos/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod api;
2+
pub mod endpoints;
23
pub mod error;
34
pub mod events;
45
pub mod types;

ldk-server/src/api/bolt11_receive.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use crate::service::Context;
33
use crate::util::proto_adapter::proto_to_bolt11_description;
44
use ldk_server_protos::api::{Bolt11ReceiveRequest, Bolt11ReceiveResponse};
55

6-
pub(crate) const BOLT11_RECEIVE_PATH: &str = "Bolt11Receive";
7-
86
pub(crate) fn handle_bolt11_receive_request(
97
context: Context, request: Bolt11ReceiveRequest,
108
) -> Result<Bolt11ReceiveResponse, LdkServerError> {

ldk-server/src/api/bolt11_send.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use ldk_node::lightning_invoice::Bolt11Invoice;
44
use ldk_server_protos::api::{Bolt11SendRequest, Bolt11SendResponse};
55
use std::str::FromStr;
66

7-
pub(crate) const BOLT11_SEND_PATH: &str = "Bolt11Send";
8-
97
pub(crate) fn handle_bolt11_send_request(
108
context: Context, request: Bolt11SendRequest,
119
) -> Result<Bolt11SendResponse, LdkServerError> {

ldk-server/src/api/bolt12_receive.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ use crate::api::error::LdkServerError;
22
use crate::service::Context;
33
use ldk_server_protos::api::{Bolt12ReceiveRequest, Bolt12ReceiveResponse};
44

5-
pub(crate) const BOLT12_RECEIVE_PATH: &str = "Bolt12Receive";
6-
75
pub(crate) fn handle_bolt12_receive_request(
86
context: Context, request: Bolt12ReceiveRequest,
97
) -> Result<Bolt12ReceiveResponse, LdkServerError> {

ldk-server/src/api/bolt12_send.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use ldk_node::lightning::offers::offer::Offer;
44
use ldk_server_protos::api::{Bolt12SendRequest, Bolt12SendResponse};
55
use std::str::FromStr;
66

7-
pub(crate) const BOLT12_SEND_PATH: &str = "Bolt12Send";
8-
97
pub(crate) fn handle_bolt12_send_request(
108
context: Context, request: Bolt12SendRequest,
119
) -> Result<Bolt12SendResponse, LdkServerError> {

ldk-server/src/api/close_channel.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use ldk_server_protos::api::{
88
};
99
use std::str::FromStr;
1010

11-
pub(crate) const CLOSE_CHANNEL_PATH: &str = "CloseChannel";
12-
1311
pub(crate) fn handle_close_channel_request(
1412
context: Context, request: CloseChannelRequest,
1513
) -> Result<CloseChannelResponse, LdkServerError> {
@@ -21,8 +19,6 @@ pub(crate) fn handle_close_channel_request(
2119
Ok(CloseChannelResponse {})
2220
}
2321

24-
pub(crate) const FORCE_CLOSE_CHANNEL_PATH: &str = "ForceCloseChannel";
25-
2622
pub(crate) fn handle_force_close_channel_request(
2723
context: Context, request: ForceCloseChannelRequest,
2824
) -> Result<ForceCloseChannelResponse, LdkServerError> {

ldk-server/src/api/get_balances.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use crate::service::Context;
33
use crate::util::proto_adapter::{lightning_balance_to_proto, pending_sweep_balance_to_proto};
44
use ldk_server_protos::api::{GetBalancesRequest, GetBalancesResponse};
55

6-
pub(crate) const GET_BALANCES: &str = "GetBalances";
7-
86
pub(crate) fn handle_get_balances_request(
97
context: Context, _request: GetBalancesRequest,
108
) -> Result<GetBalancesResponse, LdkServerError> {

ldk-server/src/api/get_node_info.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use crate::service::Context;
33
use ldk_server_protos::api::{GetNodeInfoRequest, GetNodeInfoResponse};
44
use ldk_server_protos::types::BestBlock;
55

6-
pub(crate) const GET_NODE_INFO: &str = "GetNodeInfo";
7-
86
pub(crate) fn handle_get_node_info_request(
97
context: Context, _request: GetNodeInfoRequest,
108
) -> Result<GetNodeInfoResponse, LdkServerError> {

0 commit comments

Comments
 (0)