From cac779b69ecf70b7d1ad1e50ef5f90d7333d188a Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 26 Feb 2024 17:16:01 -0800 Subject: [PATCH] funding: send warning to remote peer if chan nonce missing on reest --- funding/manager.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/funding/manager.go b/funding/manager.go index 78cf19559..5196090b7 100644 --- a/funding/manager.go +++ b/funding/manager.go @@ -960,6 +960,28 @@ func (f *Manager) failFundingFlow(peer lnpeer.Peer, cid *chanIdentifier, } } +// sendWarning sends a new warning message to the target peer, targeting the +// specified cid with the passed funding error. +func (f *Manager) sendWarning(peer lnpeer.Peer, cid *chanIdentifier, + fundingErr error) { + + msg := fundingErr.Error() + + errMsg := &lnwire.Warning{ + ChanID: cid.tempChanID, + Data: lnwire.WarningData(msg), + } + + log.Debugf("Sending funding warning to peer (%x): %v", + peer.IdentityKey().SerializeCompressed(), + spew.Sdump(errMsg), + ) + + if err := peer.SendMessage(false, errMsg); err != nil { + log.Errorf("unable to send error message to peer %v", err) + } +} + // reservationCoordinator is the primary goroutine tasked with progressing the // funding workflow between the wallet, and any outside peers or local callers. // @@ -3890,7 +3912,7 @@ func (f *Manager) handleChannelReady(peer lnpeer.Peer, //nolint:funlen ) if err != nil { cid := newChanIdentifier(msg.ChanID) - f.failFundingFlow(peer, cid, err) + f.sendWarning(peer, cid, err) return }