From e54e88ee2f46a909ba3a945a486621a499b11aca Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 8 Jan 2018 17:50:19 -0800 Subject: [PATCH] htlcswitch: ensure onion related errors always have the BadOnion bit set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we fix a lingering protocol level bug when reporting errors encountered during onion blob processing. The spec states that if one sends an UpdateFailMalformedHtlc, then the error reason MUST have the BadOnion bit set. Before this commit, we would return CodeTemporaryChannelFailure. This is incorrect as this doesn’t have the BadOnio bit set. --- htlcswitch/iterator.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htlcswitch/iterator.go b/htlcswitch/iterator.go index bb589a8d..46f57605 100644 --- a/htlcswitch/iterator.go +++ b/htlcswitch/iterator.go @@ -170,7 +170,7 @@ func (p *OnionProcessor) DecodeHopIterator(r io.Reader, rHash []byte) (HopIterat return nil, lnwire.CodeInvalidOnionKey default: log.Errorf("unable to decode onion packet: %v", err) - return nil, lnwire.CodeTemporaryChannelFailure + return nil, lnwire.CodeInvalidOnionKey } } @@ -190,7 +190,7 @@ func (p *OnionProcessor) DecodeHopIterator(r io.Reader, rHash []byte) (HopIterat return nil, lnwire.CodeInvalidOnionKey default: log.Errorf("unable to process onion packet: %v", err) - return nil, lnwire.CodeTemporaryChannelFailure + return nil, lnwire.CodeInvalidOnionKey } } @@ -216,7 +216,7 @@ func (p *OnionProcessor) ExtractErrorEncrypter(r io.Reader) (ErrorEncrypter, lnw return nil, lnwire.CodeInvalidOnionKey default: log.Errorf("unable to decode onion packet: %v", err) - return nil, lnwire.CodeTemporaryChannelFailure + return nil, lnwire.CodeInvalidOnionKey } } @@ -232,7 +232,7 @@ func (p *OnionProcessor) ExtractErrorEncrypter(r io.Reader) (ErrorEncrypter, lnw return nil, lnwire.CodeInvalidOnionKey default: log.Errorf("unable to process onion packet: %v", err) - return nil, lnwire.CodeTemporaryChannelFailure + return nil, lnwire.CodeInvalidOnionKey } }