Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit aac3418

Browse files
committed
Added docs for pub fn in lsps1
1 parent f55dafe commit aac3418

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

src/lsps1/client.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ where
221221
C::Target: Filter,
222222
ES::Target: EntropySource,
223223
{
224+
/// Constructs an `LSPS1ClientHandler`.
224225
pub(crate) fn new(
225226
entropy_source: ES, pending_messages: Arc<MessageQueue>, pending_events: Arc<EventQueue>,
226227
channel_manager: CM, chain_source: Option<C>, config: LSPS1ClientConfig,
@@ -236,7 +237,14 @@ where
236237
}
237238
}
238239

239-
fn request_for_info(&self, counterparty_node_id: PublicKey, channel_id: u128) {
240+
/// Initiate the creation of an invoice that when paid will open a channel
241+
/// with enough inbound liquidity to be able to receive the payment.
242+
///
243+
/// `counterparty_node_id` is the node_id of the LSP you would like to use.
244+
///
245+
/// `token` is an optional String that will be provided to the LSP.
246+
/// It can be used by the LSP as an API key, coupon code, or some other way to identify a user.
247+
pub fn request_for_info(&self, counterparty_node_id: PublicKey, channel_id: u128) {
240248
let channel = InboundCRChannel::new(channel_id);
241249

242250
let mut outer_state_lock = self.per_peer_state.write().unwrap();
@@ -313,7 +321,14 @@ where
313321
Ok(())
314322
}
315323

316-
fn place_order(
324+
/// Used by client to place an order to LSP with the provided parameters.
325+
/// The client agrees to paying an channel fees as per requested by
326+
/// the LSP.
327+
///
328+
/// Should be called in response to receiving a [`LSPS1ClientEvent::GetInfoResponse`] event.
329+
///
330+
/// [`LSPS1ClientEvent::GetInfoResponse`]: crate::lsps1::event::LSPS1ClientEvent::GetInfoResponse
331+
pub fn place_order(
317332
&self, channel_id: u128, counterparty_node_id: &PublicKey, order: OrderParams,
318333
) -> Result<(), APIError> {
319334
let outer_state_lock = self.per_peer_state.write().unwrap();
@@ -466,6 +481,11 @@ where
466481
}
467482
}
468483

484+
/// Used by client to check whether payment is received by LSP and status of order.
485+
///
486+
/// Should be called in response to receiving a [`LSPS1ClientEvent::DisplayOrder`] event.
487+
///
488+
/// [`LSPS1ClientEvent::DisplayOrder`]: crate::lsps1::event::LSPS1ClientEvent::DisplayOrder
469489
fn check_order_status(
470490
&self, counterparty_node_id: &PublicKey, order_id: OrderId, channel_id: u128,
471491
) -> Result<(), APIError> {

src/lsps1/service.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ where
152152
C::Target: Filter,
153153
ES::Target: EntropySource,
154154
{
155+
/// Constructs a `LSPS1ServiceHandler`.
155156
pub(crate) fn new(
156157
entropy_source: ES, pending_messages: Arc<MessageQueue>, pending_events: Arc<EventQueue>,
157158
channel_manager: CM, chain_source: Option<C>, config: LSPS1ServiceConfig,
@@ -232,7 +233,12 @@ where
232233
Ok(())
233234
}
234235

235-
fn send_invoice_for_order(
236+
/// Used by LSP to send invoice containing details regarding the channel fees and payment information.
237+
///
238+
/// Should be called in response to receiving a [`LSPS1ServiceEvent::CreateInvoice`] event.
239+
///
240+
/// [`LSPS1ServiceEvent::CreateInvoice`]: crate::lsps1::event::LSPS1ServiceEvent::CreateInvoice
241+
pub fn send_invoice_for_order(
236242
&self, request_id: RequestId, counterparty_node_id: &PublicKey, payment: OrderPayment,
237243
created_at: chrono::DateTime<Utc>, expires_at: chrono::DateTime<Utc>,
238244
) -> Result<(), APIError> {
@@ -342,7 +348,15 @@ where
342348
Ok(())
343349
}
344350

345-
fn update_order_status(
351+
/// Used by LSP to give details to client regarding the status of channel opening.
352+
/// Called to respond to client's GetOrder request.
353+
/// The LSP continously polls for checking payment confirmation on-chain or lighting
354+
/// and then responds to client request.
355+
///
356+
/// Should be called in response to receiving a [`LSPS1ServiceEvent::CheckPaymentConfirmation`] event.
357+
///
358+
/// [`LSPS1ServiceEvent::CheckPaymentConfirmation`]: crate::lsps1::event::LSPS1ServiceEvent::CheckPaymentConfirmation
359+
pub fn update_order_status(
346360
&self, request_id: RequestId, counterparty_node_id: PublicKey, order_id: OrderId,
347361
order_state: OrderState, channel: Option<ChannelInfo>,
348362
) -> Result<(), APIError> {

0 commit comments

Comments
 (0)