File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,7 @@ pub fn do_test(data: &[u8]) {
249
249
Some ( ErrorAction :: DisconnectPeer { ..} ) => return ,
250
250
Some ( ErrorAction :: IgnoreError ) => None ,
251
251
Some ( ErrorAction :: SendErrorMessage { ..} ) => None ,
252
+ Some ( ErrorAction :: KeyError ) => None ,
252
253
} ,
253
254
}
254
255
}
Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ macro_rules! secp_call {
175
175
match $res {
176
176
Ok ( key) => key,
177
177
//TODO: Make the err a parameter!
178
- Err ( _) => return Err ( HandleError { err: "Key error" , action: None } )
178
+ Err ( _) => return Err ( HandleError { err: "Key error" , action: Some ( msgs :: ErrorAction :: KeyError ) } ) ,
179
179
}
180
180
} ;
181
181
}
@@ -1145,9 +1145,18 @@ impl ChainListener for ChannelManager {
1145
1145
if let Ok ( Some ( funding_locked) ) = chan_res {
1146
1146
let announcement_sigs = match self . get_announcement_sigs ( channel) {
1147
1147
Ok ( res) => res,
1148
- Err ( _e) => {
1149
- //TODO: push e on events and blow up the channel (it has bad keys)
1150
- return true ;
1148
+ Err ( e) => {
1149
+ if e. action . is_some ( ) {
1150
+ new_events. push ( events:: Event :: DisconnectPeer {
1151
+ node_id : channel. get_their_node_id ( ) ,
1152
+ msg : None ,
1153
+ } ) ;
1154
+ failed_channels. push ( channel. force_shutdown ( ) ) ;
1155
+ short_to_id. remove ( & channel. get_short_channel_id ( ) . unwrap ( ) ) ;
1156
+ return false ;
1157
+ } else {
1158
+ return true ;
1159
+ }
1151
1160
}
1152
1161
} ;
1153
1162
new_events. push ( events:: Event :: SendFundingLocked {
@@ -3106,4 +3115,5 @@ mod tests {
3106
3115
assert_eq ! ( channel_state. by_id. len( ) , 0 ) ;
3107
3116
assert_eq ! ( channel_state. short_to_id. len( ) , 0 ) ;
3108
3117
}
3118
+
3109
3119
}
Original file line number Diff line number Diff line change @@ -391,6 +391,8 @@ pub enum ErrorAction {
391
391
SendErrorMessage {
392
392
msg : ErrorMessage
393
393
} ,
394
+ /// The peer send us invalid keys for a given action. Disconnect them or tell them. Your call.
395
+ KeyError ,
394
396
}
395
397
396
398
pub struct HandleError { //TODO: rename me
Original file line number Diff line number Diff line change @@ -312,6 +312,9 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
312
312
encode_and_send_msg!( msg, 17 ) ;
313
313
continue ;
314
314
} ,
315
+ msgs:: ErrorAction :: KeyError => {
316
+ continue ; //TODO : return a PeerHandleError and disconnect socket ?
317
+ }
315
318
}
316
319
} else {
317
320
return Err ( PeerHandleError { no_connection_possible: false } ) ;
You can’t perform that action at this time.
0 commit comments