lnd

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const MAXEVENTS int = 50000

MAXEVENTS is used to set the maximum events in ForwardingHistoryRequest. It's also used to check if we need to request more.

Variables

This section is empty.

Functions

func ImportNodeInfo added in v0.10.0

func ImportNodeInfo(client lnrpc.LightningClient, db *sqlx.DB, nodeSettings commons.ManagedNodeSettings) error

ImportNodeInfo imports node information about all channels if they don't already have

func ImportRoutingPolicies

func ImportRoutingPolicies(client lnrpc.LightningClient, db *sqlx.DB, nodeSettings commons.ManagedNodeSettings) error

ImportRoutingPolicies imports routing policy information about all channels if they don't already have

func ImportTransactions

func ImportTransactions(ctx context.Context, client lnrpc.LightningClient, db *sqlx.DB, nodeId int) error

func SubscribeAndStoreChannelEvents

func SubscribeAndStoreChannelEvents(ctx context.Context, client lndClientSubscribeChannelEvent, db *sqlx.DB,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}) error

SubscribeAndStoreChannelEvents Subscribes to channel events from LND and stores them in the database as a time series

func SubscribeAndStoreChannelGraph

func SubscribeAndStoreChannelGraph(ctx context.Context, client subscribeChannelGrpahClient, db *sqlx.DB,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}) error

SubscribeAndStoreChannelGraph Subscribes to channel updates

func SubscribeAndStoreHtlcEvents

func SubscribeAndStoreHtlcEvents(ctx context.Context, router routerrpc.RouterClient, db *sqlx.DB,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}) error

SubscribeAndStoreHtlcEvents subscribes to HTLC events from LND and stores them in the database as time series. NB: LND has marked HTLC event streaming as experimental. Delivery is not guaranteed, so dataset might not be complete HTLC events is primarily used to diagnose how good a channel / node is. And if the channel allocation should change.

func SubscribeAndStoreInvoices added in v0.4.6

func SubscribeAndStoreInvoices(ctx context.Context, client invoicesClient, db *sqlx.DB,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}) error

func SubscribeAndStorePayments added in v0.4.6

func SubscribeAndStorePayments(ctx context.Context, client lightningClient_ListPayments, db *sqlx.DB,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}, opt *PayOptions) error

func SubscribeAndStoreTransactions

func SubscribeAndStoreTransactions(ctx context.Context, client lnrpc.LightningClient, db *sqlx.DB,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}) error

SubscribeAndStoreTransactions Subscribes to on-chain transaction events from LND and stores them in the database as a time series. It will also import unregistered transactions on startup.

func SubscribeForwardingEvents

func SubscribeForwardingEvents(ctx context.Context, client lightningClientForwardingHistory, db *sqlx.DB,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}, opt *FwhOptions) error

SubscribeForwardingEvents repeatedly requests forwarding history starting after the last forwarding stored in the database and stores new forwards.

func SubscribePeerEvents added in v0.8.20

func SubscribePeerEvents(ctx context.Context, client peerEventsClient,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}) error

func UpdateInFlightPayments added in v0.8.19

func UpdateInFlightPayments(ctx context.Context, client lightningClient_ListPayments, db *sqlx.DB,
	nodeSettings commons.ManagedNodeSettings, eventChannel chan interface{}, opt *PayOptions) error

Types

type FwhOptions

type FwhOptions struct {
	MaxEvents *int
	Tick      <-chan time.Time
}

FwhOptions allows the caller to adjust the number of forwarding events can be requested at a time and set a custom time interval between requests.

type Invoice added in v0.4.6

