lnd/onionmessage/errors.go
Gijs van Dam 261babcf09
onionmessage: drop onion messages cycling back to the sending peer
Block forwarding of an onion message when the resolved next hop is the
same peer that delivered it. Such a forward would immediately bounce the
message back over the very connection it arrived on, which is never
useful and can be abused to amplify traffic against a peer.

The check runs after the routing action is resolved, so both direct
next-node-ID and SCID-resolved paths are covered. A new
`ErrSamePeerCycle` is returned (and logged at warn level) when a cycle
is detected.
2026-04-17 12:33:08 +02:00

22 lines
709 B
Go

package onionmessage
import "errors"
var (
// ErrActorShuttingDown is returned by the actor logic when its context
// is cancelled.
ErrActorShuttingDown = errors.New("actor shutting down")
// ErrNextNodeIdEmpty is returned when the next node ID is missing from
// the route data.
ErrNextNodeIdEmpty = errors.New("next node ID empty")
// ErrSCIDEmpty is returned when the short channel ID is missing from
// the route data.
ErrSCIDEmpty = errors.New("short channel ID empty")
// ErrSamePeerCycle is returned when a forwarding onion message
// would be sent back to the same peer it was received from.
ErrSamePeerCycle = errors.New("onion message cycle: next " +
"hop is the sending peer")
)