From 99828b8ebb72e18be69a7870d5342d20a748412c Mon Sep 17 00:00:00 2001 From: Carla Kirk-Cohen Date: Mon, 16 May 2022 12:19:07 -0400 Subject: [PATCH] multi: add ability to read warning messages and log on link level Warning messages are intended to add "softer" failure modes for peers, so to start with we simply log the warnings sent to us. While we "may" disconnect from the peer according to the spec, we start with the least extreme option (which is also not a change in behavior because previously we'd just log that we received an unknown odd message). --- htlcswitch/link.go | 7 +++++++ peer/brontide.go | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 6c553e31c..7680909e8 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -1996,6 +1996,13 @@ func (l *channelLink) handleUpstreamMsg(msg lnwire.Message) { // Update the mailbox's feerate as well. l.mailBox.SetFeeRate(fee) + // In the case where we receive a warning message from our peer, just + // log it and move on. We choose not to disconnect from our peer, + // although we "MAY" do so according to the specification. + case *lnwire.Warning: + l.log.Warnf("received warning message from peer: %v", + msg.Error.Error()) + case *lnwire.Error: // Error received from remote, MUST fail channel, but should // only print the contents of the error message if all diff --git a/peer/brontide.go b/peer/brontide.go index dd0576fba..83e108903 100644 --- a/peer/brontide.go +++ b/peer/brontide.go @@ -1455,6 +1455,10 @@ out: break out } + case *lnwire.Warning: + targetChan = msg.ChanID + isLinkUpdate = p.handleError(&msg.Error) + case *lnwire.Error: targetChan = msg.ChanID isLinkUpdate = p.handleError(msg) @@ -1688,6 +1692,9 @@ func messageSummary(msg lnwire.Message) string { return fmt.Sprintf("chan_id=%v, id=%v, fail_code=%v", msg.ChanID, msg.ID, msg.FailureCode) + case *lnwire.Warning: + return fmt.Sprintf("%v", msg.Error.Error()) + case *lnwire.Error: return fmt.Sprintf("%v", msg.Error())