lightning_api

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 21 Imported by: 0

README

LightningAPI

LightningAPI is a thin wrapper around lightning APIs that are used for the agents (currently it just supports the minimal that is needed for channelchecker) We have LND gRPC and REST support for the time being.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClient

func GetClient(getData GetDataCall) (lnrpc.LightningClient, func(), error)

func GetConnection

func GetConnection(getData GetDataCall) (*grpc.ClientConn, error)

func IsMacaroonValid

func IsMacaroonValid(mac *macaroon.Macaroon) (bool, time.Duration)

Types

type ApiType

type ApiType int
const (
	LND_GRPC ApiType = iota
	LND_REST
)

func GetApiType

func GetApiType(t *int) (*ApiType, error)

type ChannelApi

type ChannelApi struct {
	Private               bool
	Active                bool
	RemotePubkey          string
	Initiator             bool
	CommitFee             uint64
	ChanId                uint64
	RemoteBalance         uint64
	LocalBalance          uint64
	Capacity              uint64
	PendingHtlcs          []HtlcApi
	TotalSatoshisSent     uint64
	TotalSatoshisReceived uint64
	NumUpdates            uint64
}

type ChannelConstraintsOverride

type ChannelConstraintsOverride struct {
	ChanReserveSat    string `json:"chan_reserve_sat,omitempty"`
	DustLimitSat      string `json:"dust_limit_sat,omitempty"`
	MaxPendingAmtMsat string `json:"max_pending_amt_msat,omitempty"`
	MinHtlcMsat       string `json:"min_htlc_msat,omitempty"`

	lnrpc.ChannelConstraints
}

type ChannelOverride

type ChannelOverride struct {
	ChanId                string `json:"chan_id,omitempty"`
	Capacity              string `json:"capacity,omitempty"`
	LocalBalance          string `json:"local_balance,omitempty"`
	RemoteBalance         string `json:"remote_balance,omitempty"`
	CommitFee             string `json:"commit_fee,omitempty"`
	CommitWeight          string `json:"commit_weight,omitempty"`
	FeePerKw              string `json:"fee_per_kw,omitempty"`
	UnsettledBalance      string `json:"unsettled_balance,omitempty"`
	TotalSatoshisSent     string `json:"total_satoshis_sent,omitempty"`
	TotalSatoshisReceived string `json:"total_satoshis_received,omitempty"`
	NumUpdates            string `json:"num_updates,omitempty"`
	// Deprecated
	LocalChanReserveSat string `json:"local_chan_reserve_sat,omitempty"`
	// Deprecated
	RemoteChanReserveSat string                      `json:"remote_chan_reserve_sat,omitempty"`
	CommitmentType       string                      `json:"commitment_type,omitempty"`
	PendingHtlcs         []*HtlcOverride             `json:"pending_htlcs,omitempty"`
	Lifetime             string                      `json:"lifetime,omitempty"`
	Uptime               string                      `json:"uptime,omitempty"`
	PushAmountSat        string                      `json:"push_amount_sat,omitempty"`
	LocalConstraints     *ChannelConstraintsOverride `json:"local_constraints,omitempty"`
	RemoteConstraints    *ChannelConstraintsOverride `json:"remote_constraints,omitempty"`

	lnrpc.Channel
}

type Channels

type Channels struct {
	Channels []*ChannelOverride `json:"channels"`
}

type ChannelsApi

type ChannelsApi struct {
	Channels []ChannelApi
}

type DescribeGraphApi

type DescribeGraphApi struct {
	Nodes    []DescribeGraphNodeApi
	Channels []DescribeGraphChannelApi
}

type DescribeGraphChannelApi

type DescribeGraphChannelApi struct {
	ChannelId   uint64
	ChanPoint   string
	Node1Pub    string
	Node2Pub    string
	Capacity    uint64
	Node1Policy *RoutingPolicyApi
	Node2Policy *RoutingPolicyApi
}

type DescribeGraphNodeApi

type DescribeGraphNodeApi struct {
	PubKey string
	Alias  string
}

type GetDataCall

type GetDataCall func() (*entities.Data, error)

type GetDoFunc

type GetDoFunc func(req *http.Request) (*http.Response, error)

type GetInfoResponseOverride

type GetInfoResponseOverride struct {
	BestHeaderTimestamp string `json:"best_header_timestamp,omitempty"`
	lnrpc.GetInfoResponse
}

type Graph

type Graph struct {
	GraphNodeOverride  []*GraphNodeOverride `json:"nodes,omitempty"`
	GraphEdgesOverride []*GraphEdgeOverride `json:"edges,omitempty"`
}

type GraphEdgeOverride

type GraphEdgeOverride struct {
	ChannelId   string                 `json:"channel_id,omitempty"`
	Capacity    string                 `json:"capacity,omitempty"`
	Node1Policy *RoutingPolicyOverride `json:"node1_policy,omitempty"`
	Node2Policy *RoutingPolicyOverride `json:"node2_policy,omitempty"`

	lnrpc.ChannelEdge
}

