@@ -176,19 +176,20 @@ impl OutboundJITChannelState {
176176
177177struct OutboundJITChannel {
178178 state : OutboundJITChannelState ,
179- scid : u64 ,
179+ intercept_scid : u64 ,
180180 cltv_expiry_delta : u32 ,
181181 client_trusts_lsp : bool ,
182182 user_channel_id : u128 ,
183183}
184184
185185impl OutboundJITChannel {
186186 fn new (
187- scid : u64 , cltv_expiry_delta : u32 , client_trusts_lsp : bool , payment_size_msat : Option < u64 > ,
188- opening_fee_params : OpeningFeeParams , user_channel_id : u128 ,
187+ intercept_scid : u64 , cltv_expiry_delta : u32 , client_trusts_lsp : bool ,
188+ payment_size_msat : Option < u64 > , opening_fee_params : OpeningFeeParams ,
189+ user_channel_id : u128 ,
189190 ) -> Self {
190191 Self {
191- scid ,
192+ intercept_scid ,
192193 cltv_expiry_delta,
193194 client_trusts_lsp,
194195 user_channel_id,
@@ -240,25 +241,29 @@ impl OutboundJITChannel {
240241}
241242
242243struct PeerState {
243- outbound_channels_by_scid : HashMap < u64 , OutboundJITChannel > ,
244- scid_by_user_channel_id : HashMap < u128 , u64 > ,
244+ outbound_channels_by_intercept_scid : HashMap < u64 , OutboundJITChannel > ,
245+ intercept_scid_by_user_channel_id : HashMap < u128 , u64 > ,
245246 pending_requests : HashMap < RequestId , LSPS2Request > ,
246247}
247248
248249impl PeerState {
249250 fn new ( ) -> Self {
250- let outbound_channels_by_scid = HashMap :: new ( ) ;
251+ let outbound_channels_by_intercept_scid = HashMap :: new ( ) ;
251252 let pending_requests = HashMap :: new ( ) ;
252- let scid_by_user_channel_id = HashMap :: new ( ) ;
253- Self { outbound_channels_by_scid, pending_requests, scid_by_user_channel_id }
253+ let intercept_scid_by_user_channel_id = HashMap :: new ( ) ;
254+ Self {
255+ outbound_channels_by_intercept_scid,
256+ pending_requests,
257+ intercept_scid_by_user_channel_id,
258+ }
254259 }
255260
256- fn insert_outbound_channel ( & mut self , scid : u64 , channel : OutboundJITChannel ) {
257- self . outbound_channels_by_scid . insert ( scid , channel) ;
261+ fn insert_outbound_channel ( & mut self , intercept_scid : u64 , channel : OutboundJITChannel ) {
262+ self . outbound_channels_by_intercept_scid . insert ( intercept_scid , channel) ;
258263 }
259264
260- fn remove_outbound_channel ( & mut self , scid : u64 ) {
261- self . outbound_channels_by_scid . remove ( & scid ) ;
265+ fn remove_outbound_channel ( & mut self , intercept_scid : u64 ) {
266+ self . outbound_channels_by_intercept_scid . remove ( & intercept_scid ) ;
262267 }
263268}
264269
@@ -272,7 +277,7 @@ where
272277 pending_messages : MQ ,
273278 pending_events : Arc < EventQueue > ,
274279 per_peer_state : RwLock < HashMap < PublicKey , Mutex < PeerState > > > ,
275- peer_by_scid : RwLock < HashMap < u64 , PublicKey > > ,
280+ peer_by_intercept_scid : RwLock < HashMap < u64 , PublicKey > > ,
276281 config : LSPS2ServiceConfig ,
277282}
278283
@@ -290,7 +295,7 @@ where
290295 pending_messages,
291296 pending_events,
292297 per_peer_state : RwLock :: new ( HashMap :: new ( ) ) ,
293- peer_by_scid : RwLock :: new ( HashMap :: new ( ) ) ,
298+ peer_by_intercept_scid : RwLock :: new ( HashMap :: new ( ) ) ,
294299 channel_manager,
295300 config,
296301 }
@@ -378,13 +383,13 @@ where
378383 }
379384 }
380385
381- /// Used by LSP to provide client with the scid and cltv_expiry_delta to use in their invoice.
386+ /// Used by LSP to provide client with the intercept scid and cltv_expiry_delta to use in their invoice.
382387 ///
383388 /// Should be called in response to receiving a [`LSPS2ServiceEvent::BuyRequest`] event.
384389 ///
385390 /// [`LSPS2ServiceEvent::BuyRequest`]: crate::lsps2::event::LSPS2ServiceEvent::BuyRequest
386391 pub fn invoice_parameters_generated (
387- & self , counterparty_node_id : & PublicKey , request_id : RequestId , scid : u64 ,
392+ & self , counterparty_node_id : & PublicKey , request_id : RequestId , intercept_scid : u64 ,
388393 cltv_expiry_delta : u32 , client_trusts_lsp : bool , user_channel_id : u128 ,
389394 ) -> Result < ( ) , APIError > {
390395 let outer_state_lock = self . per_peer_state . read ( ) . unwrap ( ) ;
@@ -396,27 +401,30 @@ where
396401 match peer_state. pending_requests . remove ( & request_id) {
397402 Some ( LSPS2Request :: Buy ( buy_request) ) => {
398403 {
399- let mut peer_by_scid = self . peer_by_scid . write ( ) . unwrap ( ) ;
400- peer_by_scid. insert ( scid, * counterparty_node_id) ;
404+ let mut peer_by_intercept_scid =
405+ self . peer_by_intercept_scid . write ( ) . unwrap ( ) ;
406+ peer_by_intercept_scid. insert ( intercept_scid, * counterparty_node_id) ;
401407 }
402408
403409 let outbound_jit_channel = OutboundJITChannel :: new (
404- scid ,
410+ intercept_scid ,
405411 cltv_expiry_delta,
406412 client_trusts_lsp,
407413 buy_request. payment_size_msat ,
408414 buy_request. opening_fee_params ,
409415 user_channel_id,
410416 ) ;
411417
412- peer_state. scid_by_user_channel_id . insert ( user_channel_id, scid) ;
413- peer_state. insert_outbound_channel ( scid, outbound_jit_channel) ;
418+ peer_state
419+ . intercept_scid_by_user_channel_id
420+ . insert ( user_channel_id, intercept_scid) ;
421+ peer_state. insert_outbound_channel ( intercept_scid, outbound_jit_channel) ;
414422
415423 self . enqueue_response (
416424 counterparty_node_id,
417425 request_id,
418426 LSPS2Response :: Buy ( BuyResponse {
419- jit_channel_scid : scid . into ( ) ,
427+ intercept_scid : intercept_scid . into ( ) ,
420428 lsp_cltv_expiry_delta : cltv_expiry_delta,
421429 client_trusts_lsp,
422430 } ) ,
@@ -437,26 +445,28 @@ where
437445
438446 /// Forward [`Event::HTLCIntercepted`] event parameters into this function.
439447 ///
440- /// Will fail the intercepted HTLC if the scid matches a payment we are expecting
448+ /// Will fail the intercepted HTLC if the intercept scid matches a payment we are expecting
441449 /// but the payment amount is incorrect or the expiry has passed.
442450 ///
443- /// Will generate a [`LSPS2ServiceEvent::OpenChannel`] event if the scid matches a payment we are expected
451+ /// Will generate a [`LSPS2ServiceEvent::OpenChannel`] event if the intercept scid matches a payment we are expected
444452 /// and the payment amount is correct and the offer has not expired.
445453 ///
446- /// Will do nothing if the scid does not match any of the ones we gave out.
454+ /// Will do nothing if the intercept scid does not match any of the ones we gave out.
447455 ///
448456 /// [`Event::HTLCIntercepted`]: lightning::events::Event::HTLCIntercepted
449457 /// [`LSPS2ServiceEvent::OpenChannel`]: crate::lsps2::event::LSPS2ServiceEvent::OpenChannel
450458 pub fn htlc_intercepted (
451- & self , scid : u64 , intercept_id : InterceptId , expected_outbound_amount_msat : u64 ,
459+ & self , intercept_scid : u64 , intercept_id : InterceptId , expected_outbound_amount_msat : u64 ,
452460 ) -> Result < ( ) , APIError > {
453- let peer_by_scid = self . peer_by_scid . read ( ) . unwrap ( ) ;
454- if let Some ( counterparty_node_id) = peer_by_scid . get ( & scid ) {
461+ let peer_by_intercept_scid = self . peer_by_intercept_scid . read ( ) . unwrap ( ) ;
462+ if let Some ( counterparty_node_id) = peer_by_intercept_scid . get ( & intercept_scid ) {
455463 let outer_state_lock = self . per_peer_state . read ( ) . unwrap ( ) ;
456464 match outer_state_lock. get ( counterparty_node_id) {
457465 Some ( inner_state_lock) => {
458466 let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
459- if let Some ( jit_channel) = peer_state. outbound_channels_by_scid . get_mut ( & scid) {
467+ if let Some ( jit_channel) =
468+ peer_state. outbound_channels_by_intercept_scid . get_mut ( & intercept_scid)
469+ {
460470 let htlc = InterceptedHTLC { intercept_id, expected_outbound_amount_msat } ;
461471 match jit_channel. htlc_intercepted ( htlc) {
462472 Ok ( Some ( ( opening_fee_msat, amt_to_forward_msat) ) ) => {
@@ -466,7 +476,7 @@ where
466476 amt_to_forward_msat,
467477 opening_fee_msat,
468478 user_channel_id : jit_channel. user_channel_id ,
469- scid ,
479+ intercept_scid ,
470480 } ,
471481 ) ) ;
472482 }
@@ -475,16 +485,18 @@ where
475485 self . channel_manager
476486 . get_cm ( )
477487 . fail_intercepted_htlc ( intercept_id) ?;
478- peer_state. outbound_channels_by_scid . remove ( & scid) ;
479- // TODO: cleanup peer_by_scid
488+ peer_state
489+ . outbound_channels_by_intercept_scid
490+ . remove ( & intercept_scid) ;
491+ // TODO: cleanup peer_by_intercept_scid
480492 return Err ( APIError :: APIMisuseError { err : e. err } ) ;
481493 }
482494 }
483495 }
484496 }
485497 None => {
486498 return Err ( APIError :: APIMisuseError {
487- err : format ! ( "No counterparty found for scid: {}" , scid ) ,
499+ err : format ! ( "No counterparty found for scid: {}" , intercept_scid ) ,
488500 } ) ;
489501 }
490502 }
@@ -506,10 +518,12 @@ where
506518 match outer_state_lock. get ( counterparty_node_id) {
507519 Some ( inner_state_lock) => {
508520 let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
509- if let Some ( scid ) =
510- peer_state. scid_by_user_channel_id . get ( & user_channel_id) . copied ( )
521+ if let Some ( intercept_scid ) =
522+ peer_state. intercept_scid_by_user_channel_id . get ( & user_channel_id) . copied ( )
511523 {
512- if let Some ( jit_channel) = peer_state. outbound_channels_by_scid . get_mut ( & scid) {
524+ if let Some ( jit_channel) =
525+ peer_state. outbound_channels_by_intercept_scid . get_mut ( & intercept_scid)
526+ {
513527 match jit_channel. channel_ready ( ) {
514528 Ok ( ( htlcs, total_amt_to_forward_msat) ) => {
515529 let amounts_to_forward_msat = calculate_amount_to_forward_per_htlc (
0 commit comments