lightning

package
v1.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PaymentSucceeded PaymentState = "succeeded"
	PaymentFailed    PaymentState = "failed"
	PaymentPending   PaymentState = "pending"

	NodeTypeLnd LightningNodeType = "LND"
	NodeTypeCln LightningNodeType = "CLN"

	// The cltv expiry has to be lowered in regtest to allow for lower swap timeouts
	RegtestCltv = 18
)

Variables

View Source
var ErrInvoiceNotFound = errors.New("invoice not found")
View Source
var ErrUnsupported = fmt.Errorf("lightning: %w", errors.ErrUnsupported)

Functions

func CalculateFeeLimit

func CalculateFeeLimit(invoice string, chainParams *chaincfg.Params, feeLimitPpm uint64) (uint, error)

CalculateFeeLimit calculates the fee limit of a payment in sat

func CheckInvoiceIsForOffer

func CheckInvoiceIsForOffer(invoice string, offer string) bool

func SerializeChanId

func SerializeChanId(chanId ChanId) *lightzrpc.ChannelId

func SerializeChanIds

func SerializeChanIds(chanIds []ChanId) (result []*lightzrpc.ChannelId)

Types

type AddInvoiceResponse

type AddInvoiceResponse struct {
	PaymentRequest string
	PaymentHash    []byte
}

type ChanId

type ChanId uint64

func NewChanIdFromString

func NewChanIdFromString(chanId string) (ChanId, error)

func (ChanId) String

func (chanId ChanId) String() string

func (ChanId) ToCln

func (chanId ChanId) ToCln() string

func (ChanId) ToLnd

func (chanId ChanId) ToLnd() uint64

type ChannelPoint

type ChannelPoint struct {
	FundingTxId string
	OutputIndex uint32
}

type DecodedInvoice

type DecodedInvoice struct {
	AmountSat        uint64
	PaymentHash      [32]byte
	Expiry           time.Time
	MagicRoutingHint *btcec.PublicKey
}

func DecodeBolt12Invoice

func DecodeBolt12Invoice(bolt12 string) (*DecodedInvoice, error)

func DecodeInvoice

func DecodeInvoice(invoice string, network *chaincfg.Params) (*DecodedInvoice, error)

type LightningChannel

type LightningChannel struct {
	OutboundSat uint64
	InboundSat  uint64
	Capacity    uint64
	Id          ChanId
	PeerId      string
	Point       *ChannelPoint
}

func (*LightningChannel) GetId

func (channel *LightningChannel) GetId() ChanId

type LightningInfo

type LightningInfo struct {
	Pubkey      string
	BlockHeight uint32
	Version     string
	Network     string
	Synced      bool
}

type LightningNode

type LightningNode interface {
	onchain.Wallet

	Connect() error
	Name() string
	PaymentStatus(paymentHash []byte) (*PaymentStatus, error)
	PayInvoice(ctx context.Context, invoice string, feeLimit uint, timeoutSeconds uint, channelIds []ChanId) (*PayInvoiceResponse, error)
	CreateInvoice(value uint64, preimage []byte, expiry int64, memo string) (*AddInvoiceResponse, error)
	NewAddress() (string, error)
	GetInfo() (*LightningInfo, error)
	ListChannels() ([]*LightningChannel, error)
	SetupWallet(info onchain.WalletInfo)
}

type LightningNodeType

type LightningNodeType string

type Offer

type Offer struct {
	MinAmountSat uint64
}

func DecodeOffer

func DecodeOffer(offer string) (*Offer, error)

type PayInvoiceResponse

type PayInvoiceResponse struct {
	FeeMsat uint
}

type PaymentState

type PaymentState string

type PaymentStatus

type PaymentStatus struct {
	State         PaymentState
	FailureReason string
	Preimage      string
	FeeMsat       uint64
}

type PaymentUpdate

type PaymentUpdate struct {
	IsLastUpdate bool
	Update       PaymentStatus
}

Jump to

Keyboard shortcuts

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