@@ -10,12 +10,20 @@ use ldk_server_client::ldk_server_protos::api::{
1010 ListChannelsRequest , ListPaymentsRequest , OnchainReceiveRequest , OnchainSendRequest ,
1111 OpenChannelRequest , SpliceInRequest , SpliceOutRequest ,
1212} ;
13+ use ldk_server_client:: ldk_server_protos:: types:: RouteParametersConfig ;
1314use ldk_server_client:: ldk_server_protos:: types:: {
1415 bolt11_invoice_description, channel_config, Bolt11InvoiceDescription , ChannelConfig , PageToken ,
1516 Payment ,
1617} ;
1718use std:: fmt:: Debug ;
1819
20+ // Having these default values as constants in the Proto file and
21+ // importing/reusing them here might be better, but Proto3 removed
22+ // the ability to set default values.
23+ const DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA : u32 = 1008 ;
24+ const DEFAULT_MAX_PATH_COUNT : u32 = 10 ;
25+ const DEFAULT_MAX_CHANNEL_SATURATION_POWER_OF_HALF : u32 = 2 ;
26+
1927#[ derive( Parser , Debug ) ]
2028#[ command( version, about, long_about = None ) ]
2129struct Cli {
@@ -56,6 +64,14 @@ enum Commands {
5664 invoice : String ,
5765 #[ arg( long) ]
5866 amount_msat : Option < u64 > ,
67+ #[ arg( long) ]
68+ max_total_routing_fee_msat : Option < u64 > ,
69+ #[ arg( long) ]
70+ max_total_cltv_expiry_delta : Option < u32 > ,
71+ #[ arg( long) ]
72+ max_path_count : Option < u32 > ,
73+ #[ arg( long) ]
74+ max_channel_saturation_power_of_half : Option < u32 > ,
5975 } ,
6076 Bolt12Receive {
6177 #[ arg( short, long) ]
@@ -76,6 +92,14 @@ enum Commands {
7692 quantity : Option < u64 > ,
7793 #[ arg( short, long) ]
7894 payer_note : Option < String > ,
95+ #[ arg( long) ]
96+ max_total_routing_fee_msat : Option < u64 > ,
97+ #[ arg( long) ]
98+ max_total_cltv_expiry_delta : Option < u32 > ,
99+ #[ arg( long) ]
100+ max_path_count : Option < u32 > ,
101+ #[ arg( long) ]
102+ max_channel_saturation_power_of_half : Option < u32 > ,
79103 } ,
80104 CloseChannel {
81105 #[ arg( short, long) ]
@@ -196,9 +220,30 @@ async fn main() {
196220
197221 handle_response_result ( client. bolt11_receive ( request) . await ) ;
198222 } ,
199- Commands :: Bolt11Send { invoice, amount_msat } => {
223+ Commands :: Bolt11Send {
224+ invoice,
225+ amount_msat,
226+ max_total_routing_fee_msat,
227+ max_total_cltv_expiry_delta,
228+ max_path_count,
229+ max_channel_saturation_power_of_half,
230+ } => {
231+ let route_parameters = RouteParametersConfig {
232+ max_total_routing_fee_msat,
233+ max_total_cltv_expiry_delta : max_total_cltv_expiry_delta
234+ . unwrap_or ( DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA ) ,
235+ max_path_count : max_path_count. unwrap_or ( DEFAULT_MAX_PATH_COUNT ) ,
236+ max_channel_saturation_power_of_half : max_channel_saturation_power_of_half
237+ . unwrap_or ( DEFAULT_MAX_CHANNEL_SATURATION_POWER_OF_HALF ) ,
238+ } ;
200239 handle_response_result (
201- client. bolt11_send ( Bolt11SendRequest { invoice, amount_msat } ) . await ,
240+ client
241+ . bolt11_send ( Bolt11SendRequest {
242+ invoice,
243+ amount_msat,
244+ route_parameters : Some ( route_parameters) ,
245+ } )
246+ . await ,
202247 ) ;
203248 } ,
204249 Commands :: Bolt12Receive { description, amount_msat, expiry_secs, quantity } => {
@@ -213,10 +258,34 @@ async fn main() {
213258 . await ,
214259 ) ;
215260 } ,
216- Commands :: Bolt12Send { offer, amount_msat, quantity, payer_note } => {
261+ Commands :: Bolt12Send {
262+ offer,
263+ amount_msat,
264+ quantity,
265+ payer_note,
266+ max_total_routing_fee_msat,
267+ max_total_cltv_expiry_delta,
268+ max_path_count,
269+ max_channel_saturation_power_of_half,
270+ } => {
271+ let route_parameters = RouteParametersConfig {
272+ max_total_routing_fee_msat,
273+ max_total_cltv_expiry_delta : max_total_cltv_expiry_delta
274+ . unwrap_or ( DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA ) ,
275+ max_path_count : max_path_count. unwrap_or ( DEFAULT_MAX_PATH_COUNT ) ,
276+ max_channel_saturation_power_of_half : max_channel_saturation_power_of_half
277+ . unwrap_or ( DEFAULT_MAX_CHANNEL_SATURATION_POWER_OF_HALF ) ,
278+ } ;
279+
217280 handle_response_result (
218281 client
219- . bolt12_send ( Bolt12SendRequest { offer, amount_msat, quantity, payer_note } )
282+ . bolt12_send ( Bolt12SendRequest {
283+ offer,
284+ amount_msat,
285+ quantity,
286+ payer_note,
287+ route_parameters : Some ( route_parameters) ,
288+ } )
220289 . await ,
221290 ) ;
222291 } ,
0 commit comments