@@ -10,11 +10,19 @@ use ldk_server_client::ldk_server_protos::api::{
1010 ListChannelsRequest , ListPaymentsRequest , OnchainReceiveRequest , OnchainSendRequest ,
1111 OpenChannelRequest ,
1212} ;
13+ use ldk_server_client:: ldk_server_protos:: types:: RouteParametersConfig ;
1314use ldk_server_client:: ldk_server_protos:: types:: {
1415 bolt11_invoice_description, Bolt11InvoiceDescription , PageToken , Payment ,
1516} ;
1617use std:: fmt:: Debug ;
1718
19+ // Having these default values as constants in the Proto file and
20+ // importing/reusing them here might be better, but Proto3 removed
21+ // the ability to set default values.
22+ const DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA : u32 = 1008 ;
23+ const DEFAULT_MAX_PATH_COUNT : u32 = 10 ;
24+ const DEFAULT_MAX_CHANNEL_SATURATION_POWER_OF_HALF : u32 = 2 ;
25+
1826#[ derive( Parser , Debug ) ]
1927#[ command( version, about, long_about = None ) ]
2028struct Cli {
@@ -55,6 +63,14 @@ enum Commands {
5563 invoice : String ,
5664 #[ arg( long) ]
5765 amount_msat : Option < u64 > ,
66+ #[ arg( long) ]
67+ max_total_routing_fee_msat : Option < u64 > ,
68+ #[ arg( long) ]
69+ max_total_cltv_expiry_delta : Option < u32 > ,
70+ #[ arg( long) ]
71+ max_path_count : Option < u32 > ,
72+ #[ arg( long) ]
73+ max_channel_saturation_power_of_half : Option < u32 > ,
5874 } ,
5975 Bolt12Receive {
6076 #[ arg( short, long) ]
@@ -75,6 +91,14 @@ enum Commands {
7591 quantity : Option < u64 > ,
7692 #[ arg( short, long) ]
7793 payer_note : Option < String > ,
94+ #[ arg( long) ]
95+ max_total_routing_fee_msat : Option < u64 > ,
96+ #[ arg( long) ]
97+ max_total_cltv_expiry_delta : Option < u32 > ,
98+ #[ arg( long) ]
99+ max_path_count : Option < u32 > ,
100+ #[ arg( long) ]
101+ max_channel_saturation_power_of_half : Option < u32 > ,
78102 } ,
79103 CloseChannel {
80104 #[ arg( short, long) ]
@@ -161,9 +185,30 @@ async fn main() {
161185
162186 handle_response_result ( client. bolt11_receive ( request) . await ) ;
163187 } ,
164- Commands :: Bolt11Send { invoice, amount_msat } => {
188+ Commands :: Bolt11Send {
189+ invoice,
190+ amount_msat,
191+ max_total_routing_fee_msat,
192+ max_total_cltv_expiry_delta,
193+ max_path_count,
194+ max_channel_saturation_power_of_half,
195+ } => {
196+ let route_parameters = RouteParametersConfig {
197+ max_total_routing_fee_msat,
198+ max_total_cltv_expiry_delta : max_total_cltv_expiry_delta
199+ . unwrap_or ( DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA ) ,
200+ max_path_count : max_path_count. unwrap_or ( DEFAULT_MAX_PATH_COUNT ) ,
201+ max_channel_saturation_power_of_half : max_channel_saturation_power_of_half
202+ . unwrap_or ( DEFAULT_MAX_CHANNEL_SATURATION_POWER_OF_HALF ) ,
203+ } ;
165204 handle_response_result (
166- client. bolt11_send ( Bolt11SendRequest { invoice, amount_msat } ) . await ,
205+ client
206+ . bolt11_send ( Bolt11SendRequest {
207+ invoice,
208+ amount_msat,
209+ route_parameters : Some ( route_parameters) ,
210+ } )
211+ . await ,
167212 ) ;
168213 } ,
169214 Commands :: Bolt12Receive { description, amount_msat, expiry_secs, quantity } => {
@@ -178,10 +223,34 @@ async fn main() {
178223 . await ,
179224 ) ;
180225 } ,
181- Commands :: Bolt12Send { offer, amount_msat, quantity, payer_note } => {
226+ Commands :: Bolt12Send {
227+ offer,
228+ amount_msat,
229+ quantity,
230+ payer_note,
231+ max_total_routing_fee_msat,
232+ max_total_cltv_expiry_delta,
233+ max_path_count,
234+ max_channel_saturation_power_of_half,
235+ } => {
236+ let route_parameters = RouteParametersConfig {
237+ max_total_routing_fee_msat,
238+ max_total_cltv_expiry_delta : max_total_cltv_expiry_delta
239+ . unwrap_or ( DEFAULT_MAX_TOTAL_CLTV_EXPIRY_DELTA ) ,
240+ max_path_count : max_path_count. unwrap_or ( DEFAULT_MAX_PATH_COUNT ) ,
241+ max_channel_saturation_power_of_half : max_channel_saturation_power_of_half
242+ . unwrap_or ( DEFAULT_MAX_CHANNEL_SATURATION_POWER_OF_HALF ) ,
243+ } ;
244+
182245 handle_response_result (
183246 client
184- . bolt12_send ( Bolt12SendRequest { offer, amount_msat, quantity, payer_note } )
247+ . bolt12_send ( Bolt12SendRequest {
248+ offer,
249+ amount_msat,
250+ quantity,
251+ payer_note,
252+ route_parameters : Some ( route_parameters) ,
253+ } )
185254 . await ,
186255 ) ;
187256 } ,
0 commit comments