@@ -2,7 +2,8 @@ use crate::events::{Event, EventQueue};
2
2
use crate :: lsps0:: client:: LSPS0ClientHandler ;
3
3
use crate :: lsps0:: msgs:: LSPS0Message ;
4
4
use crate :: lsps0:: ser:: {
5
- LSPSMessage , LSPSMethod , ProtocolMessageHandler , RawLSPSMessage , RequestId ,
5
+ LSPSMessage , LSPSMethod , ProtocolMessageHandler , RawLSPSMessage , RequestId , ResponseError ,
6
+ JSONRPC_INVALID_MESSAGE_ERROR_CODE , JSONRPC_INVALID_MESSAGE_ERROR_MESSAGE ,
6
7
LSPS_MESSAGE_TYPE_ID ,
7
8
} ;
8
9
use crate :: lsps0:: service:: LSPS0ServiceHandler ;
@@ -18,7 +19,7 @@ use crate::lsps1::service::{LSPS1ServiceConfig, LSPS1ServiceHandler};
18
19
use crate :: lsps2:: client:: { LSPS2ClientConfig , LSPS2ClientHandler } ;
19
20
use crate :: lsps2:: msgs:: LSPS2Message ;
20
21
use crate :: lsps2:: service:: { LSPS2ServiceConfig , LSPS2ServiceHandler } ;
21
- use crate :: prelude:: { HashMap , Vec } ;
22
+ use crate :: prelude:: { HashMap , ToString , Vec } ;
22
23
use crate :: sync:: { Arc , Mutex , RwLock } ;
23
24
24
25
use lightning:: chain:: { self , BestBlock , Confirm , Filter , Listen } ;
@@ -330,7 +331,7 @@ where {
330
331
& self , msg : LSPSMessage , sender_node_id : & PublicKey ,
331
332
) -> Result < ( ) , lightning:: ln:: msgs:: LightningError > {
332
333
match msg {
333
- LSPSMessage :: Invalid => {
334
+ LSPSMessage :: Invalid ( _error ) => {
334
335
return Err ( LightningError { err : format ! ( "{} did not understand a message we previously sent, maybe they don't support a protocol we are trying to use?" , sender_node_id) , action : ErrorAction :: IgnoreAndLog ( Level :: Error ) } ) ;
335
336
}
336
337
LSPSMessage :: LSPS0 ( msg @ LSPS0Message :: Response ( ..) ) => {
@@ -422,7 +423,13 @@ where
422
423
let mut request_id_to_method_map = self . request_id_to_method_map . lock ( ) . unwrap ( ) ;
423
424
LSPSMessage :: from_str_with_id_map ( & msg. payload , & mut request_id_to_method_map) . map_err (
424
425
|_| {
425
- self . pending_messages . enqueue ( sender_node_id, LSPSMessage :: Invalid ) ;
426
+ let error = ResponseError {
427
+ code : JSONRPC_INVALID_MESSAGE_ERROR_CODE ,
428
+ message : JSONRPC_INVALID_MESSAGE_ERROR_MESSAGE . to_string ( ) ,
429
+ data : None ,
430
+ } ;
431
+
432
+ self . pending_messages . enqueue ( sender_node_id, LSPSMessage :: Invalid ( error) ) ;
426
433
let err = format ! ( "Failed to deserialize invalid LSPS message." ) ;
427
434
let err_msg =
428
435
Some ( ErrorMessage { channel_id : ChannelId ( [ 0 ; 32 ] ) , data : err. clone ( ) } ) ;
0 commit comments