type Invoice struct {

	/*
	   An optional memo to attach along with the invoice. Used for record keeping
	   purposes for the invoice's creator, and will also be set in the description
	   field of the encoded payment request if the description_hash field is not
	   being used.
	*/
	Memo string `db:"memo" json:"memo"`

	/*
	   The hex-encoded preimage (32 byte) which will allow settling an incoming
	   HTLC payable to this preimage.
	*/
	RPreimage string `db:"r_preimage" json:"r_preimage"`

	/*
	   The hash of the preimage.
	*/
	RHash string `db:"r_hash" json:"r_hash"`

	// The value of the invoice
	ValueMsat int64 `db:"value_msat" json:"value_msat"`

	// When this invoice was created
	CreationDate time.Time `db:"creation_date" json:"creation_date"`

	// When this invoice was settled
	SettleDate time.Time `db:"settle_date" json:"settle_date"`

	/*
	   A bare-bones invoice for a payment within the Lightning Network. With the
	   details of the invoice, the sender has all the data necessary to send a
	   payment to the recipient.
	*/
	PaymentRequest string `db:"payment_request" json:"payment_request"`

	/*
	   A bare-bones invoice for a payment within the Lightning Network. With the
	   details of the invoice, the sender has all the data necessary to send a
	   payment to the recipient.
	*/
	Destination string `db:"destination_pub_key" json:"destination_pub_key"`

	/*
	   Hash (SHA-256) of a description of the payment. Used if the description of
	   payment (memo) is too long to naturally fit within the description field
	   of an encoded payment request.
	*/
	DescriptionHash []byte `db:"description_hash" json:"description_hash"`

	// Payment request expiry time in seconds. Default is 3600 (1 hour).
	Expiry int64 `db:"expiry" json:"expiry"`

	// Fallback on-chain address.
	FallbackAddr string `db:"fallback_addr" json:"fallback_addr"`

	// Delta to use for the time-lock of the CLTV extended to the final hop.
	CltvExpiry uint64 `db:"cltv_expiry" json:"cltv_expiry"`

	/*
	   Route hints that can each be individually used to assist in reaching the
	   invoice's destination.
	*/
	//repeated RouteHint route_hints = 14;
	RouteHints []byte `db:"route_hints" json:"route_hints"`

	// Whether this invoice should include routing hints for private channels.
	Private bool `db:"private" json:"private"`

	/*
	   The "add" index of this invoice. Each newly created invoice will increment
	   this index making it monotonically increasing. Callers to the
	   SubscribeInvoices call can use this to instantly get notified of all added
	   invoices with an add_index greater than this one.
	*/
	AddIndex uint64 `db:"add_index" json:"add_index"`

	/*
	   The "settle" index of this invoice. Each newly settled invoice will
	   increment this index making it monotonically increasing. Callers to the
	   SubscribeInvoices call can use this to instantly get notified of all
	   settled invoices with an settle_index greater than this one.
	*/
	SettleIndex uint64 `db:"settle_index" json:"settle_index"`

	/*
	   The amount that was accepted for this invoice, in satoshis. This will ONLY
	   be set if this invoice has been settled. We provide this field as if the
	   invoice was created with a zero value, then we need to record what amount
	   was ultimately accepted. Additionally, it's possible that the sender paid
	   MORE that was specified in the original invoice. So we'll record that here
	   as well.
	*/
	AmtPaidSat int64 `db:"amt_paid_sat" json:"amt_paid_sat"`

	/*
	   The amount that was accepted for this invoice, in millisatoshis. This will
	   ONLY be set if this invoice has been settled. We provide this field as if
	   the invoice was created with a zero value, then we need to record what
	   amount was ultimately accepted. Additionally, it's possible that the sender
	   paid MORE that was specified in the original invoice. So we'll record that
	   here as well.
	*/
	AmtPaidMsat int64 `db:"amt_paid_msat" json:"amt_paid_msat"`

	InvoiceState string `db:"invoice_state" json:"invoice_state"`

	// List of HTLCs paying to this invoice [EXPERIMENTAL].
	Htlcs []byte `db:"htlcs" json:"htlcs"`

	// List of features advertised on the invoice.
	//map<uint32, Feature> features = 24;
	// features []*lnrpc.Feature
	Features []byte `db:"features" json:"features"`

	/*
	   Indicates if this invoice was a spontaneous payment that arrived via keysend
	   [EXPERIMENTAL].
	*/
	IsKeysend bool `db:"is_keysend" json:"is_keysend"`

	/*
	   The payment address of this invoice. This value will be used in MPP
	   payments, and also for newer invoices that always require the MPP payload
	   for added end-to-end security.
	*/
	PaymentAddr string `db:"payment_addr" json:"payment_addr"`

	/*
	   Signals whether this is an AMP invoice.
	*/
	IsAmp bool `db:"is_amp" json:"is_amp"`

	/*
	   [EXPERIMENTAL]:
	   Maps a 32-byte hex-encoded set ID to the sub-invoice AMP state for the
	   given set ID. This field is always populated for AMP invoices, and can be
	   used alongside LookupInvoice to obtain the HTLC information related to a
	   given sub-invoice.
	*/
	//map<string, AMPInvoiceState> amp_invoice_state = 28;
	AmpInvoiceState []byte    `db:"amp_invoice_state" json:"amp_invoice_state"`
	NodeId          int       `db:"node_id" json:"nodeId"`
	CreatedOn       time.Time `db:"created_on" json:"created_on"`
	UpdatedOn       time.Time `db:"updated_on" json:"updated_on"`
}

type PayOptions added in v0.4.6

type PayOptions struct {
	Tick <-chan time.Time
}

PayOptions allows the caller to adjust the number of payments can be requested at a time and set a custom time interval between requests.

type Payment added in v0.4.6

type Payment struct {
	PaymentIndex      uint64 `json:"payment_index" db:"payment_index"`
	PaymentHash       string `json:"payment_hash" db:"payment_hash"`
	PaymentPreimage   string `json:"payment_preimage" db:"payment_preimage"`
	PaymentRequest    string `json:"payment_request" db:"payment_request"`
	Status            string `json:"status" db:"status"`
	ValueMsat         int64  `json:"value_msat" db:"value_msat"`
	FeeMsat           int64  `json:"fee_msat" db:"fee_msat"`
	Htlcs             []byte `json:"htlcs" db:"htlcs"`
	FailureReason     string `json:"failure_reason" db:"failure_reason"`
	CreationTimeNs    int64  `json:"creation_time_ns" db:"creation_time_ns"`
	CreationTimestamp int64  `json:"creation_timestamp" db:"creation_timestamp"`
}

Jump to

Keyboard shortcuts

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