Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions docs/api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ RPCs with no permission mapping return `UNIMPLEMENTED`, even for admin tokens.
| `payments:read` | Read payments, forwarded payments, and forwarding statistics |
| `payments:claim` | Claim or fail held BOLT11 payments |
| `payments:send` | Send BOLT11, BOLT12, spontaneous and unified payments and probes; splice out |
| `channels:read` | List channels |
| `channels:manage` | Open, configure, cooperatively close, splice funds into channels, or bump pending splice fees. Opening a channel can push funds to the counterparty, so this permission can move funds out of the node |
| `channels:read` | List channels and check LSPS1 order status |
| `channels:manage` | Open, configure, cooperatively close, splice funds into channels, bump pending splice fees, or request an LSPS1 channel. Opening a channel can push funds to the counterparty, so this permission can move funds out of the node |
| `channels:force_close` | Force-close channels |
| `peers:read` | List peers |
| `peers:manage` | Connect or disconnect peers |
Expand Down Expand Up @@ -213,6 +213,22 @@ These RPCs support a manual claim/fail workflow for held payments. See
| `Bolt11ClaimForId` | Claim a held payment by its payment ID and preimage |
| `Bolt11FailForId` | Reject a held payment by its payment ID |

### LSPS1 Channel Orders

Requires an LSPS1-capable LSP configured in `[[liquidity.lsps_client]]`. Request an inbound
channel with `Lsps1RequestChannel`, then pay one of the returned BOLT11, BOLT12, or on-chain
payment options. Use `Lsps1CheckOrderStatus` with the returned `order_id` to check the order again;
`channel_state` is populated once the LSP publishes the funding transaction. `Lsps1RequestChannel`
can take an optional `lsp_node_id` to select a configured provider; status checks require the
`lsp_node_id` of the provider that received the order.

| RPC | Description |
| --- | --- |
| `Lsps1RequestChannel` | Place an order for an inbound channel from the configured LSP |
| `Lsps1CheckOrderStatus` | Check the status of a previously placed LSPS1 order |

`Lsps1RequestChannel` requires `channels:manage`; `Lsps1CheckOrderStatus` requires `channels:read`.

### BOLT11 JIT Channels (LSPS2)

