lsps2

package
v0.0.0-...-9a3af51 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CleanupInterval time.Duration = time.Hour

The interval to clean unused promises and buy registrations.

View Source
var ErrNotFound = errors.New("not found")
View Source
var ErrNotImplemented = errors.New("not implemented")
View Source
var ErrOverflow = fmt.Errorf("integer overflow detected")
View Source
var ErrScidExists = errors.New("scid exists")
View Source
var RelaxPeriod time.Duration = time.Hour * 24 * 14

The relax period is a period where expired promises may still be valid, if the current chainfees are cheaper than the fees in the promise itself. It is set to ~two weeks.

View Source
var SupportedVersion uint32 = 1

Functions

func RegisterLsps2Server

func RegisterLsps2Server(s lsps0.ServiceRegistrar, l Lsps2Server)

Types

type BuyRegistration

type BuyRegistration struct {
	Id               uuid7.UUID
	LspId            string
	PeerId           string // TODO: Make peerId in the registration a byte array.
	Token            string
	Scid             lightning.ShortChannelID
	OpeningFeeParams common.OpeningFeeParams
	PaymentSizeMsat  *uint64
	Mode             OpeningMode
	ChannelPoint     *wire.OutPoint
	IsComplete       bool
}

func (*BuyRegistration) IsExpired

func (b *BuyRegistration) IsExpired() bool

type BuyRequest

type BuyRequest struct {
	Version          uint32           `json:"version"`
	OpeningFeeParams OpeningFeeParams `json:"opening_fee_params"`
	PaymentSizeMsat  *uint64          `json:"payment_size_msat,string,omitempty"`
}

type BuyResponse

type BuyResponse struct {
	JitChannelScid     string `json:"jit_channel_scid"`
	LspCltvExpiryDelta uint32 `json:"lsp_cltv_expiry_delta"`
	ClientTrustsLsp    bool   `json:"client_trusts_lsp"`
}

type ChannelOpened

type ChannelOpened struct {
	RegistrationId  uuid7.UUID
	Outpoint        *wire.OutPoint
	FeeMsat         uint64
	PaymentSizeMsat uint64
}

type CleanupService

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

func NewCleanupService

func NewCleanupService(store Lsps2Store) *CleanupService

func (*CleanupService) Start

func (c *CleanupService) Start(ctx context.Context)

Periodically cleans up unused buy registrations and promises that have expired before the relax interval.

type GetInfoRequest

type GetInfoRequest struct {
	Version uint32  `json:"version"`
	Token   *string `json:"token,omitempty"`
}

type GetInfoResponse

type GetInfoResponse struct {
	OpeningFeeParamsMenu []*OpeningFeeParams `json:"opening_fee_params_menu"`
	MinPaymentSizeMsat   uint64              `json:"min_payment_size_msat,string"`
	MaxPaymentSizeMsat   uint64              `json:"max_payment_size_msat,string"`
}

type GetVersionsRequest

type GetVersionsRequest struct {
}

type GetVersionsResponse

type GetVersionsResponse struct {
	Versions []uint32 `json:"versions"`
}

type Interceptor

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

func NewInterceptHandler

func NewInterceptHandler(
	store Lsps2Store,
	historyStore history.Store,
	openingService common.OpeningService,
	client lightning.Client,
	feeEstimator chain.FeeEstimator,
	config *InterceptorConfig,
) *Interceptor

func (*Interceptor) Intercept

func (*Interceptor) Start

func (i *Interceptor) Start(ctx context.Context)

type InterceptorConfig

type InterceptorConfig struct {
	NodeId                       []byte
	AdditionalChannelCapacitySat uint64
	MinConfs                     *uint32
	TargetConf                   uint32
	FeeStrategy                  chain.FeeStrategy
	MinPaymentSizeMsat           uint64
	MaxPaymentSizeMsat           uint64
	TimeLockDelta                uint32
	HtlcMinimumMsat              uint64
	MppTimeout                   time.Duration
}

type Lsps2Server

type Lsps2Server interface {
	GetVersions(ctx context.Context, request *GetVersionsRequest) (*GetVersionsResponse, error)
	GetInfo(ctx context.Context, request *GetInfoRequest) (*GetInfoResponse, error)
	Buy(ctx context.Context, request *BuyRequest) (*BuyResponse, error)
}

func NewLsps2Server

func NewLsps2Server(
	openingService common.OpeningService,
	nodesService common.NodesService,
	node *common.Node,
	store Lsps2Store,
) Lsps2Server

type Lsps2Store

type Lsps2Store interface {
	SavePromises(ctx context.Context, req *SavePromises) error
	RegisterBuy(ctx context.Context, req *RegisterBuy) error
	GetBuyRegistration(ctx context.Context, scid lightning.ShortChannelID) (*BuyRegistration, error)
	SetChannelOpened(ctx context.Context, channelOpened *ChannelOpened) error
	SetCompleted(ctx context.Context, registrationId uuid7.UUID) error
	RemoveUnusedExpired(ctx context.Context, before time.Time) error
}

type OpeningFeeParams

type OpeningFeeParams struct {
	MinFeeMsat           uint64 `json:"min_fee_msat,string"`
	Proportional         uint32 `json:"proportional"`
	ValidUntil           string `json:"valid_until"`
	MinLifetime          uint32 `json:"min_lifetime"`
	MaxClientToSelfDelay uint32 `json:"max_client_to_self_delay"`
	Promise              string `json:"promise"`
}

type OpeningMode

type OpeningMode int
const (
	OpeningMode_NoMppVarInvoice OpeningMode = 1
	OpeningMode_MppFixedInvoice OpeningMode = 2
)

type RegisterBuy

type RegisterBuy struct {
	LspId            string
	PeerId           string
	Scid             lightning.ShortChannelID
	OpeningFeeParams common.OpeningFeeParams
	PaymentSizeMsat  *uint64
	Mode             OpeningMode
}

type SavePromises

type SavePromises struct {
	Menu  []*common.OpeningFeeParams
	Token string
}

Jump to

Keyboard shortcuts

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