lightning

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Lightning Network primitives.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	Edge
	ChannelID     ChannelID
	LocalBalance  Satoshi
	LocalFee      FeePPM
	RemoteBalance Satoshi
	RemoteNode    Node
	Private       bool
}

Channel between local and remote node.

func (Channel) Liquidity

func (c Channel) Liquidity() float64

Liquidity percent of the channel that is local.

type ChannelID added in v0.2.1

type ChannelID uint64

ChannelID for channel.

type Channels

type Channels []Channel

Channels of node.

type Edge

type Edge struct {
	Capacity Satoshi
	Node1    PubKey
	Node2    PubKey
}

Edge between nodes in the Lightning Network.

type FeePPM

type FeePPM float64

FeePPM is the channel fee in part per million.

func (FeePPM) Rate

func (f FeePPM) Rate() float64

Rate of fee.

type Forward added in v0.2.0

type Forward struct {
	Timestamp  time.Time
	ChannelIn  ChannelID
	ChannelOut ChannelID
}

Forward routing event.

type Graph

type Graph struct {
	Nodes []Node
	Edges []Edge
}

Graph of nodes and edges of the Lightning Network.

type Info

type Info struct {
	PubKey PubKey
}

Info of a node.

type Invoice added in v0.2.1

type Invoice string

Invoice for lightning payment.

type LndClient added in v0.9.2

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

LndClient client backed by LND node.

func NewLndClient added in v0.9.2

func NewLndClient(s *lndclient.GrpcLndServices, network string) LndClient

NewLndClient backed by a single LND lightning node.

func (LndClient) AddInvoice added in v0.9.2

func (l LndClient) AddInvoice(ctx context.Context, amount Satoshi) (Invoice, error)

AddInvoice of amount.

func (LndClient) DescribeGraph added in v0.9.2

func (l LndClient) DescribeGraph(ctx context.Context) (*Graph, error)

DescribeGraph of the Lightning Network.

func (LndClient) ForwardingHistory added in v0.9.2

func (l LndClient) ForwardingHistory(ctx context.Context, since time.Time) ([]Forward, error)

ForwardingHistory of node since the time give, capped at 50,000 events.

func (LndClient) GetChannel added in v0.9.2

func (l LndClient) GetChannel(ctx context.Context, channelID ChannelID) (Channel, error)

GetChannel with ID.

func (LndClient) GetInfo added in v0.9.2

func (l LndClient) GetInfo(ctx context.Context) (*Info, error)

GetInfo of local node.

func (LndClient) ListChannels added in v0.9.2

func (l LndClient) ListChannels(ctx context.Context) (Channels, error)

ListChannels of local node.

func (LndClient) SendPayment added in v0.9.2

func (l LndClient) SendPayment(ctx context.Context, invoice Invoice, outChannelID ChannelID, lastHopPubKey PubKey, maxFee FeePPM) (Satoshi, error)

SendPayment to pay for invoice.

func (LndClient) SetFees added in v0.9.2

func (l LndClient) SetFees(ctx context.Context, channelID ChannelID, fee FeePPM, maxHTLC MilliSatoshi) error

SetFees for channel with rate in ppm.

func (LndClient) SubscribeChannelUpdates added in v0.9.2

func (l LndClient) SubscribeChannelUpdates(ctx context.Context) (<-chan Channels, <-chan error, error)

SubscribeChannelUpdates signals when a channel's liquidity changes.

type MilliSatoshi added in v0.10.0

type MilliSatoshi int64

MilliSatoshi unit of bitcoin.

type Node

type Node struct {
	PubKey    PubKey
	Alias     string
	Updated   time.Time
	Addresses []string
}

Node in the Lightning Network.

func (Node) Clearnet

func (n Node) Clearnet() bool

Clearnet is true if node has a clearnet address.

type PubKey added in v0.3.6

type PubKey string

PubKey of node.

type Satoshi

type Satoshi int64

Satoshi unit of bitcoin.

func (Satoshi) BTC

func (s Satoshi) BTC() float64

BTC value of Satoshi.

func (Satoshi) Millis added in v0.10.0

func (s Satoshi) Millis() MilliSatoshi

BTC value of Satoshi.

Jump to

Keyboard shortcuts

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