Requires at least one `[[liquidity.lsps_client]]` entry for an LSPS2-capable LSP. The LSP opens
Expand Down Expand Up @@ -248,6 +264,8 @@ a channel just-in-time when the invoice is paid.
| RPC | Description |
| ----------------------- | ---------------------------------------------------------------------- |
| `OpenChannel` | Open a new outbound channel (with optional push amount and fee config) |
| `Lsps1RequestChannel` | Request an inbound channel from the configured LSPS1 LSP |
| `Lsps1CheckOrderStatus` | Check the status of an LSPS1 channel order |
| `CloseChannel` | Cooperatively close a channel |
| `ForceCloseChannel` | Force-close a channel unilaterally |
| `SpliceIn` | Add on-chain funds to an existing channel |
Expand Down
69 changes: 61 additions & 8 deletions ldk-server-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ use ldk_server_client::ldk_server_grpc::api::{
GraphListNodesRequest, GraphListNodesResponse, ListChannelForwardingStatsRequest,
ListChannelPairForwardingStatsRequest, ListChannelsRequest, ListChannelsResponse,
ListForwardedPaymentsRequest, ListMacaroonsRequest, ListMacaroonsResponse, ListPaymentsRequest,
ListPeersRequest, ListPeersResponse, OnchainBumpFeeRequest, OnchainBumpFeeResponse,
OnchainReceiveRequest, OnchainReceiveResponse, OnchainSendRequest, OnchainSendResponse,
OpenChannelRequest, OpenChannelResponse, RevokeMacaroonRequest, RevokeMacaroonResponse,
SignMessageRequest, SignMessageResponse, SpliceInRequest, SpliceInResponse, SpliceOutRequest,
SpliceOutResponse, SpontaneousSendProbesRequest, SpontaneousSendProbesResponse,
SpontaneousSendRequest, SpontaneousSendResponse, UnifiedSendRequest, UnifiedSendResponse,
UpdateChannelConfigRequest, UpdateChannelConfigResponse, VerifySignatureRequest,
VerifySignatureResponse,
ListPeersRequest, ListPeersResponse, Lsps1CheckOrderStatusRequest,
Lsps1CheckOrderStatusResponse, Lsps1RequestChannelRequest, Lsps1RequestChannelResponse,
OnchainBumpFeeRequest, OnchainBumpFeeResponse, OnchainReceiveRequest, OnchainReceiveResponse,
OnchainSendRequest, OnchainSendResponse, OpenChannelRequest, OpenChannelResponse,
RevokeMacaroonRequest, RevokeMacaroonResponse, SignMessageRequest, SignMessageResponse,
SpliceInRequest, SpliceInResponse, SpliceOutRequest, SpliceOutResponse,
SpontaneousSendProbesRequest, SpontaneousSendProbesResponse, SpontaneousSendRequest,
SpontaneousSendResponse, UnifiedSendRequest, UnifiedSendResponse, UpdateChannelConfigRequest,
UpdateChannelConfigResponse, VerifySignatureRequest, VerifySignatureResponse,
};
use ldk_server_client::ldk_server_grpc::permissions::MacaroonPreset;
use ldk_server_client::ldk_server_grpc::types::{
Expand Down Expand Up @@ -647,6 +648,26 @@ enum Commands {
)]
wait_timeout: Option<u64>,
},
#[command(about = "Request an inbound channel from the configured LSPS1 LSP")]
Lsps1RequestChannel {
#[arg(long, help = "The balance in satoshis the LSP will contribute, e.g. 500000sat")]
lsp_balance: Amount,
#[arg(long, help = "The balance in satoshis the client will contribute, e.g. 100000sat")]
client_balance: Amount,
#[arg(long, help = "How long the channel should be leased, in blocks")]
channel_expiry_blocks: u32,
#[arg(long, help = "Whether the channel should be announced to the network")]
announce_channel: bool,
#[arg(long, help = "Hex-encoded node ID of the configured LSP to use")]
lsp_node_id: Option<String>,
},
#[command(about = "Check the status of a previously placed LSPS1 channel order")]
Lsps1CheckOrderStatus {
#[arg(help = "The order ID returned by lsps1-request-channel")]
order_id: String,
#[arg(long, help = "Hex-encoded node ID of the LSP that received the order")]
lsp_node_id: String,
},
#[command(
about = "Increase the channel balance by the given amount, funds will come from the node's on-chain wallet"
)]
Expand Down Expand Up @@ -1470,6 +1491,38 @@ async fn main() {
);
}
},
Commands::Lsps1RequestChannel {
lsp_balance,
client_balance,
channel_expiry_blocks,
announce_channel,
lsp_node_id,
} => {
let lsp_balance_sat = lsp_balance.to_sat().unwrap_or_else(|e| handle_error_msg(e));
let client_balance_sat =
client_balance.to_sat().unwrap_or_else(|e| handle_error_msg(e));
handle_response_result::<_, Lsps1RequestChannelResponse>(
client
.lsps1_request_channel(Lsps1RequestChannelRequest {
lsp_balance_sat,
client_balance_sat,
channel_expiry_blocks,
announce_channel,
lsp_node_id,
})
.await,
);
},
Commands::Lsps1CheckOrderStatus { order_id, lsp_node_id } => {
handle_response_result::<_, Lsps1CheckOrderStatusResponse>(
client
.lsps1_check_order_status(Lsps1CheckOrderStatusRequest {
order_id,
lsp_node_id,
})
.await,
);
},
Commands::SpliceIn { user_channel_id, counterparty_node_id, splice_amount } => {
let amount = match splice_amount.to_sat().unwrap_or_else(|e| handle_error_msg(e)) {
Some(amount_sats) => splice_in_request::Amount::SpliceAmountSats(amount_sats),
Expand Down
38 changes: 27 additions & 11 deletions ldk-server-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ use ldk_server_grpc::api::{
ListChannelPairForwardingStatsResponse, ListChannelsRequest, ListChannelsResponse,
ListForwardedPaymentsRequest, ListForwardedPaymentsResponse, ListMacaroonsRequest,
ListMacaroonsResponse, ListPaymentsRequest, ListPaymentsResponse, ListPeersRequest,
ListPeersResponse, OnchainBumpFeeRequest, OnchainBumpFeeResponse, OnchainReceiveRequest,
OnchainReceiveResponse, OnchainSendRequest, OnchainSendResponse, OpenChannelRequest,
OpenChannelResponse, RevokeMacaroonRequest, RevokeMacaroonResponse, SignMessageRequest,
SignMessageResponse, SpliceInRequest, SpliceInResponse, SpliceOutRequest, SpliceOutResponse,
SpontaneousSendProbesRequest, SpontaneousSendProbesResponse, SpontaneousSendRequest,
SpontaneousSendResponse, SubscribeEventsRequest, UnifiedSendRequest, UnifiedSendResponse,
UpdateChannelConfigRequest, UpdateChannelConfigResponse, VerifySignatureRequest,
VerifySignatureResponse,
ListPeersResponse, Lsps1CheckOrderStatusRequest, Lsps1CheckOrderStatusResponse,
Lsps1RequestChannelRequest, Lsps1RequestChannelResponse, OnchainBumpFeeRequest,
OnchainBumpFeeResponse, OnchainReceiveRequest, OnchainReceiveResponse, OnchainSendRequest,
OnchainSendResponse, OpenChannelRequest, OpenChannelResponse, RevokeMacaroonRequest,
RevokeMacaroonResponse, SignMessageRequest, SignMessageResponse, SpliceInRequest,
SpliceInResponse, SpliceOutRequest, SpliceOutResponse, SpontaneousSendProbesRequest,
SpontaneousSendProbesResponse, SpontaneousSendRequest, SpontaneousSendResponse,
SubscribeEventsRequest, UnifiedSendRequest, UnifiedSendResponse, UpdateChannelConfigRequest,
UpdateChannelConfigResponse, VerifySignatureRequest, VerifySignatureResponse,
};
use ldk_server_grpc::endpoints::{
BOLT11_CLAIM_FOR_ID_PATH, BOLT11_FAIL_FOR_ID_PATH, BOLT11_RECEIVE_FOR_HASH_PATH,
Expand All @@ -67,9 +68,10 @@ use ldk_server_grpc::endpoints::{
GRAPH_LIST_CHANNELS_PATH, GRAPH_LIST_NODES_PATH, GRPC_SERVICE_PREFIX, LIST_CHANNELS_PATH,
LIST_CHANNEL_FORWARDING_STATS_PATH, LIST_CHANNEL_PAIR_FORWARDING_STATS_PATH,
LIST_FORWARDED_PAYMENTS_PATH, LIST_MACAROONS_PATH, LIST_PAYMENTS_PATH, LIST_PEERS_PATH,
ONCHAIN_BUMP_FEE_PATH, ONCHAIN_RECEIVE_PATH, ONCHAIN_SEND_PATH, OPEN_CHANNEL_PATH,
REVOKE_MACAROON_PATH, SIGN_MESSAGE_PATH, SPLICE_IN_PATH, SPLICE_OUT_PATH,
SPONTANEOUS_SEND_PATH, SPONTANEOUS_SEND_PROBES_PATH, SUBSCRIBE_EVENTS_PATH, UNIFIED_SEND_PATH,
LSPS1_CHECK_ORDER_STATUS_PATH, LSPS1_REQUEST_CHANNEL_PATH, ONCHAIN_BUMP_FEE_PATH,
ONCHAIN_RECEIVE_PATH, ONCHAIN_SEND_PATH, OPEN_CHANNEL_PATH, REVOKE_MACAROON_PATH,
SIGN_MESSAGE_PATH, SPLICE_IN_PATH, SPLICE_OUT_PATH, SPONTANEOUS_SEND_PATH,
SPONTANEOUS_SEND_PROBES_PATH, SUBSCRIBE_EVENTS_PATH, UNIFIED_SEND_PATH,
UPDATE_CHANNEL_CONFIG_PATH, VERIFY_SIGNATURE_PATH,
};
use ldk_server_grpc::events::EventEnvelope;
Expand Down Expand Up @@ -333,6 +335,20 @@ impl LdkServerClient {
self.grpc_unary(&request, OPEN_CHANNEL_PATH).await
}

/// Place an LSPS1 order for an inbound channel from the configured LSP.
pub async fn lsps1_request_channel(
&self, request: Lsps1RequestChannelRequest,
) -> Result<Lsps1RequestChannelResponse, LdkServerError> {
self.grpc_unary(&request, LSPS1_REQUEST_CHANNEL_PATH).await
}

/// Check the status of a previously placed LSPS1 channel order.
pub async fn lsps1_check_order_status(
&self, request: Lsps1CheckOrderStatusRequest,
) -> Result<Lsps1CheckOrderStatusResponse, LdkServerError> {
self.grpc_unary(&request, LSPS1_CHECK_ORDER_STATUS_PATH).await
}

/// Splices funds into the channel specified by given request.
pub async fn splice_in(
&self, request: SpliceInRequest,
Expand Down
Loading
Loading