mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
74e0d545fe
This commit adds a linkError field to track the value of failures which occur at our node. This field is set when local payments or multi hop htlcs fail in the switch or on our outgoing link. This addition is required for the addition of a htlc notifier which will notify these failures in handleDownstreamPacket. The passing of link error to failAddPacket removes the need for an additional error field, because the link error's failure detail will contain any additional metadata. In the places where the failure detail does not cover all the metadata that was previously supplied by addr err, the error is logged before calling failAddPacket so that this change does not reduce the amount of information we log.
98 lines
3.0 KiB
Go
98 lines
3.0 KiB
Go
package htlcswitch
|
|
|
|
// FailureDetail is an interface implemented by failures that occur on
|
|
// our incoming or outgoing link, or within the switch itself.
|
|
type FailureDetail interface {
|
|
// FailureString returns the string representation of a failure
|
|
// detail.
|
|
FailureString() string
|
|
}
|
|
|
|
// OutgoingFailure is an enum which is used to enrich failures which occur in
|
|
// the switch or on our outgoing link with additional metadata.
|
|
type OutgoingFailure int
|
|
|
|
const (
|
|
// OutgoingFailureNone is returned when the wire message contains
|
|
// sufficient information.
|
|
OutgoingFailureNone OutgoingFailure = iota
|
|
|
|
// OutgoingFailureDecodeError indicates that we could not decode the
|
|
// failure reason provided for a failed payment.
|
|
OutgoingFailureDecodeError
|
|
|
|
// OutgoingFailureLinkNotEligible indicates that a routing attempt was
|
|
// made over a link that is not eligible for routing.
|
|
OutgoingFailureLinkNotEligible
|
|
|
|
// OutgoingFailureOnChainTimeout indicates that a payment had to be
|
|
// timed out on chain before it got past the first hop by us or the
|
|
// remote party.
|
|
OutgoingFailureOnChainTimeout
|
|
|
|
// OutgoingFailureHTLCExceedsMax is returned when a htlc exceeds our
|
|
// policy's maximum htlc amount.
|
|
OutgoingFailureHTLCExceedsMax
|
|
|
|
// OutgoingFailureInsufficientBalance is returned when we cannot route a
|
|
// htlc due to insufficient outgoing capacity.
|
|
OutgoingFailureInsufficientBalance
|
|
|
|
// OutgoingFailureCircularRoute is returned when an attempt is made
|
|
// to forward a htlc through our node which arrives and leaves on the
|
|
// same channel.
|
|
OutgoingFailureCircularRoute
|
|
|
|
// OutgoingFailureIncompleteForward is returned when we cancel an incomplete
|
|
// forward.
|
|
OutgoingFailureIncompleteForward
|
|
|
|
// OutgoingFailureDownstreamHtlcAdd is returned when we fail to add a
|
|
// downstream htlc to our outgoing link.
|
|
OutgoingFailureDownstreamHtlcAdd
|
|
|
|
// OutgoingFailureForwardsDisabled is returned when the switch is
|
|
// configured to disallow forwards.
|
|
OutgoingFailureForwardsDisabled
|
|
)
|
|
|
|
// FailureString returns the string representation of a failure detail.
|
|
//
|
|
// Note: it is part of the FailureDetail interface.
|
|
func (fd OutgoingFailure) FailureString() string {
|
|
switch fd {
|
|
case OutgoingFailureNone:
|
|
return "no failure detail"
|
|
|
|
case OutgoingFailureDecodeError:
|
|
return "could not decode wire failure"
|
|
|
|
case OutgoingFailureLinkNotEligible:
|
|
return "link not eligible"
|
|
|
|
case OutgoingFailureOnChainTimeout:
|
|
return "payment was resolved on-chain, then canceled back"
|
|
|
|
case OutgoingFailureHTLCExceedsMax:
|
|
return "htlc exceeds maximum policy amount"
|
|
|
|
case OutgoingFailureInsufficientBalance:
|
|
return "insufficient bandwidth to route htlc"
|
|
|
|
case OutgoingFailureCircularRoute:
|
|
return "same incoming and outgoing channel"
|
|
|
|
case OutgoingFailureIncompleteForward:
|
|
return "failed after detecting incomplete forward"
|
|
|
|
case OutgoingFailureDownstreamHtlcAdd:
|
|
return "could not add downstream htlc"
|
|
|
|
case OutgoingFailureForwardsDisabled:
|
|
return "node configured to disallow forwards"
|
|
|
|
default:
|
|
return "unknown failure detail"
|
|
}
|
|
}
|