Skip to content
Merged
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
49 changes: 48 additions & 1 deletion ldk-server-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ldk_server_client::ldk_server_protos::api::{
Bolt11ReceiveRequest, Bolt11SendRequest, Bolt12ReceiveRequest, Bolt12SendRequest,
CloseChannelRequest, ForceCloseChannelRequest, GetBalancesRequest, GetNodeInfoRequest,
ListChannelsRequest, ListPaymentsRequest, OnchainReceiveRequest, OnchainSendRequest,
OpenChannelRequest, SpliceInRequest, SpliceOutRequest,
OpenChannelRequest, SpliceInRequest, SpliceOutRequest, UpdateChannelConfigRequest,
};
use ldk_server_client::ldk_server_protos::types::RouteParametersConfig;
use ldk_server_client::ldk_server_protos::types::{
Expand Down Expand Up @@ -169,6 +169,27 @@ enum Commands {
)]
number_of_payments: Option<u64>,
},
UpdateChannelConfig {
#[arg(short, long)]
user_channel_id: String,
#[arg(short, long)]
counterparty_node_id: String,
#[arg(
long,
help = "Amount (in millionths of a satoshi) charged per satoshi for payments forwarded outbound over the channel. This can be updated by using update-channel-config."
)]
forwarding_fee_proportional_millionths: Option<u32>,
#[arg(
long,
help = "Amount (in milli-satoshi) charged for payments forwarded outbound over the channel, in excess of forwarding_fee_proportional_millionths. This can be updated by using update-channel-config."
)]
forwarding_fee_base_msat: Option<u32>,
#[arg(
long,
help = "The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over the channel."
)]
cltv_expiry_delta: Option<u32>,
},
}

#[tokio::main]
Expand Down Expand Up @@ -374,6 +395,32 @@ async fn main() {
Commands::ListPayments { number_of_payments } => {
handle_response_result(list_n_payments(client, number_of_payments).await);
},
Commands::UpdateChannelConfig {
user_channel_id,
counterparty_node_id,
forwarding_fee_proportional_millionths,
forwarding_fee_base_msat,
cltv_expiry_delta,
} => {
let channel_config = ChannelConfig {
forwarding_fee_proportional_millionths,
forwarding_fee_base_msat,
cltv_expiry_delta,
force_close_avoidance_max_fee_satoshis: None,
accept_underpaying_htlcs: None,
max_dust_htlc_exposure: None,
};

handle_response_result(
client
.update_channel_config(UpdateChannelConfigRequest {
user_channel_id,
counterparty_node_id,
channel_config: Some(channel_config),
})
.await,
);
},
}
}

Expand Down
13 changes: 11 additions & 2 deletions ldk-server-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ use ldk_server_protos::api::{
ListChannelsRequest, ListChannelsResponse, ListPaymentsRequest, ListPaymentsResponse,
OnchainReceiveRequest, OnchainReceiveResponse, OnchainSendRequest, OnchainSendResponse,
OpenChannelRequest, OpenChannelResponse, SpliceInRequest, SpliceInResponse, SpliceOutRequest,
SpliceOutResponse,
SpliceOutResponse, UpdateChannelConfigRequest, UpdateChannelConfigResponse,
};
use ldk_server_protos::endpoints::{
BOLT11_RECEIVE_PATH, BOLT11_SEND_PATH, BOLT12_RECEIVE_PATH, BOLT12_SEND_PATH,
CLOSE_CHANNEL_PATH, FORCE_CLOSE_CHANNEL_PATH, GET_BALANCES_PATH, GET_NODE_INFO_PATH,
LIST_CHANNELS_PATH, LIST_PAYMENTS_PATH, ONCHAIN_RECEIVE_PATH, ONCHAIN_SEND_PATH,
OPEN_CHANNEL_PATH, SPLICE_IN_PATH, SPLICE_OUT_PATH,
OPEN_CHANNEL_PATH, SPLICE_IN_PATH, SPLICE_OUT_PATH, UPDATE_CHANNEL_CONFIG_PATH,
};
use ldk_server_protos::error::{ErrorCode, ErrorResponse};
use reqwest::header::CONTENT_TYPE;
Expand Down Expand Up @@ -174,6 +174,15 @@ impl LdkServerClient {
self.post_request(&request, &url).await
}

/// Updates the config for a previously opened channel.
/// For API contract/usage, refer to docs for [`UpdateChannelConfigRequest`] and [`UpdateChannelConfigResponse`].
pub async fn update_channel_config(
&self, request: UpdateChannelConfigRequest,
) -> Result<UpdateChannelConfigResponse, LdkServerError> {
let url = format!("http://{}/{UPDATE_CHANNEL_CONFIG_PATH}", self.base_url);
self.post_request(&request, &url).await
}

async fn post_request<Rq: Message, Rs: Message + Default>(
&self, request: &Rq, url: &str,
) -> Result<Rs, LdkServerError> {
Expand Down