Skip to content

Commit 22cae11

Browse files
committed
Add ChannelConfig options to open channel cli command
These were available on the server side but not in the cli. Not all options are given as they aren't likely to be used and more likely to be confusing to users.
1 parent 40f5ddc commit 22cae11

1 file changed

Lines changed: 50 additions & 2 deletions

File tree

‎ldk-server-cli/src/main.rs‎

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ use ldk_server_client::ldk_server_protos::api::{
1111
OpenChannelRequest,
1212
};
1313
use ldk_server_client::ldk_server_protos::types::{
14-
bolt11_invoice_description, Bolt11InvoiceDescription, PageToken, Payment,
14+
bolt11_invoice_description, channel_config, Bolt11InvoiceDescription, ChannelConfig, PageToken,
15+
Payment,
1516
};
1617
use std::fmt::Debug;
1718

@@ -101,6 +102,22 @@ enum Commands {
101102
push_to_counterparty_msat: Option<u64>,
102103
#[arg(long)]
103104
announce_channel: bool,
105+
// Channel config options
106+
#[arg(
107+
long,
108+
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."
109+
)]
110+
forwarding_fee_proportional_millionths: Option<u32>,
111+
#[arg(
112+
long,
113+
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."
114+
)]
115+
forwarding_fee_base_msat: Option<u32>,
116+
#[arg(
117+
long,
118+
help = "The difference in the CLTV value between incoming HTLCs and an outbound HTLC forwarded over the channel. This can be updated by using update-channel-config."
119+
)]
120+
cltv_expiry_delta: Option<u32>,
104121
},
105122
ListChannels,
106123
ListPayments {
@@ -213,15 +230,24 @@ async fn main() {
213230
channel_amount_sats,
214231
push_to_counterparty_msat,
215232
announce_channel,
233+
forwarding_fee_proportional_millionths,
234+
forwarding_fee_base_msat,
235+
cltv_expiry_delta,
216236
} => {
237+
let channel_config = build_open_channel_config(
238+
forwarding_fee_proportional_millionths,
239+
forwarding_fee_base_msat,
240+
cltv_expiry_delta,
241+
);
242+
217243
handle_response_result(
218244
client
219245
.open_channel(OpenChannelRequest {
220246
node_pubkey,
221247
address,
222248
channel_amount_sats,
223249
push_to_counterparty_msat,
224-
channel_config: None,
250+
channel_config,
225251
announce_channel,
226252
})
227253
.await,
@@ -236,6 +262,28 @@ async fn main() {
236262
}
237263
}
238264

265+
fn build_open_channel_config(
266+
forwarding_fee_proportional_millionths: Option<u32>, forwarding_fee_base_msat: Option<u32>,
267+
cltv_expiry_delta: Option<u32>,
268+
) -> Option<ChannelConfig> {
269+
// Only create a config if at least one field is set
270+
if forwarding_fee_proportional_millionths.is_none()
271+
&& forwarding_fee_base_msat.is_none()
272+
&& cltv_expiry_delta.is_none()
273+
{
274+
return None;
275+
}
276+
277+
Some(ChannelConfig {
278+
forwarding_fee_proportional_millionths,
279+
forwarding_fee_base_msat,
280+
cltv_expiry_delta,
281+
force_close_avoidance_max_fee_satoshis: None,
282+
accept_underpaying_htlcs: None,
283+
max_dust_htlc_exposure: None,
284+
})
285+
}
286+
239287
async fn list_n_payments(
240288
client: LdkServerClient, number_of_payments: Option<u64>,
241289
) -> Result<Vec<Payment>, LdkServerError> {

0 commit comments

Comments
 (0)