type GraphNodeOverride

type GraphNodeOverride struct {
	lnrpc.LightningNode
}

type HtlcApi

type HtlcApi struct {
	Amount              uint64
	Incoming            bool
	ForwardingChannel   uint64
	ForwardingHtlcIndex uint64
}

type HtlcOverride

type HtlcOverride struct {
	Amount              string `json:"amount,omitempty"`
	HashLock            string `json:"hash_lock,omitempty"`
	HtlcIndex           string `json:"htlc_index,omitempty"`
	ForwardingChannel   string `json:"forwarding_channel,omitempty"`
	ForwardingHtlcIndex string `json:"forwarding_htlc_index,omitempty"`
	lnrpc.HTLC
}

type HttpApi

type HttpApi struct {
	DoFunc GetDoFunc
	// contains filtered or unexported fields
}

func NewHttpApi

func NewHttpApi() *HttpApi

func (*HttpApi) Do

func (h *HttpApi) Do(req *http.Request) (*http.Response, error)

func (*HttpApi) GetHttpRequest

func (h *HttpApi) GetHttpRequest(getData GetDataCall) (*http.Request, *http.Transport, error)

func (*HttpApi) HttpGetChannels

func (h *HttpApi) HttpGetChannels(ctx context.Context, req *http.Request, trans *http.Transport) (*Channels, error)

func (*HttpApi) HttpGetGraph

func (h *HttpApi) HttpGetGraph(ctx context.Context, req *http.Request, trans *http.Transport, unannounced bool) (*Graph, error)

func (*HttpApi) HttpGetInfo

func (h *HttpApi) HttpGetInfo(ctx context.Context, req *http.Request, trans *http.Transport) (*GetInfoResponseOverride, error)

func (*HttpApi) SetTransport

func (h *HttpApi) SetTransport(transport *http.Transport)

type InfoApi

type InfoApi struct {
	IdentityPubkey string
	Alias          string
	Chain          string
	Network        string
}

type LightingApiCalls

type LightingApiCalls interface {
	Cleanup()
	GetInfo(ctx context.Context) (*InfoApi, error)
	GetChannels(ctx context.Context) (*ChannelsApi, error)
	DescribeGraph(ctx context.Context, unannounced bool) (*DescribeGraphApi, error)
}

func NewApi

func NewApi(apiType ApiType, getData GetDataCall) LightingApiCalls

Get new API

func NewLndGrpcLightningApi

func NewLndGrpcLightningApi(getData GetDataCall) LightingApiCalls

func NewLndRestLightningApi

func NewLndRestLightningApi(getData GetDataCall) LightingApiCalls

type LightningApi

type LightningApi struct {
}

type LndGrpcLightningApi

type LndGrpcLightningApi struct {
	Client      lnrpc.LightningClient
	CleanupFunc func()
	LightningApi
}

func (*LndGrpcLightningApi) Cleanup

func (l *LndGrpcLightningApi) Cleanup()

func (*LndGrpcLightningApi) DescribeGraph

func (l *LndGrpcLightningApi) DescribeGraph(ctx context.Context, unannounced bool) (*DescribeGraphApi, error)

func (*LndGrpcLightningApi) GetChannels

func (l *LndGrpcLightningApi) GetChannels(ctx context.Context) (*ChannelsApi, error)

func (*LndGrpcLightningApi) GetInfo

func (l *LndGrpcLightningApi) GetInfo(ctx context.Context) (*InfoApi, error)

type LndRestLightningApi

type LndRestLightningApi struct {
	Request   *http.Request
	Transport *http.Transport
	HttpApi   *HttpApi
	LightningApi
}

func (*LndRestLightningApi) Cleanup

func (l *LndRestLightningApi) Cleanup()

func (*LndRestLightningApi) DescribeGraph

func (l *LndRestLightningApi) DescribeGraph(ctx context.Context, unannounced bool) (*DescribeGraphApi, error)

func (*LndRestLightningApi) GetChannels

func (l *LndRestLightningApi) GetChannels(ctx context.Context) (*ChannelsApi, error)

func (*LndRestLightningApi) GetInfo

func (l *LndRestLightningApi) GetInfo(ctx context.Context) (*InfoApi, error)

type RoutingPolicyApi

type RoutingPolicyApi struct {
	TimeLockDelta uint32
	MinHtlc       uint64
	BaseFee       uint64
	FeeRate       uint64
	Disabled      bool
	LastUpdate    time.Time
	MaxHtlc       uint64
}

type RoutingPolicyOverride

type RoutingPolicyOverride struct {
	MinHtlc          string `json:"min_htlc,omitempty"`
	FeeBaseMsat      string `json:"fee_base_msat,omitempty"`
	FeeRateMilliMsat string `json:"fee_rate_milli_msat,omitempty"`
	MaxHtlcMsat      string `json:"max_htlc_msat,omitempty"`

	lnrpc.RoutingPolicy
}

Jump to

Keyboard shortcuts

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