blindedpath

package
v0.18.3-beta Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const Subsystem = "BLPT"

Variables

This section is empty.

Functions

func BuildBlindedPaymentPaths

func BuildBlindedPaymentPaths(cfg *BuildBlindedPathCfg) (
	[]*zpay32.BlindedPaymentPath, error)

BuildBlindedPaymentPaths uses the passed config to construct a set of blinded payment paths that can be added to the invoice.

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type BlindedHopPolicy

type BlindedHopPolicy struct {
	CLTVExpiryDelta uint16
	FeeRate         uint32
	BaseFee         lnwire.MilliSatoshi
	MinHTLCMsat     lnwire.MilliSatoshi
	MaxHTLCMsat     lnwire.MilliSatoshi
}

BlindedHopPolicy holds the set of relay policy values to use for a channel in a blinded path.

func AddPolicyBuffer

func AddPolicyBuffer(policy *BlindedHopPolicy, incMultiplier,
	decMultiplier float64) (*BlindedHopPolicy, error)

AddPolicyBuffer constructs the bufferedChanPolicies for a path hop by taking its actual policy values and multiplying them by the given multipliers. The base fee, fee rate and minimum HTLC msat values are adjusted via the incMultiplier while the maximum HTLC msat value is adjusted via the decMultiplier. If adjustments of the HTLC values no longer make sense then the original HTLC value is used.

type BuildBlindedPathCfg

type BuildBlindedPathCfg struct {
	// FindRoutes returns a set of routes to us that can be used for the
	// construction of blinded paths. These routes will consist of real
	// nodes advertising the route blinding feature bit. They may be of
	// various lengths and may even contain only a single hop. Any route
	// shorter than MinNumHops will be padded with dummy hops during route
	// construction.
	FindRoutes func(value lnwire.MilliSatoshi) ([]*route.Route, error)

	// FetchChannelEdgesByID attempts to look up the two directed edges for
	// the channel identified by the channel ID.
	FetchChannelEdgesByID func(chanID uint64) (*models.ChannelEdgeInfo,
		*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)

	// FetchOurOpenChannels fetches this node's set of open channels.
	FetchOurOpenChannels func() ([]*channeldb.OpenChannel, error)

	// BestHeight can be used to fetch the best block height that this node
	// is aware of.
	BestHeight func() (uint32, error)

	// AddPolicyBuffer is a function that can be used to alter the policy
	// values of the given channel edge. The main reason for doing this is
	// to add a safety buffer so that if the node makes small policy changes
	// during the lifetime of the blinded path, then the path remains valid
	// and so probing is more difficult. Note that this will only be called
	// for the policies of real nodes and won't be applied to
	// DefaultDummyHopPolicy.
	AddPolicyBuffer func(policy *BlindedHopPolicy) (*BlindedHopPolicy,
		error)

	// PathID is the secret data to embed in the blinded path data that we
	// will receive back as the recipient. This is the equivalent of the
	// payment address used in normal payments. It lets the recipient check
	// that the path is being used in the correct context.
	PathID []byte

	// ValueMsat is the payment amount in milli-satoshis that must be
	// routed. This will be used for selecting appropriate routes to use for
	// the blinded path.
	ValueMsat lnwire.MilliSatoshi

	// MinFinalCLTVExpiryDelta is the minimum CLTV delta that the recipient
	// requires for the final hop of the payment.
	//
	// NOTE that the caller is responsible for adding additional block
	// padding to this value to account for blocks being mined while the
	// payment is in-flight.
	MinFinalCLTVExpiryDelta uint32

	// BlocksUntilExpiry is the number of blocks that this blinded path
	// should remain valid for. This is a relative number of blocks. This
	// number in addition with a potential minimum cltv delta for the last
	// hop and some block padding will be the payment constraint which is
	// part of the blinded hop info. Every htlc using the provided blinded
	// hops cannot have a higher cltv delta otherwise it will get rejected
	// by the forwarding nodes or the final node.
	//
	// This number should at least be greater than the invoice expiry time
	// so that the blinded route is always valid as long as the invoice is
	// valid.
	BlocksUntilExpiry uint32

	// MinNumHops is the minimum number of hops that each blinded path
	// should be. If the number of hops in a path returned by FindRoutes is
	// less than this number, then dummy hops will be post-fixed to the
	// route.
	MinNumHops uint8

	// DefaultDummyHopPolicy holds the policy values that should be used for
	// dummy hops in the cases where it cannot be derived via other means
	// such as averaging the policy values of other hops on the path. This
	// would happen in the case where the introduction node is also the
	// introduction node. If these default policy values are used, then
	// the MaxHTLCMsat value must be carefully chosen.
	DefaultDummyHopPolicy *BlindedHopPolicy
}

BuildBlindedPathCfg defines the various resources and configuration values required to build a blinded payment path to this node.

Jump to

Keyboard shortcuts

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