htlcswitch: ensure onion related errors always have the BadOnion bit set

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.
This commit is contained in:
Olaoluwa Osuntokun
2018-01-08 17:50:19 -08:00
parent b11461fba7
commit e54e88ee2f

View File

@@ -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
}
}