Documentation
¶
Overview ¶
Package lightning provides utilities for interacting with a Lightning Netowrk node.
Index ¶
- Constants
- type BlockedStreamMock
- type Client
- type ClientMock
- func (c *ClientMock) AddInvoice(ctx context.Context, amount uint64) (*lnrpc.AddInvoiceResponse, error)
- func (c *ClientMock) DecodeInvoice(ctx context.Context, invoice string) (*lnrpc.PayReq, error)
- func (c *ClientMock) GetInfo(ctx context.Context) (*lnrpc.GetInfoResponse, error)
- func (c *ClientMock) PayInvoice(ctx context.Context, invoice *lnrpc.PayReq, feeSat int64, inflightUpdates bool) (Stream[*lnrpc.Payment], error)
- func (c *ClientMock) RemoteBalance(ctx context.Context) (int64, error)
- func (c *ClientMock) SendToLightningAddress(ctx context.Context, address string, amountSat int64) (string, error)
- func (c *ClientMock) SubscribeBlocks(ctx context.Context) (Stream[*chainrpc.BlockEpoch], error)
- func (c *ClientMock) SubscribeChannelEvents(ctx context.Context) (Stream[*lnrpc.ChannelEventUpdate], error)
- func (c *ClientMock) SubscribeInvoices(ctx context.Context) (Stream[*lnrpc.Invoice], error)
- func (c *ClientMock) SubscribePayments(ctx context.Context) (Stream[*lnrpc.Payment], error)
- type Stream
Constants ¶
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.
type ClientMock ¶
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 ¶
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 ¶
SubscribeInvoices mock.
func (*ClientMock) SubscribePayments ¶
SubscribePayments mock.