common

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: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNodeNotFound = errors.New("node not found")
View Source
var ExtraFeeTlvType tlv.Type = 65536

Functions

func NewExtraFeeRecord

func NewExtraFeeRecord(feeMsat *uint64) tlv.Record

Types

type CombinedHandler

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

func NewCombinedHandler

func NewCombinedHandler(handlers ...InterceptHandler) *CombinedHandler

func (*CombinedHandler) Intercept

type InterceptAction

type InterceptAction int
const (
	INTERCEPT_RESUME              InterceptAction = 0
	INTERCEPT_RESUME_WITH_ONION   InterceptAction = 1
	INTERCEPT_FAIL_HTLC_WITH_CODE InterceptAction = 2
	INTERCEPT_IGNORE              InterceptAction = 3
)

type InterceptFailureCode

type InterceptFailureCode uint16
var (
	FAILURE_TEMPORARY_CHANNEL_FAILURE            InterceptFailureCode = 0x1007
	FAILURE_AMOUNT_BELOW_MINIMUM                 InterceptFailureCode = 0x100B
	FAILURE_INCORRECT_CLTV_EXPIRY                InterceptFailureCode = 0x100D
	FAILURE_TEMPORARY_NODE_FAILURE               InterceptFailureCode = 0x2002
	FAILURE_UNKNOWN_NEXT_PEER                    InterceptFailureCode = 0x400A
	FAILURE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS InterceptFailureCode = 0x400F
)

type InterceptHandler

type InterceptHandler interface {
	Intercept(req InterceptRequest) InterceptResult
}

type InterceptRequest

type InterceptRequest struct {
	// Identifier that uniquely identifies this htlc.
	// For cln, that's hash of the next onion or the shared secret.
	Identifier         string
	Scid               lightning.ShortChannelID
	PaymentHash        []byte
	IncomingAmountMsat uint64
	OutgoingAmountMsat uint64
	IncomingExpiry     uint32
	OutgoingExpiry     uint32
}

func (*InterceptRequest) HtlcId

func (r *InterceptRequest) HtlcId() string

func (*InterceptRequest) PaymentId

func (r *InterceptRequest) PaymentId() string

func (*InterceptRequest) String

func (r *InterceptRequest) String() string

type InterceptResult

type InterceptResult struct {
	Action             InterceptAction
	FailureCode        InterceptFailureCode
	Destination        []byte
	AmountMsat         uint64
	FeeMsat            *uint64
	TotalAmountMsat    uint64
	ChannelPoint       *wire.OutPoint
	Scid               lightning.ShortChannelID
	PaymentSecret      []byte
	UseLegacyOnionBlob bool
}

func (*InterceptResult) String

func (r *InterceptResult) String() string

type Node

type Node struct {
	NodeId              []byte
	Client              lightning.Client
	NodeConfig          *config.NodeConfig
	PrivateKey          *btcec.PrivateKey
	PublicKey           *btcec.PublicKey
	EciesPrivateKey     *ecies.PrivateKey
	EciesPublicKey      *ecies.PublicKey
	OpenChannelReqGroup singleflight.Group
	Tokens              []string
}

type NodesService

type NodesService interface {
	GetNode(token string) (*Node, error)
	GetNodes() []*Node
}

func NewNodesService

func NewNodesService(nodes []*Node) (NodesService, error)

type OpeningFeeParams

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

type OpeningFeeParamsSetting

type OpeningFeeParamsSetting struct {
	Validity time.Duration
	Params   *OpeningFeeParams
}

type OpeningService

type OpeningService interface {
	GetFeeParamsMenu(token string, privateKey *btcec.PrivateKey) ([]*OpeningFeeParams, error)
	ValidateOpeningFeeParams(params *OpeningFeeParams, publicKey *btcec.PublicKey) bool
	IsCurrentChainFeeCheaper(token string, params *OpeningFeeParams) bool
}

func NewOpeningService

func NewOpeningService(
	store OpeningStore,
	nodesService NodesService,
) OpeningService

type OpeningStore

type OpeningStore interface {
	GetFeeParamsSettings(token string) ([]*OpeningFeeParamsSetting, error)
}

Jump to

Keyboard shortcuts

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