feature

package
v0.17.2-beta Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownSet is returned if a proposed feature vector contains a
	// set that is unknown to LND.
	ErrUnknownSet = errors.New("unknown feature bit set")

	// ErrFeatureConfigured is returned if an attempt is made to unset a
	// feature that was configured at startup.
	ErrFeatureConfigured = errors.New("can't unset configured feature")
)

Functions

func ValidateDeps

func ValidateDeps(fv *lnwire.FeatureVector) error

ValidateDeps asserts that a feature vector sets all features and their transitive dependencies properly. It assumes that the dependencies between optional and required features are identical, e.g. if a feature is required but its dependency is optional, that is sufficient.

func ValidateRequired

func ValidateRequired(fv *lnwire.FeatureVector) error

ValidateRequired returns an error if the feature vector contains a non-zero number of unknown, required feature bits.

Types

type Config

type Config struct {
	// NoTLVOnion unsets any optional or required TLVOnionPaylod bits from
	// all feature sets.
	NoTLVOnion bool

	// NoStaticRemoteKey unsets any optional or required StaticRemoteKey
	// bits from all feature sets.
	NoStaticRemoteKey bool

	// NoAnchors unsets any bits signaling support for anchor outputs.
	NoAnchors bool

	// NoWumbo unsets any bits signalling support for wumbo channels.
	NoWumbo bool

	// NoTaprootChans unsets any bits signaling support for taproot
	// channels.
	NoTaprootChans bool

	// NoScriptEnforcementLease unsets any bits signaling support for script
	// enforced leases.
	NoScriptEnforcementLease bool

	// NoKeysend unsets any bits signaling support for accepting keysend
	// payments.
	NoKeysend bool

	// NoOptionScidAlias unsets any bits signalling support for
	// option_scid_alias. This also implicitly disables zero-conf channels.
	NoOptionScidAlias bool

	// NoZeroConf unsets any bits signalling support for zero-conf
	// channels. This should be used instead of NoOptionScidAlias to still
	// keep option-scid-alias support.
	NoZeroConf bool

	// NoAnySegwit unsets any bits that signal support for using other
	// segwit witness versions for co-op closes.
	NoAnySegwit bool

	// CustomFeatures is a set of custom features to advertise in each
	// set.
	CustomFeatures map[Set][]lnwire.FeatureBit
}

Config houses any runtime modifications to the default set descriptors. For our purposes, this typically means disabling certain features to test legacy protocol interoperability or functionality.

type ErrMissingFeatureDep

type ErrMissingFeatureDep struct {
	// contains filtered or unexported fields
}

ErrMissingFeatureDep is an error signaling that a transitive dependency in a feature vector is not set properly.

func NewErrMissingFeatureDep

func NewErrMissingFeatureDep(dep lnwire.FeatureBit) ErrMissingFeatureDep

NewErrMissingFeatureDep creates a new ErrMissingFeatureDep error.

func (ErrMissingFeatureDep) Error

func (e ErrMissingFeatureDep) Error() string

Error returns a human-readable description of the missing dep error.

type ErrUnknownRequired

type ErrUnknownRequired struct {
	// contains filtered or unexported fields
}

ErrUnknownRequired signals that a feature vector requires certain features that our node is unaware of or does not implement.

func NewErrUnknownRequired

func NewErrUnknownRequired(unknown []lnwire.FeatureBit) ErrUnknownRequired

NewErrUnknownRequired initializes an ErrUnknownRequired with the unknown feature bits.

func (ErrUnknownRequired) Error

func (e ErrUnknownRequired) Error() string

Error returns a human-readable description of the error.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is responsible for generating feature vectors for different requested feature sets.

func NewManager

func NewManager(cfg Config) (*Manager, error)

NewManager creates a new feature Manager, applying any custom modifications to its feature sets before returning.

func (*Manager) Get

func (m *Manager) Get(set Set) *lnwire.FeatureVector

Get returns a feature vector for the passed set. If no set is known, an empty feature vector is returned.

func (*Manager) GetRaw

func (m *Manager) GetRaw(set Set) *lnwire.RawFeatureVector

GetRaw returns a raw feature vector for the passed set. If no set is known, an empty raw feature vector is returned.

func (*Manager) ListSets

func (m *Manager) ListSets() []Set

ListSets returns a list of the feature sets that our node supports.

func (*Manager) UpdateFeatureSets

func (m *Manager) UpdateFeatureSets(
	updates map[Set]*lnwire.RawFeatureVector) error

UpdateFeatureSets accepts a map of new feature vectors for each of the manager's known sets, validates that the update can be applied and modifies the feature manager's internal state. If a set is not included in the update map, it is left unchanged. The feature vectors provided are expected to include the current set of features, updated with desired bits added/removed.

type Set

type Set uint8

Set is an enum identifying various feature sets, which separates the single feature namespace into distinct categories depending what context a feature vector is being used.

const (
	// SetInit identifies features that should be sent in an Init message to
	// a remote peer.
	SetInit Set = iota

	// SetLegacyGlobal identifies features that should be set in the legacy
	// GlobalFeatures field of an Init message, which maintains backwards
	// compatibility with nodes that haven't implemented flat features.
	SetLegacyGlobal

	// SetNodeAnn identifies features that should be advertised on node
	// announcements.
	SetNodeAnn

	// SetInvoice identifies features that should be advertised on invoices
	// generated by the daemon.
	SetInvoice

	// SetInvoiceAmp identifies the features that should be advertised on
	// AMP invoices generated by the daemon.
	SetInvoiceAmp
)

func (Set) Maximum

func (s Set) Maximum() lnwire.FeatureBit

Maximum returns the maximum allowable value for a feature bit in the context of a set. The maximum feature value we can express differs by set context because the amount of space available varies between protocol messages. In practice this should never be a problem (reasonably one would never hit these high ranges), but we enforce these maximums for the sake of sane validation.

func (Set) String

func (s Set) String() string

String returns a human-readable description of a Set.

Jump to

Keyboard shortcuts

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