htlcswitch: do not consider unknown failures an error

This commit is contained in:
Joost Jager
2019-06-19 15:09:23 +02:00
parent c6f9517e48
commit 2726f50d7c
7 changed files with 186 additions and 112 deletions

View File

@@ -31,10 +31,10 @@ type ForwardingError struct {
// returned.
func (f *ForwardingError) Error() string {
if f.ExtraMsg == "" {
return f.FailureMessage.Error()
return fmt.Sprintf("%v", f.FailureMessage)
}
return fmt.Sprintf("%v: %v", f.FailureMessage.Error(), f.ExtraMsg)
return fmt.Sprintf("%v: %v", f.FailureMessage, f.ExtraMsg)
}
// ErrorDecrypter is an interface that is used to decrypt the onion encrypted
@@ -274,10 +274,14 @@ func (s *SphinxErrorDecrypter) DecryptError(reason lnwire.OpaqueReason) (
return nil, err
}
// Decode the failure. If an error occurs, we leave the failure message
// field nil.
r := bytes.NewReader(failure.Message)
failureMsg, err := lnwire.DecodeFailure(r, 0)
if err != nil {
return nil, err
return &ForwardingError{
FailureSourceIdx: failure.SenderIdx,
}, nil
}
return &ForwardingError{