@@ -30,17 +30,13 @@ use crate::prelude::{new_hash_map, HashMap};
3030use crate :: sync:: { Arc , Mutex , RwLock } ;
3131use crate :: utils;
3232
33- use lightning:: chain:: Filter ;
34- use lightning:: ln:: channelmanager:: AChannelManager ;
3533use lightning:: ln:: msgs:: { ErrorAction , LightningError } ;
3634use lightning:: sign:: EntropySource ;
3735use lightning:: util:: errors:: APIError ;
3836use lightning:: util:: logger:: Level ;
3937
4038use bitcoin:: secp256k1:: PublicKey ;
4139
42- use chrono:: Utc ;
43-
4440/// Server-side configuration options for bLIP-51 / LSPS1 channel requests.
4541#[ derive( Clone , Debug ) ]
4642pub struct LSPS1ServiceConfig {
@@ -62,7 +58,6 @@ impl From<ChannelStateError> for LightningError {
6258enum OutboundRequestState {
6359 OrderCreated { order_id : LSPS1OrderId } ,
6460 WaitingPayment { order_id : LSPS1OrderId } ,
65- Ready ,
6661}
6762
6863impl OutboundRequestState {
@@ -101,67 +96,43 @@ impl OutboundCRChannel {
10196 self . state = self . state . awaiting_payment ( ) ?;
10297 Ok ( ( ) )
10398 }
104-
105- fn check_order_validity ( & self , supported_options : & LSPS1Options ) -> bool {
106- let order = & self . config . order ;
107-
108- is_valid ( order, supported_options)
109- }
11099}
111100
112101#[ derive( Default ) ]
113102struct PeerState {
114103 outbound_channels_by_order_id : HashMap < LSPS1OrderId , OutboundCRChannel > ,
115- request_to_cid : HashMap < LSPSRequestId , u128 > ,
116104 pending_requests : HashMap < LSPSRequestId , LSPS1Request > ,
117105}
118106
119107impl PeerState {
120108 fn insert_outbound_channel ( & mut self , order_id : LSPS1OrderId , channel : OutboundCRChannel ) {
121109 self . outbound_channels_by_order_id . insert ( order_id, channel) ;
122110 }
123-
124- fn insert_request ( & mut self , request_id : LSPSRequestId , channel_id : u128 ) {
125- self . request_to_cid . insert ( request_id, channel_id) ;
126- }
127-
128- fn remove_outbound_channel ( & mut self , order_id : LSPS1OrderId ) {
129- self . outbound_channels_by_order_id . remove ( & order_id) ;
130- }
131111}
132112
133113/// The main object allowing to send and receive bLIP-51 / LSPS1 messages.
134- pub struct LSPS1ServiceHandler < ES : Deref , CM : Deref + Clone , C : Deref >
114+ pub struct LSPS1ServiceHandler < ES : Deref >
135115where
136116 ES :: Target : EntropySource ,
137- CM :: Target : AChannelManager ,
138- C :: Target : Filter ,
139117{
140118 entropy_source : ES ,
141- channel_manager : CM ,
142- chain_source : Option < C > ,
143119 pending_messages : Arc < MessageQueue > ,
144120 pending_events : Arc < EventQueue > ,
145121 per_peer_state : RwLock < HashMap < PublicKey , Mutex < PeerState > > > ,
146122 config : LSPS1ServiceConfig ,
147123}
148124
149- impl < ES : Deref , CM : Deref + Clone , C : Deref > LSPS1ServiceHandler < ES , CM , C >
125+ impl < ES : Deref > LSPS1ServiceHandler < ES >
150126where
151127 ES :: Target : EntropySource ,
152- CM :: Target : AChannelManager ,
153- C :: Target : Filter ,
154- ES :: Target : EntropySource ,
155128{
156129 /// Constructs a `LSPS1ServiceHandler`.
157130 pub ( crate ) fn new (
158131 entropy_source : ES , pending_messages : Arc < MessageQueue > , pending_events : Arc < EventQueue > ,
159- channel_manager : CM , chain_source : Option < C > , config : LSPS1ServiceConfig ,
132+ config : LSPS1ServiceConfig ,
160133 ) -> Self {
161134 Self {
162135 entropy_source,
163- channel_manager,
164- chain_source,
165136 pending_messages,
166137 pending_events,
167138 per_peer_state : RwLock :: new ( new_hash_map ( ) ) ,
@@ -432,12 +403,9 @@ where
432403 }
433404}
434405
435- impl < ES : Deref , CM : Deref + Clone , C : Deref > LSPSProtocolMessageHandler
436- for LSPS1ServiceHandler < ES , CM , C >
406+ impl < ES : Deref > LSPSProtocolMessageHandler for LSPS1ServiceHandler < ES >
437407where
438408 ES :: Target : EntropySource ,
439- CM :: Target : AChannelManager ,
440- C :: Target : Filter ,
441409{
442410 type ProtocolMessage = LSPS1Message ;
443411 const PROTOCOL_NUMBER : Option < u16 > = Some ( 1 ) ;
0 commit comments