@@ -56,7 +56,7 @@ enum InboundRequestState {
56
56
OptionsSupport { options_supported : OptionsSupported } ,
57
57
OrderRequested { order : OrderParams } ,
58
58
PendingPayment { order_id : OrderId } ,
59
- AwaitingConfirmation { id : u128 , order_id : OrderId } ,
59
+ AwaitingConfirmation { user_channel_id : u128 , order_id : OrderId } ,
60
60
}
61
61
62
62
impl InboundRequestState {
@@ -112,11 +112,11 @@ impl InboundRequestState {
112
112
}
113
113
}
114
114
115
- fn pay_for_channel ( & self , channel_id : u128 ) -> Result < Self , ChannelStateError > {
115
+ fn pay_for_channel ( & self , user_channel_id : u128 ) -> Result < Self , ChannelStateError > {
116
116
match self {
117
117
InboundRequestState :: PendingPayment { order_id } => {
118
118
Ok ( InboundRequestState :: AwaitingConfirmation {
119
- id : channel_id ,
119
+ user_channel_id ,
120
120
order_id : order_id. clone ( ) ,
121
121
} )
122
122
}
@@ -129,13 +129,13 @@ impl InboundRequestState {
129
129
}
130
130
131
131
struct InboundCRChannel {
132
- id : u128 ,
132
+ user_channel_id : u128 ,
133
133
state : InboundRequestState ,
134
134
}
135
135
136
136
impl InboundCRChannel {
137
- fn new ( id : u128 ) -> Self {
138
- Self { id , state : InboundRequestState :: InfoRequested }
137
+ fn new ( user_channel_id : u128 ) -> Self {
138
+ Self { user_channel_id , state : InboundRequestState :: InfoRequested }
139
139
}
140
140
141
141
fn info_received ( & mut self , options : OptionsSupported ) -> Result < ( ) , LightningError > {
@@ -171,8 +171,8 @@ impl InboundCRChannel {
171
171
Ok ( ( ) )
172
172
}
173
173
174
- fn pay_for_channel ( & mut self , channel_id : u128 ) -> Result < ( ) , LightningError > {
175
- self . state = self . state . pay_for_channel ( channel_id ) ?;
174
+ fn pay_for_channel ( & mut self , user_channel_id : u128 ) -> Result < ( ) , LightningError > {
175
+ self . state = self . state . pay_for_channel ( user_channel_id ) ?;
176
176
Ok ( ( ) )
177
177
}
178
178
}
@@ -185,16 +185,16 @@ struct PeerState {
185
185
}
186
186
187
187
impl PeerState {
188
- fn insert_inbound_channel ( & mut self , id : u128 , channel : InboundCRChannel ) {
189
- self . inbound_channels_by_id . insert ( id , channel) ;
188
+ fn insert_inbound_channel ( & mut self , user_channel_id : u128 , channel : InboundCRChannel ) {
189
+ self . inbound_channels_by_id . insert ( user_channel_id , channel) ;
190
190
}
191
191
192
- fn insert_request ( & mut self , request_id : RequestId , channel_id : u128 ) {
193
- self . request_to_cid . insert ( request_id, channel_id ) ;
192
+ fn insert_request ( & mut self , request_id : RequestId , user_channel_id : u128 ) {
193
+ self . request_to_cid . insert ( request_id, user_channel_id ) ;
194
194
}
195
195
196
- fn remove_inbound_channel ( & mut self , id : u128 ) {
197
- self . inbound_channels_by_id . remove ( & id ) ;
196
+ fn remove_inbound_channel ( & mut self , user_channel_id : u128 ) {
197
+ self . inbound_channels_by_id . remove ( & user_channel_id ) ;
198
198
}
199
199
}
200
200
@@ -241,19 +241,19 @@ where
241
241
///
242
242
/// `counterparty_node_id` is the node_id of the LSP you would like to use.
243
243
///
244
- /// 'channel_id' is the id used to uniquely identify the channel with counterparty node.
245
- pub fn request_for_info ( & self , counterparty_node_id : PublicKey , channel_id : u128 ) {
246
- let channel = InboundCRChannel :: new ( channel_id ) ;
244
+ /// `user_channel_id` is the id used to uniquely identify the channel with counterparty node.
245
+ pub fn send_get_info_request ( & self , counterparty_node_id : PublicKey , user_channel_id : u128 ) {
246
+ let channel = InboundCRChannel :: new ( user_channel_id ) ;
247
247
248
248
let mut outer_state_lock = self . per_peer_state . write ( ) . unwrap ( ) ;
249
249
let inner_state_lock = outer_state_lock
250
250
. entry ( counterparty_node_id)
251
251
. or_insert ( Mutex :: new ( PeerState :: default ( ) ) ) ;
252
252
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
253
- peer_state_lock. insert_inbound_channel ( channel_id , channel) ;
253
+ peer_state_lock. insert_inbound_channel ( user_channel_id , channel) ;
254
254
255
255
let request_id = crate :: utils:: generate_request_id ( & self . entropy_source ) ;
256
- peer_state_lock. insert_request ( request_id. clone ( ) , channel_id ) ;
256
+ peer_state_lock. insert_request ( request_id. clone ( ) , user_channel_id ) ;
257
257
258
258
self . pending_messages . enqueue (
259
259
& counterparty_node_id,
@@ -270,7 +270,7 @@ where
270
270
Some ( inner_state_lock) => {
271
271
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
272
272
273
- let channel_id =
273
+ let user_channel_id =
274
274
peer_state_lock. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
275
275
err : format ! (
276
276
"Received get_info response for an unknown request: {:?}" ,
@@ -281,26 +281,25 @@ where
281
281
282
282
let inbound_channel = peer_state_lock
283
283
. inbound_channels_by_id
284
- . get_mut ( & channel_id )
284
+ . get_mut ( & user_channel_id )
285
285
. ok_or ( LightningError {
286
- err : format ! (
287
- "Received get_info response for an unknown channel: {:?}" ,
288
- channel_id
289
- ) ,
290
- action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
291
- } ) ?;
286
+ err : format ! (
287
+ "Received get_info response for an unknown channel: {:?}" ,
288
+ user_channel_id
289
+ ) ,
290
+ action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
291
+ } ) ?;
292
292
293
293
match inbound_channel. info_received ( result. options . clone ( ) ) {
294
294
Ok ( ( ) ) => ( ) ,
295
295
Err ( e) => {
296
- peer_state_lock. remove_inbound_channel ( channel_id ) ;
296
+ peer_state_lock. remove_inbound_channel ( user_channel_id ) ;
297
297
return Err ( e) ;
298
298
}
299
299
} ;
300
300
301
301
self . pending_events . enqueue ( Event :: LSPS1Client ( LSPS1ClientEvent :: GetInfoResponse {
302
- id : channel_id,
303
- request_id,
302
+ user_channel_id,
304
303
counterparty_node_id : * counterparty_node_id,
305
304
website : result. website ,
306
305
options_supported : result. options ,
@@ -326,7 +325,7 @@ where
326
325
///
327
326
/// [`LSPS1ClientEvent::GetInfoResponse`]: crate::lsps1::event::LSPS1ClientEvent::GetInfoResponse
328
327
pub fn place_order (
329
- & self , channel_id : u128 , counterparty_node_id : & PublicKey , order : OrderParams ,
328
+ & self , user_channel_id : u128 , counterparty_node_id : & PublicKey , order : OrderParams ,
330
329
) -> Result < ( ) , APIError > {
331
330
let outer_state_lock = self . per_peer_state . write ( ) . unwrap ( ) ;
332
331
@@ -336,21 +335,21 @@ where
336
335
337
336
let inbound_channel = peer_state_lock
338
337
. inbound_channels_by_id
339
- . get_mut ( & channel_id )
338
+ . get_mut ( & user_channel_id )
340
339
. ok_or ( APIError :: APIMisuseError {
341
- err : format ! ( "Channel with id {} not found" , channel_id ) ,
342
- } ) ?;
340
+ err : format ! ( "Channel with user_channel_id {} not found" , user_channel_id ) ,
341
+ } ) ?;
343
342
344
343
match inbound_channel. order_requested ( order. clone ( ) ) {
345
344
Ok ( ( ) ) => ( ) ,
346
345
Err ( e) => {
347
- peer_state_lock. remove_inbound_channel ( channel_id ) ;
346
+ peer_state_lock. remove_inbound_channel ( user_channel_id ) ;
348
347
return Err ( APIError :: APIMisuseError { err : e. err } ) ;
349
348
}
350
349
} ;
351
350
352
351
let request_id = crate :: utils:: generate_request_id ( & self . entropy_source ) ;
353
- peer_state_lock. insert_request ( request_id. clone ( ) , channel_id ) ;
352
+ peer_state_lock. insert_request ( request_id. clone ( ) , user_channel_id ) ;
354
353
355
354
self . pending_messages . enqueue (
356
355
counterparty_node_id,
@@ -379,7 +378,7 @@ where
379
378
Some ( inner_state_lock) => {
380
379
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
381
380
382
- let channel_id =
381
+ let user_channel_id =
383
382
peer_state_lock. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
384
383
err : format ! (
385
384
"Received create_order response for an unknown request: {:?}" ,
@@ -390,19 +389,19 @@ where
390
389
391
390
let inbound_channel = peer_state_lock
392
391
. inbound_channels_by_id
393
- . get_mut ( & channel_id )
392
+ . get_mut ( & user_channel_id )
394
393
. ok_or ( LightningError {
395
- err : format ! (
396
- "Received create_order response for an unknown channel: {:?}" ,
397
- channel_id
398
- ) ,
399
- action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
400
- } ) ?;
394
+ err : format ! (
395
+ "Received create_order response for an unknown channel: {:?}" ,
396
+ user_channel_id
397
+ ) ,
398
+ action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
399
+ } ) ?;
401
400
402
401
if let Err ( e) =
403
402
inbound_channel. order_received ( & response. order , response. order_id . clone ( ) )
404
403
{
405
- peer_state_lock. remove_inbound_channel ( channel_id ) ;
404
+ peer_state_lock. remove_inbound_channel ( user_channel_id ) ;
406
405
return Err ( e) ;
407
406
}
408
407
@@ -414,15 +413,15 @@ where
414
413
{
415
414
self . pending_events . enqueue ( Event :: LSPS1Client (
416
415
LSPS1ClientEvent :: DisplayOrder {
417
- id : channel_id ,
416
+ user_channel_id ,
418
417
counterparty_node_id : * counterparty_node_id,
419
418
order : response. order ,
420
419
payment : response. payment ,
421
420
channel : response. channel ,
422
421
} ,
423
422
) ) ;
424
423
} else {
425
- peer_state_lock. remove_inbound_channel ( channel_id ) ;
424
+ peer_state_lock. remove_inbound_channel ( user_channel_id ) ;
426
425
return Err ( LightningError {
427
426
err : format ! ( "Fees are too high : {:?}" , total_fees) ,
428
427
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
@@ -451,7 +450,7 @@ where
451
450
Some ( inner_state_lock) => {
452
451
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
453
452
454
- let channel_id =
453
+ let user_channel_id =
455
454
peer_state_lock. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
456
455
err : format ! (
457
456
"Received create order error for an unknown request: {:?}" ,
@@ -462,14 +461,14 @@ where
462
461
463
462
let inbound_channel = peer_state_lock
464
463
. inbound_channels_by_id
465
- . get_mut ( & channel_id )
464
+ . get_mut ( & user_channel_id )
466
465
. ok_or ( LightningError {
467
- err : format ! (
468
- "Received create order error for an unknown channel: {:?}" ,
469
- channel_id
470
- ) ,
471
- action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
472
- } ) ?;
466
+ err : format ! (
467
+ "Received create order error for an unknown channel: {:?}" ,
468
+ user_channel_id
469
+ ) ,
470
+ action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
471
+ } ) ?;
473
472
Ok ( ( ) )
474
473
}
475
474
None => {
@@ -484,23 +483,23 @@ where
484
483
///
485
484
/// [`LSPS1ClientEvent::DisplayOrder`]: crate::lsps1::event::LSPS1ClientEvent::DisplayOrder
486
485
pub fn check_order_status (
487
- & self , counterparty_node_id : & PublicKey , order_id : OrderId , channel_id : u128 ,
486
+ & self , counterparty_node_id : & PublicKey , order_id : OrderId , user_channel_id : u128 ,
488
487
) -> Result < ( ) , APIError > {
489
488
let outer_state_lock = self . per_peer_state . write ( ) . unwrap ( ) ;
490
489
match outer_state_lock. get ( & counterparty_node_id) {
491
490
Some ( inner_state_lock) => {
492
491
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
493
492
494
493
if let Some ( inbound_channel) =
495
- peer_state_lock. inbound_channels_by_id . get_mut ( & channel_id )
494
+ peer_state_lock. inbound_channels_by_id . get_mut ( & user_channel_id )
496
495
{
497
- if let Err ( e) = inbound_channel. pay_for_channel ( channel_id ) {
498
- peer_state_lock. remove_inbound_channel ( channel_id ) ;
496
+ if let Err ( e) = inbound_channel. pay_for_channel ( user_channel_id ) {
497
+ peer_state_lock. remove_inbound_channel ( user_channel_id ) ;
499
498
return Err ( APIError :: APIMisuseError { err : e. err } ) ;
500
499
}
501
500
502
501
let request_id = crate :: utils:: generate_request_id ( & self . entropy_source ) ;
503
- peer_state_lock. insert_request ( request_id. clone ( ) , channel_id ) ;
502
+ peer_state_lock. insert_request ( request_id. clone ( ) , user_channel_id ) ;
504
503
505
504
self . pending_messages . enqueue (
506
505
counterparty_node_id,
@@ -512,7 +511,7 @@ where
512
511
) ;
513
512
} else {
514
513
return Err ( APIError :: APIMisuseError {
515
- err : format ! ( "Channel with id {} not found" , channel_id ) ,
514
+ err : format ! ( "Channel with user_channel_id {} not found" , user_channel_id ) ,
516
515
} ) ;
517
516
}
518
517
}
@@ -534,7 +533,7 @@ where
534
533
Some ( inner_state_lock) => {
535
534
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
536
535
537
- let channel_id =
536
+ let user_channel_id =
538
537
peer_state_lock. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
539
538
err : format ! (
540
539
"Received get_order response for an unknown request: {:?}" ,
@@ -545,14 +544,14 @@ where
545
544
546
545
let inbound_channel = peer_state_lock
547
546
. inbound_channels_by_id
548
- . get_mut ( & channel_id )
547
+ . get_mut ( & user_channel_id )
549
548
. ok_or ( LightningError {
550
- err : format ! (
551
- "Received get_order response for an unknown channel: {:?}" ,
552
- channel_id
553
- ) ,
554
- action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
555
- } ) ?;
549
+ err : format ! (
550
+ "Received get_order response for an unknown channel: {:?}" ,
551
+ user_channel_id
552
+ ) ,
553
+ action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
554
+ } ) ?;
556
555
}
557
556
None => {
558
557
return Err ( LightningError {
@@ -576,7 +575,7 @@ where
576
575
Some ( inner_state_lock) => {
577
576
let mut peer_state_lock = inner_state_lock. lock ( ) . unwrap ( ) ;
578
577
579
- let channel_id =
578
+ let user_channel_id =
580
579
peer_state_lock. request_to_cid . remove ( & request_id) . ok_or ( LightningError {
581
580
err : format ! (
582
581
"Received get_order error for an unknown request: {:?}" ,
@@ -587,11 +586,11 @@ where
587
586
588
587
let _inbound_channel = peer_state_lock
589
588
. inbound_channels_by_id
590
- . get_mut ( & channel_id )
589
+ . get_mut ( & user_channel_id )
591
590
. ok_or ( LightningError {
592
591
err : format ! (
593
592
"Received get_order error for an unknown channel: {:?}" ,
594
- channel_id
593
+ user_channel_id
595
594
) ,
596
595
action : ErrorAction :: IgnoreAndLog ( Level :: Info ) ,
597
596
} ) ?;
0 commit comments