lnwire21: add CodeInvalidBlinding
To prevent the need to copy the entire onion_error.go file for a new Mission Control migration, this commit just updates the existing lnwire21/onion_error.go file with the new CodeInvalidBlinding code. The lnwire21 should not really ever be updated but adding a new code should be fine as it does not affect old migrations since this is a new code.
This commit is contained in:
1 file changed
+54
@@ -54,6 +54,8 @@ type FailCode uint16
|
|||||||
|
|
||||||
// The currently defined onion failure types within this current version of the
|
// The currently defined onion failure types within this current version of the
|
||||||
// Lightning protocol.
|
// Lightning protocol.
|
||||||
|
//
|
||||||
|
//nolint:lll
|
||||||
const (
|
const (
|
||||||
CodeNone FailCode = 0
|
CodeNone FailCode = 0
|
||||||
CodeInvalidRealm = FlagBadOnion | 1
|
CodeInvalidRealm = FlagBadOnion | 1
|
||||||
@@ -80,6 +82,7 @@ const (
|
|||||||
CodeExpiryTooFar FailCode = 21
|
CodeExpiryTooFar FailCode = 21
|
||||||
CodeInvalidOnionPayload = FlagPerm | 22
|
CodeInvalidOnionPayload = FlagPerm | 22
|
||||||
CodeMPPTimeout FailCode = 23
|
CodeMPPTimeout FailCode = 23
|
||||||
|
CodeInvalidBlinding = FlagBadOnion | FlagPerm | 24
|
||||||
)
|
)
|
||||||
|
|
||||||
// String returns the string representation of the failure code.
|
// String returns the string representation of the failure code.
|
||||||
@@ -157,6 +160,9 @@ func (c FailCode) String() string {
|
|||||||
case CodeMPPTimeout:
|
case CodeMPPTimeout:
|
||||||
return "MPPTimeout"
|
return "MPPTimeout"
|
||||||
|
|
||||||
|
case CodeInvalidBlinding:
|
||||||
|
return "InvalidBlinding"
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "<unknown>"
|
return "<unknown>"
|
||||||
}
|
}
|
||||||
@@ -571,6 +577,51 @@ func (f *FailInvalidOnionKey) Error() string {
|
|||||||
return fmt.Sprintf("InvalidOnionKey(onion_sha=%x)", f.OnionSHA256[:])
|
return fmt.Sprintf("InvalidOnionKey(onion_sha=%x)", f.OnionSHA256[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FailInvalidBlinding is returned if there has been a route blinding related
|
||||||
|
// error.
|
||||||
|
type FailInvalidBlinding struct {
|
||||||
|
OnionSHA256 [sha256.Size]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// Code returns the failure unique code.
|
||||||
|
//
|
||||||
|
// NOTE: Part of the FailureMessage interface.
|
||||||
|
func (f *FailInvalidBlinding) Code() FailCode {
|
||||||
|
return CodeInvalidBlinding
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a human readable string describing the target FailureMessage.
|
||||||
|
//
|
||||||
|
// NOTE: Implements the error interface.
|
||||||
|
func (f *FailInvalidBlinding) Error() string {
|
||||||
|
return f.Code().String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode decodes the failure from bytes stream.
|
||||||
|
//
|
||||||
|
// NOTE: Part of the Serializable interface.
|
||||||
|
func (f *FailInvalidBlinding) Decode(r io.Reader, _ uint32) error {
|
||||||
|
return ReadElement(r, f.OnionSHA256[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode writes the failure in bytes stream.
|
||||||
|
//
|
||||||
|
// NOTE: Part of the Serializable interface.
|
||||||
|
func (f *FailInvalidBlinding) Encode(w *bytes.Buffer, _ uint32) error {
|
||||||
|
return WriteElement(w, f.OnionSHA256[:])
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInvalidBlinding creates new instance of FailInvalidBlinding.
|
||||||
|
func NewInvalidBlinding(onion []byte) *FailInvalidBlinding {
|
||||||
|
// The spec allows empty onion hashes for invalid blinding, so we only
|
||||||
|
// include our onion hash if it's provided.
|
||||||
|
if onion == nil {
|
||||||
|
return &FailInvalidBlinding{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &FailInvalidBlinding{OnionSHA256: sha256.Sum256(onion)}
|
||||||
|
}
|
||||||
|
|
||||||
// parseChannelUpdateCompatabilityMode will attempt to parse a channel updated
|
// parseChannelUpdateCompatabilityMode will attempt to parse a channel updated
|
||||||
// encoded into an onion error payload in two ways. First, we'll try the
|
// encoded into an onion error payload in two ways. First, we'll try the
|
||||||
// compatibility oriented version wherein we'll _skip_ the length prefixing on
|
// compatibility oriented version wherein we'll _skip_ the length prefixing on
|
||||||
@@ -1392,6 +1443,9 @@ func makeEmptyOnionError(code FailCode) (FailureMessage, error) {
|
|||||||
case CodeMPPTimeout:
|
case CodeMPPTimeout:
|
||||||
return &FailMPPTimeout{}, nil
|
return &FailMPPTimeout{}, nil
|
||||||
|
|
||||||
|
case CodeInvalidBlinding:
|
||||||
|
return &FailInvalidBlinding{}, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, errors.Errorf("unknown error code: %v", code)
|
return nil, errors.Errorf("unknown error code: %v", code)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user