Skip to content

Commit 7ea45b7

Browse files
committed
Add GetPaymentDetails to client and CLI
1 parent ebef52e commit 7ea45b7

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

ldk-server-cli/src/main.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ use ldk_server_client::ldk_server_protos::api::{
1818
Bolt12ReceiveRequest, Bolt12ReceiveResponse, Bolt12SendRequest, Bolt12SendResponse,
1919
CloseChannelRequest, CloseChannelResponse, ForceCloseChannelRequest, ForceCloseChannelResponse,
2020
GetBalancesRequest, GetBalancesResponse, GetNodeInfoRequest, GetNodeInfoResponse,
21-
ListChannelsRequest, ListChannelsResponse, ListPaymentsRequest, ListPaymentsResponse,
22-
OnchainReceiveRequest, OnchainReceiveResponse, OnchainSendRequest, OnchainSendResponse,
23-
OpenChannelRequest, OpenChannelResponse, SpliceInRequest, SpliceInResponse, SpliceOutRequest,
24-
SpliceOutResponse, UpdateChannelConfigRequest, UpdateChannelConfigResponse,
21+
GetPaymentDetailsRequest, GetPaymentDetailsResponse, ListChannelsRequest, ListChannelsResponse,
22+
ListPaymentsRequest, ListPaymentsResponse, OnchainReceiveRequest, OnchainReceiveResponse,
23+
OnchainSendRequest, OnchainSendResponse, OpenChannelRequest, OpenChannelResponse,
24+
SpliceInRequest, SpliceInResponse, SpliceOutRequest, SpliceOutResponse,
25+
UpdateChannelConfigRequest, UpdateChannelConfigResponse,
2526
};
2627
use ldk_server_client::ldk_server_protos::types::{
2728
bolt11_invoice_description, Bolt11InvoiceDescription, ChannelConfig, PageToken,
@@ -199,6 +200,10 @@ enum Commands {
199200
#[arg(help = "Page token to continue from a previous page (format: token:index)")]
200201
page_token: Option<String>,
201202
},
203+
GetPaymentDetails {
204+
#[arg(short, long, help = "The payment ID in hex-encoded form")]
205+
payment_id: String,
206+
},
202207
UpdateChannelConfig {
203208
#[arg(short, long)]
204209
user_channel_id: String,
@@ -478,6 +483,11 @@ async fn main() {
478483
.await,
479484
);
480485
},
486+
Commands::GetPaymentDetails { payment_id } => {
487+
handle_response_result::<_, GetPaymentDetailsResponse>(
488+
client.get_payment_details(GetPaymentDetailsRequest { payment_id }).await,
489+
);
490+
},
481491
}
482492
}
483493

ldk-server-client/src/client.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ use ldk_server_protos::api::{
2020
Bolt12ReceiveRequest, Bolt12ReceiveResponse, Bolt12SendRequest, Bolt12SendResponse,
2121
CloseChannelRequest, CloseChannelResponse, ForceCloseChannelRequest, ForceCloseChannelResponse,
2222
GetBalancesRequest, GetBalancesResponse, GetNodeInfoRequest, GetNodeInfoResponse,
23-
ListChannelsRequest, ListChannelsResponse, ListPaymentsRequest, ListPaymentsResponse,
24-
OnchainReceiveRequest, OnchainReceiveResponse, OnchainSendRequest, OnchainSendResponse,
25-
OpenChannelRequest, OpenChannelResponse, SpliceInRequest, SpliceInResponse, SpliceOutRequest,
26-
SpliceOutResponse, UpdateChannelConfigRequest, UpdateChannelConfigResponse,
23+
GetPaymentDetailsRequest, GetPaymentDetailsResponse, ListChannelsRequest, ListChannelsResponse,
24+
ListPaymentsRequest, ListPaymentsResponse, OnchainReceiveRequest, OnchainReceiveResponse,
25+
OnchainSendRequest, OnchainSendResponse, OpenChannelRequest, OpenChannelResponse,
26+
SpliceInRequest, SpliceInResponse, SpliceOutRequest, SpliceOutResponse,
27+
UpdateChannelConfigRequest, UpdateChannelConfigResponse,
2728
};
2829
use ldk_server_protos::endpoints::{
2930
BOLT11_RECEIVE_PATH, BOLT11_SEND_PATH, BOLT12_RECEIVE_PATH, BOLT12_SEND_PATH,
3031
CLOSE_CHANNEL_PATH, FORCE_CLOSE_CHANNEL_PATH, GET_BALANCES_PATH, GET_NODE_INFO_PATH,
31-
LIST_CHANNELS_PATH, LIST_PAYMENTS_PATH, ONCHAIN_RECEIVE_PATH, ONCHAIN_SEND_PATH,
32-
OPEN_CHANNEL_PATH, SPLICE_IN_PATH, SPLICE_OUT_PATH, UPDATE_CHANNEL_CONFIG_PATH,
32+
GET_PAYMENT_DETAILS_PATH, LIST_CHANNELS_PATH, LIST_PAYMENTS_PATH, ONCHAIN_RECEIVE_PATH,
33+
ONCHAIN_SEND_PATH, OPEN_CHANNEL_PATH, SPLICE_IN_PATH, SPLICE_OUT_PATH,
34+
UPDATE_CHANNEL_CONFIG_PATH,
3335
};
3436
use ldk_server_protos::error::{ErrorCode, ErrorResponse};
3537
use reqwest::header::CONTENT_TYPE;
@@ -230,6 +232,15 @@ impl LdkServerClient {
230232
self.post_request(&request, &url).await
231233
}
232234

235+
/// Retrieves payment details for a given payment id.
236+
/// For API contract/usage, refer to docs for [`GetPaymentDetailsRequest`] and [`GetPaymentDetailsResponse`].
237+
pub async fn get_payment_details(
238+
&self, request: GetPaymentDetailsRequest,
239+
) -> Result<GetPaymentDetailsResponse, LdkServerError> {
240+
let url = format!("https://{}/{GET_PAYMENT_DETAILS_PATH}", self.base_url);
241+
self.post_request(&request, &url).await
242+
}
243+
233244
async fn post_request<Rq: Message, Rs: Message + Default>(
234245
&self, request: &Rq, url: &str,
235246
) -> Result<Rs, LdkServerError> {

0 commit comments

Comments
 (0)