Skip to content

Commit b149279

Browse files
committed
Send warning messages when repeating shutdown messages at volume
1 parent bb7c4d1 commit b149279

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

lightning/src/events/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,7 @@ impl MaybeReadable for Event {
15011501
/// broadcast to most peers).
15021502
/// These events are handled by PeerManager::process_events if you are using a PeerManager.
15031503
#[derive(Clone, Debug)]
1504+
#[cfg_attr(test, derive(PartialEq))]
15041505
pub enum MessageSendEvent {
15051506
/// Used to indicate that we've accepted a channel open and should send the accept_channel
15061507
/// message provided to the given peer.

lightning/src/ln/channelmanager.rs

+10
Original file line numberDiff line numberDiff line change
@@ -7512,6 +7512,16 @@ where
75127512
msg,
75137513
});
75147514
}
7515+
peer_state.pending_msg_events.push(events::MessageSendEvent::HandleError {
7516+
node_id: *counterparty_node_id,
7517+
action: msgs::ErrorAction::SendWarningMessage {
7518+
msg: msgs::WarningMessage {
7519+
channel_id: msg.channel_id,
7520+
data: "You appear to be exhibiting LND bug 6039, we'll keep sending you shutdown messages until you handle them correctly".to_owned()
7521+
},
7522+
log_level: Level::Trace,
7523+
}
7524+
});
75157525
}
75167526
}
75177527
return;

lightning/src/ln/msgs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ enum EncodingType {
11441144
}
11451145

11461146
/// Used to put an error message in a [`LightningError`].
1147-
#[derive(Clone, Debug)]
1147+
#[derive(Clone, Debug, PartialEq)]
11481148
pub enum ErrorAction {
11491149
/// The peer took some action which made us think they were useless. Disconnect them.
11501150
DisconnectPeer {

lightning/src/ln/shutdown_tests.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ fn test_lnd_bug_6039() {
219219
// see if LND will accept our protocol compliance.
220220
let err_msg = msgs::ErrorMessage { channel_id: chan.2, data: "link failed to shutdown".to_string() };
221221
nodes[0].node.handle_error(&nodes[1].node.get_our_node_id(), &err_msg);
222-
let _node_0_repeated_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
222+
let node_a_responses = nodes[0].node.get_and_clear_pending_msg_events();
223+
assert_eq!(node_a_responses[0], MessageSendEvent::SendShutdown {
224+
node_id: nodes[1].node.get_our_node_id(),
225+
msg: node_0_shutdown,
226+
});
227+
if let MessageSendEvent::HandleError { action: msgs::ErrorAction::SendWarningMessage { .. }, .. }
228+
= node_a_responses[1] {} else { panic!(); }
223229

224230
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
225231

0 commit comments

Comments
 (0)