Skip to content

Commit dc62253

Browse files
authored
Merge pull request #83 from benthecarman/update-channel-config-cli
Add update channel config cli command
2 parents 48a02e5 + 81a1a0f commit dc62253

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

ldk-server-cli/src/main.rs

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use ldk_server_client::ldk_server_protos::api::{
88
Bolt11ReceiveRequest, Bolt11SendRequest, Bolt12ReceiveRequest, Bolt12SendRequest,
99
CloseChannelRequest, ForceCloseChannelRequest, GetBalancesRequest, GetNodeInfoRequest,
1010
ListChannelsRequest, ListPaymentsRequest, OnchainReceiveRequest, OnchainSendRequest,
11-
OpenChannelRequest, SpliceInRequest, SpliceOutRequest,
11+
OpenChannelRequest, SpliceInRequest, SpliceOutRequest, UpdateChannelConfigRequest,
1212
};
1313
use ldk_server_client::ldk_server_protos::types::RouteParametersConfig;
1414
use ldk_server_client::ldk_server_protos::types::{
@@ -169,6 +169,27 @@ enum Commands {
169169
)]
170170
number_of_payments: Option<u64>,
171171
},
172+
UpdateChannelConfig {
173+
#[arg(short, long)]
174+
user_channel_id: String,
175+
#[arg(short, long)]
176+
counterparty_node_id: String,
177+
#[arg(
178+
long,
179+
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."
180+
)]
181+
forwarding_fee_proportional_millionths: Option<u32>,
182+
#[arg(
183+
long,
184+
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."
185+
)]
186+
forwarding_fee_base_msat: Option<u32>,
187+
#[arg(
188+
long,
189+
help = "The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over the channel."
190+
)]
191+
cltv_expiry_delta: Option<u32>,
192+
},
172193
}
173194

174195
#[tokio::main]
@@ -374,6 +395,32 @@ async fn main() {
374395
Commands::ListPayments { number_of_payments } => {
375396
handle_response_result(list_n_payments(client, number_of_payments).await);
376397
},
398+
Commands::UpdateChannelConfig {
399+
user_channel_id,
400+
counterparty_node_id,
401+
forwarding_fee_proportional_millionths,
402+
forwarding_fee_base_msat,
403+
cltv_expiry_delta,
404+
} => {
405+
let channel_config = ChannelConfig {
406+
forwarding_fee_proportional_millionths,
407+
forwarding_fee_base_msat,
408+
cltv_expiry_delta,
409+
force_close_avoidance_max_fee_satoshis: None,
410+
accept_underpaying_htlcs: None,
411+
max_dust_htlc_exposure: None,
412+
};
413+
414+
handle_response_result(
415+
client
416+
.update_channel_config(UpdateChannelConfigRequest {
417+
user_channel_id,
418+
counterparty_node_id,
419+
channel_config: Some(channel_config),
420+
})
421+
.await,
422+
);
423+
},
377424
}
378425
}
379426

ldk-server-client/src/client.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ use ldk_server_protos::api::{
1212
ListChannelsRequest, ListChannelsResponse, ListPaymentsRequest, ListPaymentsResponse,
1313
OnchainReceiveRequest, OnchainReceiveResponse, OnchainSendRequest, OnchainSendResponse,
1414
OpenChannelRequest, OpenChannelResponse, SpliceInRequest, SpliceInResponse, SpliceOutRequest,
15-
SpliceOutResponse,
15+
SpliceOutResponse, UpdateChannelConfigRequest, UpdateChannelConfigResponse,
1616
};
1717
use ldk_server_protos::endpoints::{
1818
BOLT11_RECEIVE_PATH, BOLT11_SEND_PATH, BOLT12_RECEIVE_PATH, BOLT12_SEND_PATH,
1919
CLOSE_CHANNEL_PATH, FORCE_CLOSE_CHANNEL_PATH, GET_BALANCES_PATH, GET_NODE_INFO_PATH,
2020
LIST_CHANNELS_PATH, LIST_PAYMENTS_PATH, ONCHAIN_RECEIVE_PATH, ONCHAIN_SEND_PATH,
21-
OPEN_CHANNEL_PATH, SPLICE_IN_PATH, SPLICE_OUT_PATH,
21+
OPEN_CHANNEL_PATH, SPLICE_IN_PATH, SPLICE_OUT_PATH, UPDATE_CHANNEL_CONFIG_PATH,
2222
};
2323
use ldk_server_protos::error::{ErrorCode, ErrorResponse};
2424
use reqwest::header::CONTENT_TYPE;
@@ -174,6 +174,15 @@ impl LdkServerClient {
174174
self.post_request(&request, &url).await
175175
}
176176

177+
/// Updates the config for a previously opened channel.
178+
/// For API contract/usage, refer to docs for [`UpdateChannelConfigRequest`] and [`UpdateChannelConfigResponse`].
179+
pub async fn update_channel_config(
180+
&self, request: UpdateChannelConfigRequest,
181+
) -> Result<UpdateChannelConfigResponse, LdkServerError> {
182+
let url = format!("http://{}/{UPDATE_CHANNEL_CONFIG_PATH}", self.base_url);
183+
self.post_request(&request, &url).await
184+
}
185+
177186
async fn post_request<Rq: Message, Rs: Message + Default>(
178187
&self, request: &Rq, url: &str,
179188
) -> Result<Rs, LdkServerError> {

0 commit comments

Comments
 (0)