lightning

package
v0.0.0-...-91dbc65 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package lightning provides utilities for interacting with a Lightning Netowrk node.

Index

Constants

View Source
const DefaultInvoiceExpiry = time.Hour * 3

DefaultInvoiceExpiry is the default time used for invoices expiration.

Variables

This section is empty.

Functions

This section is empty.

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 {
	AddInvoice(ctx context.Context, amountSat uint64) (*lnrpc.AddInvoiceResponse, error)
	DecodeInvoice(ctx context.Context, invoice string) (*lnrpc.PayReq, error)
	GetInfo(ctx context.Context) (*lnrpc.GetInfoResponse, error)
	PayInvoice(ctx context.Context, invoice *lnrpc.PayReq, feeSat int64, inflightUpdates bool) (Stream[*lnrpc.Payment], error)
	RemoteBalance(ctx context.Context) (int64, error)
	SendToLightningAddress(ctx context.Context, address string, amountSat int64) (string, error)
	SubscribeBlocks(ctx context.Context) (Stream[*chainrpc.BlockEpoch], error)
	SubscribeChannelEvents(ctx context.Context) (Stream[*lnrpc.ChannelEventUpdate], error)
	SubscribeInvoices(ctx context.Context) (Stream[*lnrpc.Invoice], error)
	SubscribePayments(ctx context.Context) (Stream[*lnrpc.Payment], error)
}

Client represents a Lightning Network node client.

func NewClient

func NewClient(config config.Lightning, torClient *http.Client) (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) AddInvoice

func (c *ClientMock) AddInvoice(ctx context.Context, amount uint64) (*lnrpc.AddInvoiceResponse, error)

AddInvoice mock.

func (*ClientMock) DecodeInvoice

func (c *ClientMock) DecodeInvoice(ctx context.Context, invoice string) (*lnrpc.PayReq, error)

DecodeInvoice mock.

func (*ClientMock) GetInfo

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

GetInfo mock.

func (*ClientMock) PayInvoice

func (c *ClientMock) PayInvoice(ctx context.Context, invoice *lnrpc.PayReq, feeSat int64, inflightUpdates bool) (Stream[*lnrpc.Payment], error)

PayInvoice mock.

func (*ClientMock) RemoteBalance

func (c *ClientMock) RemoteBalance(ctx context.Context) (int64, error)

RemoteBalance mock.

func (*ClientMock) SendToLightningAddress

func (c *ClientMock) SendToLightningAddress(ctx context.Context, address string, amountSat int64) (string, error)

SendToLightningAddress mock.

func (*ClientMock) SubscribeBlocks

func (c *ClientMock) SubscribeBlocks(ctx context.Context) (Stream[*chainrpc.BlockEpoch], error)

SubscribeBlocks mock.

func (*ClientMock) SubscribeChannelEvents

func (c *ClientMock) SubscribeChannelEvents(ctx context.Context) (Stream[*lnrpc.ChannelEventUpdate], error)

SubscribeChannelEvents mock.

func (*ClientMock) SubscribeInvoices

func (c *ClientMock) SubscribeInvoices(ctx context.Context) (Stream[*lnrpc.Invoice], error)

SubscribeInvoices mock.

func (*ClientMock) SubscribePayments

func (c *ClientMock) SubscribePayments(ctx context.Context) (Stream[*lnrpc.Payment], error)

SubscribePayments 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