aliasmgr

package
v0.20.1-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// AliasStartBlockHeight is the starting block height of the alias
	// range.
	AliasStartBlockHeight uint32 = 16_000_000

	// AliasEndBlockHeight is the ending block height of the alias range.
	AliasEndBlockHeight uint32 = 16_250_000

	// StartingAlias is the first alias ShortChannelID that will get
	// assigned by RequestAlias. The starting BlockHeight is chosen so that
	// legitimate SCIDs in integration tests aren't mistaken for an alias.
	StartingAlias = lnwire.ShortChannelID{
		BlockHeight: AliasStartBlockHeight,
		TxIndex:     0,
		TxPosition:  0,
	}

	// ErrAliasNotFound is returned when the alias is not found and can't
	// be mapped to a base SCID.
	ErrAliasNotFound = fmt.Errorf("alias not found")
)

Functions

func IsAlias

func IsAlias(scid lnwire.ShortChannelID) bool

IsAlias returns true if the passed SCID is an alias. The function determines this by looking at the BlockHeight. If the BlockHeight is greater than AliasStartBlockHeight and less than AliasEndBlockHeight, then it is an alias assigned by RequestAlias. These bounds only apply to aliases we generate. Our peers are free to use any range they choose.

Types

type AddLocalAliasOption

type AddLocalAliasOption func(cfg *addAliasCfg)

AddLocalAliasOption is a functional option that modifies the configuration for adding a local alias.

func WithBaseLookup

func WithBaseLookup() AddLocalAliasOption

WithBaseLookup is a functional option that controls whether a reverse lookup will be stored from the alias to the base scid.

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Manager is a struct that handles aliases for LND. It has an underlying database that can allocate aliases for channels, stores the peer's last alias for use in our hop hints, and contains mappings that both the Switch and Gossiper use.

func NewManager

func NewManager(db kvdb.Backend, linkAliasUpdater UpdateLinkAliases) (*Manager,
	error)

NewManager initializes an alias Manager from the passed database backend.

func (*Manager) AddLocalAlias

func (m *Manager) AddLocalAlias(alias, baseScid lnwire.ShortChannelID,
	gossip, linkUpdate bool, opts ...AddLocalAliasOption) error

AddLocalAlias adds a database mapping from the passed alias to the passed base SCID. The gossip boolean marks whether or not to create a mapping that the gossiper will use. It is set to false for the upgrade path where the feature-bit is toggled on and there are existing channels. The linkUpdate flag is used to signal whether this function should also trigger an update on the htlcswitch scid alias maps.

NOTE: The following aliases will not be persisted (will be lost on restart):

  • Aliases that were created without gossip flag.
  • Aliases that correspond to confirmed channels.

func (*Manager) DeleteLocalAlias

func (m *Manager) DeleteLocalAlias(alias,
	baseScid lnwire.ShortChannelID) error

DeleteLocalAlias removes a mapping from the database and the Manager's maps.

func (*Manager) DeleteSixConfs

func (m *Manager) DeleteSixConfs(baseScid lnwire.ShortChannelID) error

DeleteSixConfs removes a mapping for the gossiper once six confirmations have been reached and the channel is public. At this point, only the confirmed SCID should be used.

func (*Manager) FindBaseSCID

func (m *Manager) FindBaseSCID(
	alias lnwire.ShortChannelID) (lnwire.ShortChannelID, error)

FindBaseSCID finds the base SCID for a given alias. This is used in the gossiper to find the correct SCID to lookup in the graph database. It can also be used to look up the base for manual aliases that were added over the RPC.

func (*Manager) GetAliases

func (m *Manager) GetAliases(
	base lnwire.ShortChannelID) []lnwire.ShortChannelID

GetAliases fetches the set of aliases stored under a given base SCID from write-through caches.

func (*Manager) GetPeerAlias

func (m *Manager) GetPeerAlias(chanID lnwire.ChannelID) (lnwire.ShortChannelID,
	error)

GetPeerAlias retrieves a peer's alias SCID by the channel's ChanID.

func (*Manager) ListAliases

func (m *Manager) ListAliases() ScidAliasMap

ListAliases returns a carbon copy of baseToSet. This is used by the rpc layer.

func (*Manager) PutPeerAlias

func (m *Manager) PutPeerAlias(chanID lnwire.ChannelID,
	alias lnwire.ShortChannelID) error

PutPeerAlias stores the peer's alias SCID once we learn of it in the channel_ready message.

func (*Manager) RequestAlias

func (m *Manager) RequestAlias() (lnwire.ShortChannelID, error)

RequestAlias returns a new ALIAS ShortChannelID to the caller by allocating the next un-allocated ShortChannelID. The starting ShortChannelID is 16000000:0:0 and the ending ShortChannelID is 16250000:16777215:65535. This gives roughly 2^58 possible ALIAS ShortChannelIDs which ensures this space won't get exhausted.

type ScidAliasMap

type ScidAliasMap map[lnwire.ShortChannelID][]lnwire.ShortChannelID

ScidAliasMap is a map from a base short channel ID to a set of alias short channel IDs.

type UpdateLinkAliases

type UpdateLinkAliases func(shortID lnwire.ShortChannelID) error

UpdateLinkAliases is a function type for a function that locates the active link that matches the given shortID and triggers an update based on the latest values of the alias manager.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL