diff --git a/lnwire/onion_error.go b/lnwire/onion_error.go index d00dbd96..724a8110 100644 --- a/lnwire/onion_error.go +++ b/lnwire/onion_error.go @@ -146,6 +146,11 @@ func (c FailCode) String() string { // NOTE: May be returned by any node in the payment route. type FailInvalidRealm struct{} +func (f FailInvalidRealm) Error() string { + var code = f.Code() + return code.String() +} + // Code returns the failure unique code. // // NOTE: Part of the FailureMessage interface. @@ -165,6 +170,11 @@ func (f FailTemporaryNodeFailure) Code() FailCode { return CodeTemporaryNodeFailure } +func (f FailTemporaryNodeFailure) Error() string { + var code = f.Code() + return code.String() +} + // FailPermanentNodeFailure is returned if an otherwise unspecified permanent // error occurs for the entire node. // @@ -178,6 +188,11 @@ func (f FailPermanentNodeFailure) Code() FailCode { return CodePermanentNodeFailure } +func (f FailPermanentNodeFailure) Error() string { + var code = f.Code() + return code.String() +} + // FailRequiredNodeFeatureMissing is returned if a node has requirement // advertised in its node_announcement features which were not present in the // onion. @@ -192,6 +207,11 @@ func (f FailRequiredNodeFeatureMissing) Code() FailCode { return CodeRequiredNodeFeatureMissing } +func (f FailRequiredNodeFeatureMissing) Error() string { + var code = f.Code() + return code.String() +} + // FailPermanentChannelFailure is return if an otherwise unspecified permanent // error occurs for the outgoing channel (eg. channel (recently). // @@ -205,6 +225,11 @@ func (f FailPermanentChannelFailure) Code() FailCode { return CodePermanentChannelFailure } +func (f FailPermanentChannelFailure) Error() string { + var code = f.Code() + return code.String() +} + // FailRequiredChannelFeatureMissing is returned if the outgoing channel has a // requirement advertised in its channel announcement features which were not // present in the onion. @@ -219,6 +244,11 @@ func (f FailRequiredChannelFeatureMissing) Code() FailCode { 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 // not known. // @@ -232,6 +262,11 @@ func (f FailUnknownNextPeer) Code() FailCode { return CodeUnknownNextPeer } +func (f FailUnknownNextPeer) Error() string { + var code = f.Code() + return code.String() +} + // FailUnknownPaymentHash is returned If the payment hash has already been // 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 @@ -247,6 +282,11 @@ func (f FailUnknownPaymentHash) Code() FailCode { 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 // 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. @@ -263,6 +303,11 @@ func (f FailIncorrectPaymentAmount) Code() FailCode { 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 // node MUST fail the HTLC. // @@ -276,6 +321,11 @@ func (f FailFinalExpiryTooSoon) Code() FailCode { return CodeFinalExpiryTooSoon } +func (f FailFinalExpiryTooSoon) Error() string { + var code = f.Code() + return code.String() +} + // FailInvalidOnionVersion is returned if the onion version byte is unknown. // // NOTE: May be returned only by intermediate nodes. @@ -284,6 +334,11 @@ type FailInvalidOnionVersion struct { OnionSHA256 [sha256.Size]byte } +func (f FailInvalidOnionVersion) Error() string { + var code = f.Code() + return code.String() +} + // NewInvalidOnionVersion creates new instance of the FailInvalidOnionVersion. func NewInvalidOnionVersion(onion []byte) *FailInvalidOnionVersion { 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[:]) } +func (f FailInvalidOnionHmac) Error() string { + var code = f.Code() + return code.String() +} + // FailInvalidOnionKey is return if the ephemeral key in the onion is // unparsable. // @@ -379,6 +439,11 @@ func (f *FailInvalidOnionKey) Encode(w io.Writer, pver uint32) error { 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 // occurs for the outgoing channel (eg. channel capacity reached, too many // in-flight htlcs) @@ -404,6 +469,11 @@ func (f *FailTemporaryChannelFailure) Code() FailCode { return CodeTemporaryChannelFailure } +func (f FailTemporaryChannelFailure) Error() string { + var code = f.Code() + return code.String() +} + // Decode decodes the failure from bytes stream. // // NOTE: Part of the Serializable interface. @@ -473,6 +543,11 @@ func (f *FailAmountBelowMinimum) Code() FailCode { return CodeAmountBelowMinimum } +func (f FailAmountBelowMinimum) Error() string { + var code = f.Code() + return code.String() +} + // Decode decodes the failure from bytes stream. // // NOTE: Part of the Serializable interface. @@ -536,6 +611,11 @@ func (f *FailFeeInsufficient) Code() FailCode { return CodeFeeInsufficient } +func (f FailFeeInsufficient) Error() string { + var code = f.Code() + return code.String() +} + // Decode decodes the failure from bytes stream. // // NOTE: Part of the Serializable interface. @@ -602,6 +682,11 @@ func (f *FailIncorrectCltvExpiry) Code() FailCode { return CodeIncorrectCltvExpiry } +func (f *FailIncorrectCltvExpiry) Error() string { + var code = f.Code() + return code.String() +} + // Decode decodes the failure from bytes stream. // // NOTE: Part of the Serializable interface. @@ -659,7 +744,12 @@ func (f *FailExpiryTooSoon) Code() FailCode { 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. func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error { @@ -714,6 +804,11 @@ func (f *FailChannelDisabled) Code() FailCode { return CodeChannelDisabled } +func (f FailChannelDisabled) Error() string { + var code = f.Code() + return code.String() +} + // Decode decodes the failure from bytes stream. // // NOTE: Part of the Serializable interface. @@ -757,6 +852,11 @@ type FailFinalIncorrectCltvExpiry struct { CltvExpiry uint32 } +func (f FailFinalIncorrectCltvExpiry) Error() string { + var code = f.Code() + return code.String() +} + // NewFinalIncorrectCltvExpiry creates new instance of the // FailFinalIncorrectCltvExpiry. func NewFinalIncorrectCltvExpiry(cltvExpiry uint32) *FailFinalIncorrectCltvExpiry { @@ -795,6 +895,11 @@ type FailFinalIncorrectHtlcAmount struct { IncomingHTLCAmount MilliSatoshi } +func (f FailFinalIncorrectHtlcAmount) Error() string { + var code = f.Code() + return code.String() +} + // NewFinalIncorrectHtlcAmount creates new instance of the // FailFinalIncorrectHtlcAmount. func NewFinalIncorrectHtlcAmount(amount MilliSatoshi) *FailFinalIncorrectHtlcAmount {