@@ -167,19 +167,8 @@ async fn on_lsps_lsps2_buy(
167167    . context ( "Failed to create Bolt8Transport" ) ?; 
168168    let  client = JsonRpcClient :: new ( transport) ; 
169169
170-     // Convert from AmountOrAny to Msat. 
171-     let  payment_size_msat = if  let  Some ( payment_size)  = req. payment_size_msat  { 
172-         match  payment_size { 
173-             AmountOrAny :: Amount ( amount)  => Some ( Msat :: from_msat ( amount. msat ( ) ) ) , 
174-             AmountOrAny :: Any  => None , 
175-         } 
176-     }  else  { 
177-         None 
178-     } ; 
179- 
180170    let  selected_params = req. opening_fee_params ; 
181- 
182-     if  let  Some ( payment_size)  = payment_size_msat { 
171+     if  let  Some ( payment_size)  = req. payment_size_msat  { 
183172        if  payment_size < selected_params. min_payment_size_msat  { 
184173            return  Err ( anyhow ! ( 
185174                "Requested payment size {}msat is below minimum {}msat required by LSP" , 
@@ -224,7 +213,7 @@ async fn on_lsps_lsps2_buy(
224213    debug ! ( "Calling lsps2.buy for peer {}" ,  req. lsp_id) ; 
225214    let  buy_req = Lsps2BuyRequest  { 
226215        opening_fee_params :  selected_params,  // Pass the chosen params back 
227-         payment_size_msat, 
216+         payment_size_msat :  req . payment_size_msat , 
228217    } ; 
229218    let  buy_res:  Lsps2BuyResponse  = client
230219        . call_typed ( buy_req) 
@@ -270,16 +259,18 @@ async fn on_lsps_jitchannel(
270259    #[ derive( Deserialize ) ]  
271260    struct  Request  { 
272261        lsp_id :  String , 
273-         // Optional: for fixed-amount invoices 
274-         payment_size_msat :  Option < AmountOrAny > , 
275262        // Optional: for discounts/API keys 
276263        token :  Option < String > , 
264+         // Pass-through of cln invoice rpc params 
265+         pub  amount_msat :  cln_rpc:: primitives:: AmountOrAny , 
266+         pub  description :  String , 
267+         pub  label :  String , 
277268    } 
278269
279270    let  req:  Request  = serde_json:: from_value ( v) . context ( "Failed to parse request JSON" ) ?; 
280271    debug ! ( 
281272        "Handling lsps-buy-jit-channel request for peer {} with payment_size {:?} and token {:?}" , 
282-         req. lsp_id,  req. payment_size_msat ,  req. token
273+         req. lsp_id,  req. amount_msat ,  req. token
283274    ) ; 
284275
285276    let  dir = p. configuration ( ) . lightning_dir ; 
@@ -322,13 +313,18 @@ async fn on_lsps_jitchannel(
322313
323314    info ! ( "Selected fee parameters: {:?}" ,  selected_params) ; 
324315
316+     let  payment_size_msat = match  req. amount_msat  { 
317+         AmountOrAny :: Amount ( amount)  => Some ( Msat :: from_msat ( amount. msat ( ) ) ) , 
318+         AmountOrAny :: Any  => None , 
319+     } ; 
320+ 
325321    // 3. Request channel from LSP. 
326322    let  buy_res:  Lsps2BuyResponse  = cln_client
327323        . call_raw ( 
328324            "lsps-lsps2-buy" , 
329325            & ClnRpcLsps2BuyRequest  { 
330326                lsp_id :  req. lsp_id . clone ( ) , 
331-                 payment_size_msat :  req . payment_size_msat , 
327+                 payment_size_msat, 
332328                opening_fee_params :  selected_params. clone ( ) , 
333329            } , 
334330        ) 
@@ -356,20 +352,14 @@ async fn on_lsps_jitchannel(
356352        cltv_expiry_delta :  u16:: try_from ( buy_res. lsp_cltv_expiry_delta ) ?, 
357353    } ; 
358354
359-     let  amount_msat = if  let  Some ( payment_size)  = req. payment_size_msat  { 
360-         payment_size
361-     }  else  { 
362-         AmountOrAny :: Any 
363-     } ; 
364- 
365355    let  inv:  cln_rpc:: model:: responses:: InvoiceResponse  = cln_client
366356        . call_raw ( 
367357            "invoice" , 
368358            & InvoiceRequest  { 
369-                 amount_msat, 
359+                 amount_msat :  req . amount_msat , 
370360                dev_routes :  Some ( vec ! [ vec![ hint] ] ) , 
371-                 description :  String :: from ( "TODO" ) ,   // TODO: Pass down  description from rpc call 
372-                 label :  gen_label ( None ) ,              // TODO: Pass down  label from rpc call 
361+                 description :  req . description , 
362+                 label :  req . label , 
373363                expiry :  Some ( expiry as  u64 ) , 
374364                cltv :  Some ( u32:: try_from ( 6  + 2 ) ?) ,  // TODO: FETCH REAL VALUE! 
375365                deschashonly :  None , 
@@ -619,15 +609,6 @@ async fn ensure_lsp_connected(cln_client: &mut ClnRpc, lsp_id: &str) -> Result<(
619609    Ok ( ( ) ) 
620610} 
621611
622- /// Generates a unique label from an optional `String`. The given label is 
623- /// appended by a timestamp (now). 
624- fn  gen_label ( label :  Option < & str > )  -> String  { 
625-     let  now = Utc :: now ( ) ; 
626-     let  millis = now. timestamp_millis ( ) ; 
627-     let  l = label. unwrap_or_else ( || "lsps2.buy" ) ; 
628-     format ! ( "{}_{}" ,  l,  millis) 
629- } 
630- 
631612#[ derive( Debug ,  Clone ,  PartialEq ,  Serialize ,  Deserialize ) ]  
632613struct  LspsBuyJitChannelResponse  { 
633614    bolt11 :  String , 
@@ -668,8 +649,7 @@ pub struct RoutehintHopDev {
668649#[ derive( Debug ,  Clone ,  Serialize ,  Deserialize ) ]  
669650struct  ClnRpcLsps2BuyRequest  { 
670651    lsp_id :  String , 
671-     #[ serde( skip_serializing_if = "Option::is_none" ) ]  
672-     payment_size_msat :  Option < AmountOrAny > , 
652+     payment_size_msat :  Option < Msat > , 
673653    opening_fee_params :  OpeningFeeParams , 
674654} 
675655
0 commit comments