@@ -185,9 +185,9 @@ impl InboundJITChannel {
185
185
}
186
186
187
187
pub fn invoice_params_received (
188
- & mut self , client_trusts_lsp : bool , lsps2_scid : JitChannelScid ,
188
+ & mut self , client_trusts_lsp : bool , jit_channel_scid : JitChannelScid ,
189
189
) -> Result < ( ) , LightningError > {
190
- self . state = self . state . invoice_params_received ( client_trusts_lsp, lsps2_scid ) ?;
190
+ self . state = self . state . invoice_params_received ( client_trusts_lsp, jit_channel_scid ) ?;
191
191
Ok ( ( ) )
192
192
}
193
193
}
@@ -370,20 +370,20 @@ struct PeerState {
370
370
}
371
371
372
372
impl PeerState {
373
- pub fn insert_inbound_channel ( & mut self , lsps2_id : u128 , channel : InboundJITChannel ) {
374
- self . inbound_channels_by_id . insert ( lsps2_id , channel) ;
373
+ pub fn insert_inbound_channel ( & mut self , jit_channel_id : u128 , channel : InboundJITChannel ) {
374
+ self . inbound_channels_by_id . insert ( jit_channel_id , channel) ;
375
375
}
376
376
377
377
pub fn insert_outbound_channel ( & mut self , scid : u64 , channel : OutboundJITChannel ) {
378
378
self . outbound_channels_by_scid . insert ( scid, channel) ;
379
379
}
380
380
381
- pub fn insert_request ( & mut self , request_id : RequestId , lsps2_id : u128 ) {
382
- self . request_to_cid . insert ( request_id, lsps2_id ) ;
381
+ pub fn insert_request ( & mut self , request_id : RequestId , jit_channel_id : u128 ) {
382
+ self . request_to_cid . insert ( request_id, jit_channel_id ) ;
383
383
}
384
384
385
- pub fn remove_inbound_channel ( & mut self , lsps2_id : u128 ) {
386
- self . inbound_channels_by_id . remove ( & lsps2_id ) ;
385
+ pub fn remove_inbound_channel ( & mut self , jit_channel_id : u128 ) {
386
+ self . inbound_channels_by_id . remove ( & jit_channel_id ) ;
387
387
}
388
388
389
389
pub fn remove_outbound_channel ( & mut self , scid : u64 ) {
@@ -490,18 +490,19 @@ where
490
490
& self , counterparty_node_id : PublicKey , payment_size_msat : Option < u64 > ,
491
491
token : Option < String > , user_channel_id : u128 ,
492
492
) {
493
- let lsps2_id = self . generate_lsps2_id ( ) ;
494
- let channel = InboundJITChannel :: new ( lsps2_id, user_channel_id, payment_size_msat, token) ;
493
+ let jit_channel_id = self . generate_jit_channel_id ( ) ;
494
+ let channel =
495
+ InboundJITChannel :: new ( jit_channel_id, user_channel_id, payment_size_msat, token) ;
495
496
496
497
let mut outer_state_lock = self . per_peer_state . write ( ) . unwrap ( ) ;
497
498
let inner_state_lock = outer_state_lock
498
499
. entry ( counterparty_node_id)
499
500
. or_insert ( Mutex :: new ( PeerState :: default ( ) ) ) ;
500
501
let peer_state = inner_state_lock. get_mut ( ) . unwrap ( ) ;
501
- peer_state. insert_inbound_channel ( lsps2_id , channel) ;
502
+ peer_state. insert_inbound_channel ( jit_channel_id , channel) ;
502
503
503
504
let request_id = self . generate_request_id ( ) ;
504
- peer_state. insert_request ( request_id. clone ( ) , lsps2_id ) ;
505
+ peer_state. insert_request ( request_id. clone ( ) , jit_channel_id ) ;
505
506
506
507
{
507
508
let mut pending_messages = self . pending_messages . lock ( ) . unwrap ( ) ;
@@ -588,25 +589,27 @@ where
588
589
}
589
590
590
591
pub fn opening_fee_params_selected (
591
- & self , counterparty_node_id : PublicKey , lsps2_id : u128 ,
592
+ & self , counterparty_node_id : PublicKey , jit_channel_id : u128 ,
592
593
opening_fee_params : OpeningFeeParams ,
593
594
) -> Result < ( ) , APIError > {
594
595
let outer_state_lock = self . per_peer_state . read ( ) . unwrap ( ) ;
595
596
match outer_state_lock. get ( & counterparty_node_id) {
596
597
Some ( inner_state_lock) => {
597
598
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
598
- if let Some ( lsps2) = peer_state. inbound_channels_by_id . get_mut ( & lsps2_id) {
599
- let version = match lsps2. opening_fee_params_selected ( ) {
599
+ if let Some ( jit_channel) =
600
+ peer_state. inbound_channels_by_id . get_mut ( & jit_channel_id)
601
+ {
602
+ let version = match jit_channel. opening_fee_params_selected ( ) {
600
603
Ok ( version) => version,
601
604
Err ( e) => {
602
- peer_state. remove_inbound_channel ( lsps2_id ) ;
605
+ peer_state. remove_inbound_channel ( jit_channel_id ) ;
603
606
return Err ( APIError :: APIMisuseError { err : e. err } ) ;
604
607
}
605
608
} ;
606
609
607
610
let request_id = self . generate_request_id ( ) ;
608
- let payment_size_msat = lsps2 . config . payment_size_msat ;
609
- peer_state. insert_request ( request_id. clone ( ) , lsps2_id ) ;
611
+ let payment_size_msat = jit_channel . config . payment_size_msat ;
612
+ peer_state. insert_request ( request_id. clone ( ) , jit_channel_id ) ;
610
613
611
614
{
612
615
let mut pending_messages = self . pending_messages . lock ( ) . unwrap ( ) ;
@@ -628,7 +631,7 @@ where
628
631
}
629
632
} else {
630
633
return Err ( APIError :: APIMisuseError {
631
- err : format ! ( "Channel with id {} not found" , lsps2_id ) ,
634
+ err : format ! ( "Channel with id {} not found" , jit_channel_id ) ,
632
635
} ) ;
633
636
}
634
637
}
@@ -659,21 +662,21 @@ where
659
662
peer_by_scid. insert ( scid, counterparty_node_id) ;
660
663
}
661
664
662
- let outbound_lsps2 = OutboundJITChannel :: new (
665
+ let outbound_jit_channel = OutboundJITChannel :: new (
663
666
scid,
664
667
cltv_expiry_delta,
665
668
client_trusts_lsp,
666
669
buy_request. payment_size_msat ,
667
670
buy_request. opening_fee_params ,
668
671
) ;
669
672
670
- peer_state. insert_outbound_channel ( scid, outbound_lsps2 ) ;
673
+ peer_state. insert_outbound_channel ( scid, outbound_jit_channel ) ;
671
674
672
675
self . enqueue_response (
673
676
counterparty_node_id,
674
677
request_id,
675
678
LSPS2Response :: Buy ( BuyResponse {
676
- lsps2_scid : scid. into ( ) ,
679
+ jit_channel_scid : scid. into ( ) ,
677
680
lsp_cltv_expiry_delta : cltv_expiry_delta,
678
681
client_trusts_lsp,
679
682
} ) ,
@@ -701,9 +704,9 @@ where
701
704
match outer_state_lock. get ( counterparty_node_id) {
702
705
Some ( inner_state_lock) => {
703
706
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
704
- if let Some ( lsps2 ) = peer_state. outbound_channels_by_scid . get_mut ( & scid) {
707
+ if let Some ( jit_channel ) = peer_state. outbound_channels_by_scid . get_mut ( & scid) {
705
708
let htlc = InterceptedHTLC { intercept_id, expected_outbound_amount_msat } ;
706
- match lsps2 . htlc_intercepted ( htlc) {
709
+ match jit_channel . htlc_intercepted ( htlc) {
707
710
Ok ( Some ( ( opening_fee_msat, amt_to_forward_msat) ) ) => {
708
711
self . enqueue_event ( Event :: LSPS2 ( LSPS2Event :: OpenChannel {
709
712
their_network_key : counterparty_node_id. clone ( ) ,
@@ -742,8 +745,8 @@ where
742
745
match outer_state_lock. get ( counterparty_node_id) {
743
746
Some ( inner_state_lock) => {
744
747
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
745
- if let Some ( lsps2 ) = peer_state. outbound_channels_by_scid . get_mut ( & scid) {
746
- match lsps2 . channel_ready ( ) {
748
+ if let Some ( jit_channel ) = peer_state. outbound_channels_by_scid . get_mut ( & scid) {
749
+ match jit_channel . channel_ready ( ) {
747
750
Ok ( ( htlcs, total_amt_to_forward_msat) ) => {
748
751
let amounts_to_forward_msat = calculate_amount_to_forward_per_htlc (
749
752
& htlcs,
@@ -790,7 +793,7 @@ where
790
793
Ok ( ( ) )
791
794
}
792
795
793
- fn generate_lsps2_id ( & self ) -> u128 {
796
+ fn generate_jit_channel_id ( & self ) -> u128 {
794
797
let bytes = self . entropy_source . get_secure_random_bytes ( ) ;
795
798
let mut id_bytes: [ u8 ; 16 ] = [ 0 ; 16 ] ;
796
799
id_bytes. copy_from_slice ( & bytes[ 0 ..16 ] ) ;
@@ -841,7 +844,7 @@ where
841
844
Some ( inner_state_lock) => {
842
845
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
843
846
844
- let lsps2_id =
847
+ let jit_channel_id =
845
848
peer_state. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
846
849
err : format ! (
847
850
"Received get_versions response for an unknown request: {:?}" ,
@@ -850,27 +853,29 @@ where
850
853
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
851
854
} ) ?;
852
855
853
- let lsps2 =
854
- peer_state. inbound_channels_by_id . get_mut ( & lsps2_id) . ok_or ( LightningError {
856
+ let jit_channel = peer_state
857
+ . inbound_channels_by_id
858
+ . get_mut ( & jit_channel_id)
859
+ . ok_or ( LightningError {
855
860
err : format ! (
856
861
"Received get_versions response for an unknown channel: {:?}" ,
857
- lsps2_id
862
+ jit_channel_id ,
858
863
) ,
859
864
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
860
865
} ) ?;
861
866
862
- let token = lsps2 . config . token . clone ( ) ;
867
+ let token = jit_channel . config . token . clone ( ) ;
863
868
864
- let version = match lsps2 . versions_received ( result. versions ) {
869
+ let version = match jit_channel . versions_received ( result. versions ) {
865
870
Ok ( version) => version,
866
871
Err ( e) => {
867
- peer_state. remove_inbound_channel ( lsps2_id ) ;
872
+ peer_state. remove_inbound_channel ( jit_channel_id ) ;
868
873
return Err ( e) ;
869
874
}
870
875
} ;
871
876
872
877
let request_id = self . generate_request_id ( ) ;
873
- peer_state. insert_request ( request_id. clone ( ) , lsps2_id ) ;
878
+ peer_state. insert_request ( request_id. clone ( ) , jit_channel_id ) ;
874
879
875
880
{
876
881
let mut pending_messages = self . pending_messages . lock ( ) . unwrap ( ) ;
@@ -947,7 +952,7 @@ where
947
952
Some ( inner_state_lock) => {
948
953
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
949
954
950
- let lsps2_id =
955
+ let jit_channel_id =
951
956
peer_state. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
952
957
err : format ! (
953
958
"Received get_info response for an unknown request: {:?}" ,
@@ -956,17 +961,19 @@ where
956
961
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
957
962
} ) ?;
958
963
959
- let lsps2 =
960
- peer_state. inbound_channels_by_id . get_mut ( & lsps2_id) . ok_or ( LightningError {
964
+ let jit_channel = peer_state
965
+ . inbound_channels_by_id
966
+ . get_mut ( & jit_channel_id)
967
+ . ok_or ( LightningError {
961
968
err : format ! (
962
969
"Received get_info response for an unknown channel: {:?}" ,
963
- lsps2_id
970
+ jit_channel_id
964
971
) ,
965
972
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
966
973
} ) ?;
967
974
968
- if let Err ( e) = lsps2 . info_received ( ) {
969
- peer_state. remove_inbound_channel ( lsps2_id ) ;
975
+ if let Err ( e) = jit_channel . info_received ( ) {
976
+ peer_state. remove_inbound_channel ( jit_channel_id ) ;
970
977
return Err ( e) ;
971
978
}
972
979
@@ -975,8 +982,8 @@ where
975
982
opening_fee_params_menu : result. opening_fee_params_menu ,
976
983
min_payment_size_msat : result. min_payment_size_msat ,
977
984
max_payment_size_msat : result. max_payment_size_msat ,
978
- lsps2_id : lsps2 . id ,
979
- user_channel_id : lsps2 . config . user_id ,
985
+ jit_channel_id ,
986
+ user_channel_id : jit_channel . config . user_id ,
980
987
} ) ) ;
981
988
}
982
989
None => {
@@ -1001,7 +1008,7 @@ where
1001
1008
Some ( inner_state_lock) => {
1002
1009
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
1003
1010
1004
- let lsps2_id =
1011
+ let jit_channel_id =
1005
1012
peer_state. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
1006
1013
err : format ! (
1007
1014
"Received get_info error for an unknown request: {:?}" ,
@@ -1010,10 +1017,15 @@ where
1010
1017
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
1011
1018
} ) ?;
1012
1019
1013
- peer_state. inbound_channels_by_id . remove ( & lsps2_id) . ok_or ( LightningError {
1014
- err : format ! ( "Received get_info error for an unknown channel: {:?}" , lsps2_id) ,
1015
- action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
1016
- } ) ?;
1020
+ peer_state. inbound_channels_by_id . remove ( & jit_channel_id) . ok_or (
1021
+ LightningError {
1022
+ err : format ! (
1023
+ "Received get_info error for an unknown channel: {:?}" ,
1024
+ jit_channel_id
1025
+ ) ,
1026
+ action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
1027
+ } ,
1028
+ ) ?;
1017
1029
Ok ( ( ) )
1018
1030
}
1019
1031
None => {
@@ -1161,7 +1173,7 @@ where
1161
1173
Some ( inner_state_lock) => {
1162
1174
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
1163
1175
1164
- let lsps2_id =
1176
+ let jit_channel_id =
1165
1177
peer_state. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
1166
1178
err : format ! (
1167
1179
"Received buy response for an unknown request: {:?}" ,
@@ -1170,36 +1182,39 @@ where
1170
1182
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
1171
1183
} ) ?;
1172
1184
1173
- let lsps2 =
1174
- peer_state. inbound_channels_by_id . get_mut ( & lsps2_id) . ok_or ( LightningError {
1185
+ let jit_channel = peer_state
1186
+ . inbound_channels_by_id
1187
+ . get_mut ( & jit_channel_id)
1188
+ . ok_or ( LightningError {
1175
1189
err : format ! (
1176
1190
"Received buy response for an unknown channel: {:?}" ,
1177
- lsps2_id
1191
+ jit_channel_id
1178
1192
) ,
1179
1193
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
1180
1194
} ) ?;
1181
1195
1182
- if let Err ( e) = lsps2
1183
- . invoice_params_received ( result. client_trusts_lsp , result. lsps2_scid . clone ( ) )
1184
- {
1185
- peer_state. remove_inbound_channel ( lsps2_id) ;
1196
+ if let Err ( e) = jit_channel. invoice_params_received (
1197
+ result. client_trusts_lsp ,
1198
+ result. jit_channel_scid . clone ( ) ,
1199
+ ) {
1200
+ peer_state. remove_inbound_channel ( jit_channel_id) ;
1186
1201
return Err ( e) ;
1187
1202
}
1188
1203
1189
- if let Ok ( scid) = result. lsps2_scid . to_scid ( ) {
1204
+ if let Ok ( scid) = result. jit_channel_scid . to_scid ( ) {
1190
1205
self . enqueue_event ( Event :: LSPS2 ( LSPS2Event :: InvoiceGenerationReady {
1191
1206
counterparty_node_id : * counterparty_node_id,
1192
1207
scid,
1193
1208
cltv_expiry_delta : result. lsp_cltv_expiry_delta ,
1194
- payment_size_msat : lsps2 . config . payment_size_msat ,
1209
+ payment_size_msat : jit_channel . config . payment_size_msat ,
1195
1210
client_trusts_lsp : result. client_trusts_lsp ,
1196
- user_channel_id : lsps2 . config . user_id ,
1211
+ user_channel_id : jit_channel . config . user_id ,
1197
1212
} ) ) ;
1198
1213
} else {
1199
1214
return Err ( LightningError {
1200
1215
err : format ! (
1201
1216
"Received buy response with an invalid scid {:?}" ,
1202
- result. lsps2_scid
1217
+ result. jit_channel_scid
1203
1218
) ,
1204
1219
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
1205
1220
} ) ;
@@ -1226,15 +1241,20 @@ where
1226
1241
Some ( inner_state_lock) => {
1227
1242
let mut peer_state = inner_state_lock. lock ( ) . unwrap ( ) ;
1228
1243
1229
- let lsps2_id =
1244
+ let jit_channel_id =
1230
1245
peer_state. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
1231
1246
err : format ! ( "Received buy error for an unknown request: {:?}" , request_id) ,
1232
1247
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
1233
1248
} ) ?;
1234
1249
1235
- let _lsps2 =
1236
- peer_state. inbound_channels_by_id . remove ( & lsps2_id) . ok_or ( LightningError {
1237
- err : format ! ( "Received buy error for an unknown channel: {:?}" , lsps2_id) ,
1250
+ let _jit_channel = peer_state
1251
+ . inbound_channels_by_id
1252
+ . remove ( & jit_channel_id)
1253
+ . ok_or ( LightningError {
1254
+ err : format ! (
1255
+ "Received buy error for an unknown channel: {:?}" ,
1256
+ jit_channel_id
1257
+ ) ,
1238
1258
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
1239
1259
} ) ?;
1240
1260
Ok ( ( ) )
0 commit comments