@@ -53,6 +53,8 @@ pub const LSPS5_UNKNOWN_ERROR_CODE: i32 = 1000;
5353pub const LSPS5_SERIALIZATION_ERROR_CODE : i32 = 1001 ;
5454/// A notification was sent too frequently.
5555pub const LSPS5_SLOW_DOWN_ERROR_CODE : i32 = 1002 ;
56+ /// A request was rejected because the client has no prior activity with the LSP (no open channel and no active LSPS1 or LSPS2 flow). The client should first open a channel
57+ pub const LSPS5_NO_PRIOR_ACTIVITY_ERROR_CODE : i32 = 1003 ;
5658
5759pub ( crate ) const LSPS5_SET_WEBHOOK_METHOD_NAME : & str = "lsps5.set_webhook" ;
5860pub ( crate ) const LSPS5_LIST_WEBHOOKS_METHOD_NAME : & str = "lsps5.list_webhooks" ;
@@ -113,6 +115,10 @@ pub enum LSPS5ProtocolError {
113115 ///
114116 /// [`NOTIFICATION_COOLDOWN_TIME`]: super::service::NOTIFICATION_COOLDOWN_TIME
115117 SlowDownError ,
118+
119+ /// Request rejected because the client has no prior activity with the LSP (no open channel and no active LSPS1 or LSPS2 flow). The client should first open a channel
120+ /// or initiate an LSPS1/LSPS2 interaction before retrying.
121+ NoPriorActivityError ,
116122}
117123
118124impl LSPS5ProtocolError {
@@ -129,6 +135,7 @@ impl LSPS5ProtocolError {
129135 LSPS5ProtocolError :: UnknownError => LSPS5_UNKNOWN_ERROR_CODE ,
130136 LSPS5ProtocolError :: SerializationError => LSPS5_SERIALIZATION_ERROR_CODE ,
131137 LSPS5ProtocolError :: SlowDownError => LSPS5_SLOW_DOWN_ERROR_CODE ,
138+ LSPS5ProtocolError :: NoPriorActivityError => LSPS5_NO_PRIOR_ACTIVITY_ERROR_CODE ,
132139 }
133140 }
134141 /// The error message for the LSPS5 protocol error.
@@ -145,6 +152,9 @@ impl LSPS5ProtocolError {
145152 "Error serializing LSPS5 webhook notification"
146153 } ,
147154 LSPS5ProtocolError :: SlowDownError => "Notification sent too frequently" ,
155+ LSPS5ProtocolError :: NoPriorActivityError => {
156+ "Request rejected due to no prior activity with the LSP"
157+ } ,
148158 }
149159 }
150160}
@@ -249,6 +259,9 @@ impl From<LSPSResponseError> for LSPS5ProtocolError {
249259 LSPS5_UNSUPPORTED_PROTOCOL_ERROR_CODE => LSPS5ProtocolError :: UnsupportedProtocol ,
250260 LSPS5_TOO_MANY_WEBHOOKS_ERROR_CODE => LSPS5ProtocolError :: TooManyWebhooks ,
251261 LSPS5_APP_NAME_NOT_FOUND_ERROR_CODE => LSPS5ProtocolError :: AppNameNotFound ,
262+ LSPS5_SERIALIZATION_ERROR_CODE => LSPS5ProtocolError :: SerializationError ,
263+ LSPS5_SLOW_DOWN_ERROR_CODE => LSPS5ProtocolError :: SlowDownError ,
264+ LSPS5_NO_PRIOR_ACTIVITY_ERROR_CODE => LSPS5ProtocolError :: NoPriorActivityError ,
252265 _ => LSPS5ProtocolError :: UnknownError ,
253266 }
254267 }
@@ -640,6 +653,12 @@ pub enum LSPS5Request {
640653 RemoveWebhook ( RemoveWebhookRequest ) ,
641654}
642655
656+ impl LSPS5Request {
657+ pub ( crate ) fn is_state_allocating ( & self ) -> bool {
658+ matches ! ( self , LSPS5Request :: SetWebhook ( _) )
659+ }
660+ }
661+
643662/// An LSPS5 protocol response.
644663#[ derive( Clone , Debug , PartialEq , Eq ) ]
645664pub enum LSPS5Response {
0 commit comments