lightning

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MaxForwardingEvents is the maximum number of forwarding events to get per RPC call.
	MaxForwardingEvents = 50_000
)

Variables

This section is empty.

Functions

func ParseChannelPoint added in v0.2.0

func ParseChannelPoint(channelPoint string) (*lnrpc.ChannelPoint, error)

ParseChannelPoint parses a channel point string into the object used by LND.

Types

type BlockedStreamMock

type BlockedStreamMock[T any] struct{}

BlockedStreamMock is a stream of events that blocks to let the test execution end without failures.

func (BlockedStreamMock[T]) Recv

func (s BlockedStreamMock[T]) Recv() (T, error)

Recv blocks forever.

type Client

type Client interface {
	BatchOpenChannel(ctx context.Context, req *lnrpc.BatchOpenChannelRequest) (string, error)
	CloseChannel(ctx context.Context, req *lnrpc.CloseChannelRequest) (Stream[*lnrpc.CloseStatusUpdate], error)
	ClosedChannels(ctx context.Context) ([]*lnrpc.ChannelCloseSummary, error)
	ConnectPeer(ctx context.Context, publicKey string, addresses []string) error
	DescribeGraph(ctx context.Context) (*lnrpc.ChannelGraph, error)
	EstimateTxFee(ctx context.Context, targetConf int32) (uint64, error)
	EstimateRouteFee(ctx context.Context, publicKey string) (*routerrpc.RouteFeeResponse, error)
	GetChanInfo(ctx context.Context, channelID uint64) (*lnrpc.ChannelEdge, error)
	GetInfo(ctx context.Context) (*lnrpc.GetInfoResponse, error)
	ListChannels(ctx context.Context) ([]*lnrpc.Channel, error)
	ListForwards(ctx context.Context, startTime, endTime uint64, indexOffset uint32) (*lnrpc.ForwardingHistoryResponse, error)
	ListPeers(ctx context.Context) ([]*lnrpc.Peer, error)
	QueryRoute(ctx context.Context, publicKey string) (*lnrpc.QueryRoutesResponse, error)
	UpdateChannelPolicy(ctx context.Context, channelPoint string, baseFeeMsat, feeRatePPM, maxHTLCMsat, timeLockDelta uint64) error
	WalletBalance(ctx context.Context, minConf int32) (*lnrpc.WalletBalanceResponse, error)
}

Client represents a Lightning Network node client.

func NewClient

func NewClient(config config.Lightning) (Client, error)

NewClient returns a new client that communicates with a Lightning node.

type ClientMock

type ClientMock struct {
	mock.Mock
}

ClientMock is a mocked implementation of a lightning client.

func NewClientMock

func NewClientMock() *ClientMock

NewClientMock returns a mocked lightning network node client.

func (*ClientMock) BatchOpenChannel

func (c *ClientMock) BatchOpenChannel(ctx context.Context, req *lnrpc.BatchOpenChannelRequest) (string, error)

BatchOpenChannel mock.

func (*ClientMock) CloseChannel

CloseChannel mock.

func (*ClientMock) ClosedChannels

func (c *ClientMock) ClosedChannels(ctx context.Context) ([]*lnrpc.ChannelCloseSummary, error)

ClosedChannels mock.

func (*ClientMock) ConnectPeer

func (c *ClientMock) ConnectPeer(ctx context.Context, publicKey string, addresses []string) error

ConnectPeer mock.

func (*ClientMock) DescribeGraph

func (c *ClientMock) DescribeGraph(ctx context.Context) (*lnrpc.ChannelGraph, error)

DescribeGraph mock.

func (*ClientMock) EstimateRouteFee

func (c *ClientMock) EstimateRouteFee(ctx context.Context, publicKey string) (*routerrpc.RouteFeeResponse, error)

EstimateRouteFee mock.

func (*ClientMock) EstimateTxFee

func (c *ClientMock) EstimateTxFee(ctx context.Context, targetConf int32) (uint64, error)

EstimateTxFee mock.

func (*ClientMock) GetChanInfo added in v0.2.0

func (c *ClientMock) GetChanInfo(ctx context.Context, channelID uint64) (*lnrpc.ChannelEdge, error)

GetChanInfo mock.

func (*ClientMock) GetInfo

func (c *ClientMock) GetInfo(ctx context.Context) (*lnrpc.GetInfoResponse, error)

GetInfo mock.

func (*ClientMock) ListChannels

func (c *ClientMock) ListChannels(ctx context.Context) ([]*lnrpc.Channel, error)

ListChannels mock.

func (*ClientMock) ListForwards

func (c *ClientMock) ListForwards(
	ctx context.Context,
	startTime,
	endTime uint64,
	indexOffset uint32,
) (*lnrpc.ForwardingHistoryResponse, error)

ListForwards mock.

func (*ClientMock) ListPeers

func (c *ClientMock) ListPeers(ctx context.Context) ([]*lnrpc.Peer, error)

ListPeers mock.

func (*ClientMock) QueryRoute

func (c *ClientMock) QueryRoute(ctx context.Context, publicKey string) (*lnrpc.QueryRoutesResponse, error)

QueryRoute mock.

func (*ClientMock) UpdateChannelPolicy added in v0.2.0

func (c *ClientMock) UpdateChannelPolicy(
	ctx context.Context, channelPoint string, baseFeeMsat, feeRatePPM, maxHTLCMsat, timeLockDelta uint64,
) error

UpdateChannelPolicy mock.

func (*ClientMock) WalletBalance

func (c *ClientMock) WalletBalance(ctx context.Context, minConf int32) (*lnrpc.WalletBalanceResponse, error)

WalletBalance mock.

type Stream

type Stream[T any] interface {
	Recv() (T, error)
}

Stream implements a method that receives updates from a stream.

Jump to

Keyboard shortcuts

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