lnwire: add FailMPPTimeout message
This commit is contained in:
parent
d2e395d5f2
commit
1d3bb5aed6
@ -80,6 +80,7 @@ const (
|
||||
CodeFinalIncorrectHtlcAmount FailCode = 19
|
||||
CodeExpiryTooFar FailCode = 21
|
||||
CodeInvalidOnionPayload = FlagPerm | 22
|
||||
CodeMPPTimeout FailCode = 23
|
||||
)
|
||||
|
||||
// String returns the string representation of the failure code.
|
||||
@ -154,6 +155,9 @@ func (c FailCode) String() string {
|
||||
case CodeInvalidOnionPayload:
|
||||
return "InvalidOnionPayload"
|
||||
|
||||
case CodeMPPTimeout:
|
||||
return "MPPTimeout"
|
||||
|
||||
default:
|
||||
return "<unknown>"
|
||||
}
|
||||
@ -1182,6 +1186,26 @@ func (f *InvalidOnionPayload) Encode(w io.Writer, pver uint32) error {
|
||||
return WriteElements(w, f.Offset)
|
||||
}
|
||||
|
||||
// FailMPPTimeout is returned if the complete amount for a multi part payment
|
||||
// was not received within a reasonable time.
|
||||
//
|
||||
// NOTE: May only be returned by the final node in the path.
|
||||
type FailMPPTimeout struct{}
|
||||
|
||||
// Code returns the failure unique code.
|
||||
//
|
||||
// NOTE: Part of the FailureMessage interface.
|
||||
func (f *FailMPPTimeout) Code() FailCode {
|
||||
return CodeMPPTimeout
|
||||
}
|
||||
|
||||
// Returns a human readable string describing the target FailureMessage.
|
||||
//
|
||||
// NOTE: Implements the error interface.
|
||||
func (f *FailMPPTimeout) Error() string {
|
||||
return f.Code().String()
|
||||
}
|
||||
|
||||
// DecodeFailure decodes, validates, and parses the lnwire onion failure, for
|
||||
// the provided protocol version.
|
||||
func DecodeFailure(r io.Reader, pver uint32) (FailureMessage, error) {
|
||||
@ -1366,6 +1390,9 @@ func makeEmptyOnionError(code FailCode) (FailureMessage, error) {
|
||||
case CodeInvalidOnionPayload:
|
||||
return &InvalidOnionPayload{}, nil
|
||||
|
||||
case CodeMPPTimeout:
|
||||
return &FailMPPTimeout{}, nil
|
||||
|
||||
default:
|
||||
return nil, errors.Errorf("unknown error code: %v", code)
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ var onionFailures = []FailureMessage{
|
||||
&FailUnknownNextPeer{},
|
||||
&FailIncorrectPaymentAmount{},
|
||||
&FailFinalExpiryTooSoon{},
|
||||
&FailMPPTimeout{},
|
||||
|
||||
NewFailIncorrectDetails(99, 100),
|
||||
NewInvalidOnionVersion(testOnionHash),
|
||||
|
Loading…
Reference in New Issue
Block a user