lnd/onionmessage/interfaces.go
Gijs van Dam f464fb9cd8 multi: OnionPeerActor for per-peer message support
Introduce a fat OnionPeerActor that handles the full onion message
processing pipeline for each peer connection. The actor decodes incoming
onion messages, determines the routing action (forward or deliver),
executes the action via PeerMessageSender, and dispatches updates to
subscribers via OnionMessageUpdateDispatcher.

Key components:
- OnionRouter interface abstracting sphinx router operations
- PeerMessageSender interface for forwarding to other peers
- OnionMessageUpdateDispatcher interface for subscriber notifications
- OnionActorFactory for spawning per-peer actors with shared deps
- Full test suite calling Receive() directly with NoOpReplayLog
2026-03-02 15:46:21 +01:00

41 lines
1.3 KiB
Go

package onionmessage
import (
"github.com/btcsuite/btcd/btcec/v2"
sphinx "github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/lnwire"
)
// OnionRouter wraps the sphinx router operations needed for onion message
// processing.
type OnionRouter interface {
// ProcessOnionPacket processes an onion packet and returns the
// processed result.
ProcessOnionPacket(pkt *sphinx.OnionPacket, assocData []byte,
incomingCltv uint32,
opts ...sphinx.ProcessOnionOpt) (*sphinx.ProcessedPacket, error)
// DecryptBlindedHopData decrypts the encrypted hop data using the
// given path key.
DecryptBlindedHopData(pathKey *btcec.PublicKey,
encData []byte) ([]byte, error)
// NextEphemeral derives the next ephemeral key from the current path
// key.
NextEphemeral(
currentPathKey *btcec.PublicKey) (*btcec.PublicKey, error)
}
// OnionMessageUpdateDispatcher dispatches onion message updates to
// subscribers.
type OnionMessageUpdateDispatcher interface {
// SendUpdate sends an onion message update to all subscribers.
SendUpdate(update any) error
}
// PeerMessageSender sends onion messages to peers identified by public key.
type PeerMessageSender interface {
// SendToPeer sends an onion message to the peer identified by the
// given compressed public key.
SendToPeer(pubKey [33]byte, msg *lnwire.OnionMessage) error
}