a3478f1d99
Add a CheckCircularForward function which detects packets which are forwards over the same incoming and outgoing link, and errors if the node is configured to disallow forwards of this nature. This check is added to increase the cost of a liquidity lockup attack, because it increases the length of the route required to lock up an individual node's bandwidth. Since nodes are currently limited to 20 hops, increasing the length of the route needed to lock up capital increases the number of malicious payments an attacker will have to route, which increases the capital requirement of the attack overall.
67 lines
1.9 KiB
Go
67 lines
1.9 KiB
Go
package htlcswitch
|
|
|
|
// FailureDetail is an enum which is used to enrich failures with
|
|
// additional information.
|
|
type FailureDetail int
|
|
|
|
const (
|
|
// FailureDetailNone is returned when the wire message contains
|
|
// sufficient information.
|
|
FailureDetailNone = iota
|
|
|
|
// FailureDetailOnionDecode indicates that we could not decode an
|
|
// onion error.
|
|
FailureDetailOnionDecode
|
|
|
|
// FailureDetailLinkNotEligible indicates that a routing attempt was
|
|
// made over a link that is not eligible for routing.
|
|
FailureDetailLinkNotEligible
|
|
|
|
// FailureDetailOnChainTimeout indicates that a payment had to be timed
|
|
// out on chain before it got past the first hop by us or the remote
|
|
// party.
|
|
FailureDetailOnChainTimeout
|
|
|
|
// FailureDetailHTLCExceedsMax is returned when a htlc exceeds our
|
|
// policy's maximum htlc amount.
|
|
FailureDetailHTLCExceedsMax
|
|
|
|
// FailureDetailInsufficientBalance is returned when we cannot route a
|
|
// htlc due to insufficient outgoing capacity.
|
|
FailureDetailInsufficientBalance
|
|
|
|
// FailureDetailCircularRoute is returned when an attempt is made
|
|
// to forward a htlc through our node which arrives and leaves on the
|
|
// same channel.
|
|
FailureDetailCircularRoute
|
|
)
|
|
|
|
// String returns the string representation of a failure detail.
|
|
func (fd FailureDetail) String() string {
|
|
switch fd {
|
|
case FailureDetailNone:
|
|
return "no failure detail"
|
|
|
|
case FailureDetailOnionDecode:
|
|
return "could not decode onion"
|
|
|
|
case FailureDetailLinkNotEligible:
|
|
return "link not eligible"
|
|
|
|
case FailureDetailOnChainTimeout:
|
|
return "payment was resolved on-chain, then canceled back"
|
|
|
|
case FailureDetailHTLCExceedsMax:
|
|
return "htlc exceeds maximum policy amount"
|
|
|
|
case FailureDetailInsufficientBalance:
|
|
return "insufficient bandwidth to route htlc"
|
|
|
|
case FailureDetailCircularRoute:
|
|
return "same incoming and outgoing channel"
|
|
|
|
default:
|
|
return "unknown failure detail"
|
|
}
|
|
}
|