@@ -14,9 +14,6 @@ use super::msgs::{LSPS1OrderId, LSPS1OrderParams, LSPS1PaymentInfo, LSPS1Request
1414use crate :: lsps0:: ser:: { LSPSDateTime , LSPSRequestId } ;
1515use crate :: prelude:: HashMap ;
1616
17- use lightning:: ln:: msgs:: { ErrorAction , LightningError } ;
18- use lightning:: util:: logger:: Level ;
19-
2017#[ derive( Default ) ]
2118pub ( super ) struct PeerState {
2219 pub ( super ) outbound_channels_by_order_id : HashMap < LSPS1OrderId , OutboundCRChannel > ,
@@ -31,54 +28,20 @@ impl PeerState {
3128 }
3229}
3330
34- struct ChannelStateError ( String ) ;
35-
36- impl From < ChannelStateError > for LightningError {
37- fn from ( value : ChannelStateError ) -> Self {
38- LightningError { err : value. 0 , action : ErrorAction :: IgnoreAndLog ( Level :: Info ) }
39- }
40- }
41-
42- #[ derive( PartialEq , Debug ) ]
43- pub ( super ) enum OutboundRequestState {
44- OrderCreated { order_id : LSPS1OrderId } ,
45- WaitingPayment { order_id : LSPS1OrderId } ,
46- }
47-
48- impl OutboundRequestState {
49- fn awaiting_payment ( & self ) -> Result < Self , ChannelStateError > {
50- match self {
51- OutboundRequestState :: OrderCreated { order_id } => {
52- Ok ( OutboundRequestState :: WaitingPayment { order_id : order_id. clone ( ) } )
53- } ,
54- state => Err ( ChannelStateError ( format ! ( "TODO. JIT Channel was in state: {:?}" , state) ) ) ,
55- }
56- }
57- }
58-
5931pub ( super ) struct OutboundLSPS1Config {
6032 pub ( super ) order : LSPS1OrderParams ,
6133 pub ( super ) created_at : LSPSDateTime ,
6234 pub ( super ) payment : LSPS1PaymentInfo ,
6335}
6436
6537pub ( super ) struct OutboundCRChannel {
66- pub ( super ) state : OutboundRequestState ,
6738 pub ( super ) config : OutboundLSPS1Config ,
6839}
6940
7041impl OutboundCRChannel {
7142 pub ( super ) fn new (
72- order : LSPS1OrderParams , created_at : LSPSDateTime , order_id : LSPS1OrderId ,
73- payment : LSPS1PaymentInfo ,
43+ order : LSPS1OrderParams , created_at : LSPSDateTime , payment : LSPS1PaymentInfo ,
7444 ) -> Self {
75- Self {
76- state : OutboundRequestState :: OrderCreated { order_id } ,
77- config : OutboundLSPS1Config { order, created_at, payment } ,
78- }
79- }
80- pub ( super ) fn awaiting_payment ( & mut self ) -> Result < ( ) , LightningError > {
81- self . state = self . state . awaiting_payment ( ) ?;
82- Ok ( ( ) )
45+ Self { config : OutboundLSPS1Config { order, created_at, payment } }
8346 }
8447}
0 commit comments