lndclient

package
v0.1.3-beta Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMalformedServerResponse is returned when the swap and/or prepay
	// invoice is malformed.
	ErrMalformedServerResponse = errors.New(
		"one or more invoices are malformed",
	)

	// ErrNoRouteToServer is returned if no quote can returned because there
	// is no route to the server.
	ErrNoRouteToServer = errors.New("no off-chain route to server")

	// PaymentResultUnknownPaymentHash is the string result returned by
	// SendPayment when the final node indicates the hash is unknown.
	PaymentResultUnknownPaymentHash = "UnknownPaymentHash"

	// PaymentResultSuccess is the string result returned by SendPayment
	// when the payment was successful.
	PaymentResultSuccess = ""

	// PaymentResultAlreadyPaid is the string result returned by SendPayment
	// when the payment was already completed in a previous SendPayment
	// call.
	PaymentResultAlreadyPaid = htlcswitch.ErrAlreadyPaid.Error()

	// PaymentResultInFlight is the string result returned by SendPayment
	// when the payment was initiated in a previous SendPayment call and
	// still in flight.
	PaymentResultInFlight = htlcswitch.ErrPaymentInFlight.Error()
)

Functions

func NewBasicClient

func NewBasicClient(lndHost, tlsPath, macDir, network string) (lnrpc.LightningClient, error)

NewBasicClient creates a new basic gRPC client to lnd. We call this client "basic" as it uses a global macaroon (by default the admin macaroon) for the entire connection, and falls back to expected defaults if the arguments aren't provided.

Types

type ChainNotifierClient

type ChainNotifierClient interface {
	RegisterBlockEpochNtfn(ctx context.Context) (
		chan int32, chan error, error)

	RegisterConfirmationsNtfn(ctx context.Context, txid *chainhash.Hash,
		pkScript []byte, numConfs, heightHint int32) (
		chan *chainntnfs.TxConfirmation, chan error, error)

	RegisterSpendNtfn(ctx context.Context,
		outpoint *wire.OutPoint, pkScript []byte, heightHint int32) (
		chan *chainntnfs.SpendDetail, chan error, error)
}

ChainNotifierClient exposes base lightning functionality.

type GrpcLndServices

type GrpcLndServices struct {
	LndServices
	// contains filtered or unexported fields
}

GrpcLndServices constitutes a set of required RPC services.

func NewLndServices

func NewLndServices(lndAddress, application, network, macaroonDir,
	tlsPath string) (*GrpcLndServices, error)

NewLndServices creates a set of required RPC services.

func (*GrpcLndServices) Close

func (s *GrpcLndServices) Close()

Close closes the lnd connection and waits for all sub server clients to finish their goroutines.

type Info

type Info struct {
	BlockHeight    uint32
	IdentityPubkey [33]byte
	Alias          string
	Network        string
}

Info contains info about the connected lnd node.

type InvoiceUpdate

type InvoiceUpdate struct {
	State   channeldb.ContractState
	AmtPaid btcutil.Amount
}

InvoiceUpdate contains a state update for an invoice.

type InvoicesClient

type InvoicesClient interface {
	SubscribeSingleInvoice(ctx context.Context, hash lntypes.Hash) (
		<-chan InvoiceUpdate, <-chan error, error)

	SettleInvoice(ctx context.Context, preimage lntypes.Preimage) error

	CancelInvoice(ctx context.Context, hash lntypes.Hash) error

	AddHoldInvoice(ctx context.Context, in *invoicesrpc.AddInvoiceData) (
		string, error)
}

InvoicesClient exposes invoice functionality.

type LightningClient

type LightningClient interface {
	PayInvoice(ctx context.Context, invoice string,
		maxFee btcutil.Amount,
		outgoingChannel *uint64) chan PaymentResult

	GetInfo(ctx context.Context) (*Info, error)

	EstimateFeeToP2WSH(ctx context.Context, amt btcutil.Amount,
		confTarget int32) (btcutil.Amount, error)

	ConfirmedWalletBalance(ctx context.Context) (btcutil.Amount, error)

	AddInvoice(ctx context.Context, in *invoicesrpc.AddInvoiceData) (
		lntypes.Hash, string, error)
}

LightningClient exposes base lightning functionality.

type LndServices

type LndServices struct {
	Client        LightningClient
	WalletKit     WalletKitClient
	ChainNotifier ChainNotifierClient
	Signer        SignerClient
	Invoices      InvoicesClient

	ChainParams *chaincfg.Params
	// contains filtered or unexported fields
}

LndServices constitutes a set of required services.

type PaymentResult

type PaymentResult struct {
	Err      error
	Preimage lntypes.Preimage
	PaidFee  btcutil.Amount
	PaidAmt  btcutil.Amount
}

PaymentResult signals the result of a payment.

type SignerClient

type SignerClient interface {
	SignOutputRaw(ctx context.Context, tx *wire.MsgTx,
		signDescriptors []*input.SignDescriptor) ([][]byte, error)
}

SignerClient exposes sign functionality.

type WalletKitClient

type WalletKitClient interface {
	DeriveNextKey(ctx context.Context, family int32) (
		*keychain.KeyDescriptor, error)

	DeriveKey(ctx context.Context, locator *keychain.KeyLocator) (
		*keychain.KeyDescriptor, error)

	NextAddr(ctx context.Context) (btcutil.Address, error)

	PublishTransaction(ctx context.Context, tx *wire.MsgTx) error

	SendOutputs(ctx context.Context, outputs []*wire.TxOut,
		feeRate lnwallet.SatPerKWeight) (*wire.MsgTx, error)

	EstimateFee(ctx context.Context, confTarget int32) (lnwallet.SatPerKWeight,
		error)
}

WalletKitClient exposes wallet functionality.

Jump to

Keyboard shortcuts

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