lnwire: add Error() method to lnwire.FailureMessage
This commit is contained in:
parent
40ce817235
commit
492f7fa52f
@ -146,6 +146,11 @@ func (c FailCode) String() string {
|
|||||||
// NOTE: May be returned by any node in the payment route.
|
// NOTE: May be returned by any node in the payment route.
|
||||||
type FailInvalidRealm struct{}
|
type FailInvalidRealm struct{}
|
||||||
|
|
||||||
|
func (f FailInvalidRealm) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Code returns the failure unique code.
|
// Code returns the failure unique code.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the FailureMessage interface.
|
// NOTE: Part of the FailureMessage interface.
|
||||||
@ -165,6 +170,11 @@ func (f FailTemporaryNodeFailure) Code() FailCode {
|
|||||||
return CodeTemporaryNodeFailure
|
return CodeTemporaryNodeFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailTemporaryNodeFailure) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailPermanentNodeFailure is returned if an otherwise unspecified permanent
|
// FailPermanentNodeFailure is returned if an otherwise unspecified permanent
|
||||||
// error occurs for the entire node.
|
// error occurs for the entire node.
|
||||||
//
|
//
|
||||||
@ -178,6 +188,11 @@ func (f FailPermanentNodeFailure) Code() FailCode {
|
|||||||
return CodePermanentNodeFailure
|
return CodePermanentNodeFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailPermanentNodeFailure) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailRequiredNodeFeatureMissing is returned if a node has requirement
|
// FailRequiredNodeFeatureMissing is returned if a node has requirement
|
||||||
// advertised in its node_announcement features which were not present in the
|
// advertised in its node_announcement features which were not present in the
|
||||||
// onion.
|
// onion.
|
||||||
@ -192,6 +207,11 @@ func (f FailRequiredNodeFeatureMissing) Code() FailCode {
|
|||||||
return CodeRequiredNodeFeatureMissing
|
return CodeRequiredNodeFeatureMissing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailRequiredNodeFeatureMissing) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailPermanentChannelFailure is return if an otherwise unspecified permanent
|
// FailPermanentChannelFailure is return if an otherwise unspecified permanent
|
||||||
// error occurs for the outgoing channel (eg. channel (recently).
|
// error occurs for the outgoing channel (eg. channel (recently).
|
||||||
//
|
//
|
||||||
@ -205,6 +225,11 @@ func (f FailPermanentChannelFailure) Code() FailCode {
|
|||||||
return CodePermanentChannelFailure
|
return CodePermanentChannelFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailPermanentChannelFailure) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailRequiredChannelFeatureMissing is returned if the outgoing channel has a
|
// FailRequiredChannelFeatureMissing is returned if the outgoing channel has a
|
||||||
// requirement advertised in its channel announcement features which were not
|
// requirement advertised in its channel announcement features which were not
|
||||||
// present in the onion.
|
// present in the onion.
|
||||||
@ -219,6 +244,11 @@ func (f FailRequiredChannelFeatureMissing) Code() FailCode {
|
|||||||
return CodeRequiredChannelFeatureMissing
|
return CodeRequiredChannelFeatureMissing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailRequiredChannelFeatureMissing) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailUnknownNextPeer is returned if the next peer specified by the onion is
|
// FailUnknownNextPeer is returned if the next peer specified by the onion is
|
||||||
// not known.
|
// not known.
|
||||||
//
|
//
|
||||||
@ -232,6 +262,11 @@ func (f FailUnknownNextPeer) Code() FailCode {
|
|||||||
return CodeUnknownNextPeer
|
return CodeUnknownNextPeer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailUnknownNextPeer) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailUnknownPaymentHash is returned If the payment hash has already been
|
// FailUnknownPaymentHash is returned If the payment hash has already been
|
||||||
// paid, the final node MAY treat the payment hash as unknown, or may succeed
|
// paid, the final node MAY treat the payment hash as unknown, or may succeed
|
||||||
// in accepting the HTLC. If the payment hash is unknown, the final node MUST
|
// in accepting the HTLC. If the payment hash is unknown, the final node MUST
|
||||||
@ -247,6 +282,11 @@ func (f FailUnknownPaymentHash) Code() FailCode {
|
|||||||
return CodeUnknownPaymentHash
|
return CodeUnknownPaymentHash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailUnknownPaymentHash) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailIncorrectPaymentAmount is returned if the amount paid is less than the
|
// FailIncorrectPaymentAmount is returned if the amount paid is less than the
|
||||||
// amount expected, the final node MUST fail the HTLC. If the amount paid is
|
// amount expected, the final node MUST fail the HTLC. If the amount paid is
|
||||||
// more than twice the amount expected, the final node SHOULD fail the HTLC.
|
// more than twice the amount expected, the final node SHOULD fail the HTLC.
|
||||||
@ -263,6 +303,11 @@ func (f FailIncorrectPaymentAmount) Code() FailCode {
|
|||||||
return CodeIncorrectPaymentAmount
|
return CodeIncorrectPaymentAmount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailIncorrectPaymentAmount) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailFinalExpiryTooSoon is returned if the cltv_expiry is too low, the final
|
// FailFinalExpiryTooSoon is returned if the cltv_expiry is too low, the final
|
||||||
// node MUST fail the HTLC.
|
// node MUST fail the HTLC.
|
||||||
//
|
//
|
||||||
@ -276,6 +321,11 @@ func (f FailFinalExpiryTooSoon) Code() FailCode {
|
|||||||
return CodeFinalExpiryTooSoon
|
return CodeFinalExpiryTooSoon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailFinalExpiryTooSoon) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailInvalidOnionVersion is returned if the onion version byte is unknown.
|
// FailInvalidOnionVersion is returned if the onion version byte is unknown.
|
||||||
//
|
//
|
||||||
// NOTE: May be returned only by intermediate nodes.
|
// NOTE: May be returned only by intermediate nodes.
|
||||||
@ -284,6 +334,11 @@ type FailInvalidOnionVersion struct {
|
|||||||
OnionSHA256 [sha256.Size]byte
|
OnionSHA256 [sha256.Size]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailInvalidOnionVersion) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// NewInvalidOnionVersion creates new instance of the FailInvalidOnionVersion.
|
// NewInvalidOnionVersion creates new instance of the FailInvalidOnionVersion.
|
||||||
func NewInvalidOnionVersion(onion []byte) *FailInvalidOnionVersion {
|
func NewInvalidOnionVersion(onion []byte) *FailInvalidOnionVersion {
|
||||||
return &FailInvalidOnionVersion{OnionSHA256: sha256.Sum256(onion)}
|
return &FailInvalidOnionVersion{OnionSHA256: sha256.Sum256(onion)}
|
||||||
@ -344,6 +399,11 @@ func (f *FailInvalidOnionHmac) Encode(w io.Writer, pver uint32) error {
|
|||||||
return writeElement(w, f.OnionSHA256[:])
|
return writeElement(w, f.OnionSHA256[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailInvalidOnionHmac) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailInvalidOnionKey is return if the ephemeral key in the onion is
|
// FailInvalidOnionKey is return if the ephemeral key in the onion is
|
||||||
// unparsable.
|
// unparsable.
|
||||||
//
|
//
|
||||||
@ -379,6 +439,11 @@ func (f *FailInvalidOnionKey) Encode(w io.Writer, pver uint32) error {
|
|||||||
return writeElement(w, f.OnionSHA256[:])
|
return writeElement(w, f.OnionSHA256[:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailInvalidOnionKey) Error() string {
|
||||||
|
var failCode = f.Code()
|
||||||
|
return failCode.String()
|
||||||
|
}
|
||||||
|
|
||||||
// FailTemporaryChannelFailure is if an otherwise unspecified transient error
|
// FailTemporaryChannelFailure is if an otherwise unspecified transient error
|
||||||
// occurs for the outgoing channel (eg. channel capacity reached, too many
|
// occurs for the outgoing channel (eg. channel capacity reached, too many
|
||||||
// in-flight htlcs)
|
// in-flight htlcs)
|
||||||
@ -404,6 +469,11 @@ func (f *FailTemporaryChannelFailure) Code() FailCode {
|
|||||||
return CodeTemporaryChannelFailure
|
return CodeTemporaryChannelFailure
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailTemporaryChannelFailure) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Decode decodes the failure from bytes stream.
|
// Decode decodes the failure from bytes stream.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the Serializable interface.
|
// NOTE: Part of the Serializable interface.
|
||||||
@ -473,6 +543,11 @@ func (f *FailAmountBelowMinimum) Code() FailCode {
|
|||||||
return CodeAmountBelowMinimum
|
return CodeAmountBelowMinimum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailAmountBelowMinimum) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Decode decodes the failure from bytes stream.
|
// Decode decodes the failure from bytes stream.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the Serializable interface.
|
// NOTE: Part of the Serializable interface.
|
||||||
@ -536,6 +611,11 @@ func (f *FailFeeInsufficient) Code() FailCode {
|
|||||||
return CodeFeeInsufficient
|
return CodeFeeInsufficient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailFeeInsufficient) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Decode decodes the failure from bytes stream.
|
// Decode decodes the failure from bytes stream.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the Serializable interface.
|
// NOTE: Part of the Serializable interface.
|
||||||
@ -602,6 +682,11 @@ func (f *FailIncorrectCltvExpiry) Code() FailCode {
|
|||||||
return CodeIncorrectCltvExpiry
|
return CodeIncorrectCltvExpiry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *FailIncorrectCltvExpiry) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Decode decodes the failure from bytes stream.
|
// Decode decodes the failure from bytes stream.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the Serializable interface.
|
// NOTE: Part of the Serializable interface.
|
||||||
@ -659,7 +744,12 @@ func (f *FailExpiryTooSoon) Code() FailCode {
|
|||||||
return CodeExpiryTooSoon
|
return CodeExpiryTooSoon
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode decodes the failure from bytes stream.
|
func (f *FailExpiryTooSoon) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode decodes the failure from l stream.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the Serializable interface.
|
// NOTE: Part of the Serializable interface.
|
||||||
func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error {
|
func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error {
|
||||||
@ -714,6 +804,11 @@ func (f *FailChannelDisabled) Code() FailCode {
|
|||||||
return CodeChannelDisabled
|
return CodeChannelDisabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailChannelDisabled) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Decode decodes the failure from bytes stream.
|
// Decode decodes the failure from bytes stream.
|
||||||
//
|
//
|
||||||
// NOTE: Part of the Serializable interface.
|
// NOTE: Part of the Serializable interface.
|
||||||
@ -757,6 +852,11 @@ type FailFinalIncorrectCltvExpiry struct {
|
|||||||
CltvExpiry uint32
|
CltvExpiry uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailFinalIncorrectCltvExpiry) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// NewFinalIncorrectCltvExpiry creates new instance of the
|
// NewFinalIncorrectCltvExpiry creates new instance of the
|
||||||
// FailFinalIncorrectCltvExpiry.
|
// FailFinalIncorrectCltvExpiry.
|
||||||
func NewFinalIncorrectCltvExpiry(cltvExpiry uint32) *FailFinalIncorrectCltvExpiry {
|
func NewFinalIncorrectCltvExpiry(cltvExpiry uint32) *FailFinalIncorrectCltvExpiry {
|
||||||
@ -795,6 +895,11 @@ type FailFinalIncorrectHtlcAmount struct {
|
|||||||
IncomingHTLCAmount MilliSatoshi
|
IncomingHTLCAmount MilliSatoshi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f FailFinalIncorrectHtlcAmount) Error() string {
|
||||||
|
var code = f.Code()
|
||||||
|
return code.String()
|
||||||
|
}
|
||||||
|
|
||||||
// NewFinalIncorrectHtlcAmount creates new instance of the
|
// NewFinalIncorrectHtlcAmount creates new instance of the
|
||||||
// FailFinalIncorrectHtlcAmount.
|
// FailFinalIncorrectHtlcAmount.
|
||||||
func NewFinalIncorrectHtlcAmount(amount MilliSatoshi) *FailFinalIncorrectHtlcAmount {
|
func NewFinalIncorrectHtlcAmount(amount MilliSatoshi) *FailFinalIncorrectHtlcAmount {
|
||||||
|
Loading…
Reference in New Issue
Block a user