Documentation
¶
Index ¶
- Variables
- func NewBasicClient(lndHost, tlsPath, macDir, network string, basicOptions ...BasicClientOption) (lnrpc.LightningClient, error)
- func UseLogger(logger btclog.Logger)
- func VersionString(version *verrpc.Version) string
- func VersionStringShort(version *verrpc.Version) string
- type BasicClientOption
- type ChainNotifierClient
- type DialerFunc
- type GrpcLndServices
- type Info
- type InvoiceUpdate
- type InvoicesClient
- type LightningClient
- type LndServices
- type LndServicesConfig
- type PaymentResult
- type PaymentStatus
- type RouterClient
- type SendPaymentRequest
- type SignerClient
- type VersionerClient
- type WalletKitClient
Constants ¶
This section is empty.
Variables ¶
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 = channeldb.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 = channeldb.ErrPaymentInFlight.Error() )
var ( // ErrVersionCheckNotImplemented is the error that is returned if the // version RPC is not implemented in lnd. This means the version of lnd // is lower than v0.10.0-beta. ErrVersionCheckNotImplemented = errors.New("version check not " + "implemented, need minimum lnd version of v0.10.0-beta") // ErrVersionIncompatible is the error that is returned if the connected // lnd instance is not supported. ErrVersionIncompatible = errors.New("version incompatible") // ErrBuildTagsMissing is the error that is returned if the // connected lnd instance does not have all built tags activated that // are required. ErrBuildTagsMissing = errors.New("build tags missing") )
Functions ¶
func NewBasicClient ¶
func NewBasicClient(lndHost, tlsPath, macDir, network string, basicOptions ...BasicClientOption) ( lnrpc.LightningClient, error)
NewBasicClient creates a new basic gRPC client to lnd. We call this client "basic" as it falls back to expected defaults if the arguments aren't provided.
func UseLogger ¶
UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.
func VersionString ¶
VersionString returns a nice, human readable string of a version returned by the VersionerClient, including all build tags.
func VersionStringShort ¶
VersionStringShort returns a nice, human readable string of a version returned by the VersionerClient.
Types ¶
type BasicClientOption ¶
type BasicClientOption func(*basicClientOptions)
BasicClientOption is a functional option argument that allows adding arbitrary lnd basic client configuration overrides, without forcing existing users of NewBasicClient to update their invocation. These are always processed in order, with later options overriding earlier ones.
func MacFilename ¶
func MacFilename(macFilename string) BasicClientOption
MacFilename is a basic client option that sets the name of the macaroon file to use.
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 DialerFunc ¶
DialerFunc is a function that is used as grpc.WithContextDialer().
type GrpcLndServices ¶
type GrpcLndServices struct { LndServices // contains filtered or unexported fields }
GrpcLndServices constitutes a set of required RPC services.
func NewLndServices ¶
func NewLndServices(cfg *LndServicesConfig) (*GrpcLndServices, error)
NewLndServices creates creates a connection to the given lnd instance and 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 Uris []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) // ListTransactions returns all known transactions of the backing lnd // node. ListTransactions(ctx context.Context) ([]*wire.MsgTx, error) // ChannelBackup retrieves the backup for a particular channel. The // backup is returned as an encrypted chanbackup.Single payload. ChannelBackup(context.Context, wire.OutPoint) ([]byte, error) // ChannelBackups retrieves backups for all existing pending open and // open channels. The backups are returned as an encrypted // chanbackup.Multi payload. ChannelBackups(ctx context.Context) ([]byte, error) }
LightningClient exposes base lightning functionality.
type LndServices ¶
type LndServices struct { Client LightningClient WalletKit WalletKitClient ChainNotifier ChainNotifierClient Signer SignerClient Invoices InvoicesClient Router RouterClient Versioner VersionerClient ChainParams *chaincfg.Params NodeAlias string NodePubkey [33]byte Version *verrpc.Version // contains filtered or unexported fields }
LndServices constitutes a set of required services.
type LndServicesConfig ¶
type LndServicesConfig struct { // LndAddress is the network address (host:port) of the lnd node to // connect to. LndAddress string // Network is the bitcoin network we expect the lnd node to operate on. Network string // MacaroonDir is the directory where all lnd macaroons can be found. MacaroonDir string // TLSPath is the path to lnd's TLS certificate file. TLSPath string // CheckVersion is the minimum version the connected lnd node needs to // be in order to be compatible. The node will be checked against this // when connecting. If no version is supplied, the default minimum // version will be used. CheckVersion *verrpc.Version // Dialer is an optional dial function that can be passed in if the // default lncfg.ClientAddressDialer should not be used. Dialer DialerFunc }
LndServicesConfig holds all configuration settings that are needed to connect to an lnd node.
type PaymentResult ¶
type PaymentResult struct { Err error Preimage lntypes.Preimage PaidFee btcutil.Amount PaidAmt btcutil.Amount }
PaymentResult signals the result of a payment.
type PaymentStatus ¶
type PaymentStatus struct { State lnrpc.Payment_PaymentStatus // FailureReason is the reason why the payment failed. Only set when // State is Failed. FailureReason lnrpc.PaymentFailureReason Preimage lntypes.Preimage Fee lnwire.MilliSatoshi Value lnwire.MilliSatoshi InFlightAmt lnwire.MilliSatoshi InFlightHtlcs int }
PaymentStatus describe the state of a payment.
func (PaymentStatus) String ¶
func (p PaymentStatus) String() string
type RouterClient ¶
type RouterClient interface { // SendPayment attempts to route a payment to the final destination. The // call returns a payment update stream and an error stream. SendPayment(ctx context.Context, request SendPaymentRequest) ( chan PaymentStatus, chan error, error) // TrackPayment picks up a previously started payment and returns a // payment update stream and an error stream. TrackPayment(ctx context.Context, hash lntypes.Hash) ( chan PaymentStatus, chan error, error) }
RouterClient exposes payment functionality.
type SendPaymentRequest ¶
type SendPaymentRequest struct { // Invoice is an encoded payment request. The individual payment // parameters Target, Amount, PaymentHash, FinalCLTVDelta and RouteHints // are only processed when the Invoice field is empty. Invoice string MaxFee btcutil.Amount MaxCltv *int32 OutgoingChannel *uint64 Timeout time.Duration // Target is the node in which the payment should be routed towards. Target route.Vertex // Amount is the value of the payment to send through the network in // satoshis. Amount btcutil.Amount // PaymentHash is the r-hash value to use within the HTLC extended to // the first hop. PaymentHash [32]byte // FinalCLTVDelta is the CTLV expiry delta to use for the _final_ hop // in the route. This means that the final hop will have a CLTV delta // of at least: currentHeight + FinalCLTVDelta. FinalCLTVDelta uint16 // RouteHints represents the different routing hints that can be used to // assist a payment in reaching its destination successfully. These // hints will act as intermediate hops along the route. // // NOTE: This is optional unless required by the payment. When providing // multiple routes, ensure the hop hints within each route are chained // together and sorted in forward order in order to reach the // destination successfully. RouteHints [][]zpay32.HopHint // LastHopPubkey is the pubkey of the last hop of the route taken // for this payment. If empty, any hop may be used. LastHopPubkey *route.Vertex // MaxParts is the maximum number of partial payments that may be used // to complete the full amount. MaxParts uint32 }
SendPaymentRequest defines the payment parameters for a new payment.
type SignerClient ¶
type SignerClient interface { SignOutputRaw(ctx context.Context, tx *wire.MsgTx, signDescriptors []*input.SignDescriptor) ([][]byte, error) // ComputeInputScript generates the proper input script for P2WPKH // output and NP2WPKH outputs. This method only requires that the // `Output`, `HashType`, `SigHashes` and `InputIndex` fields are // populated within the sign descriptors. ComputeInputScript(ctx context.Context, tx *wire.MsgTx, signDescriptors []*input.SignDescriptor) ([]*input.Script, error) // SignMessage signs a message with the key specified in the key // locator. The returned signature is fixed-size LN wire format encoded. SignMessage(ctx context.Context, msg []byte, locator keychain.KeyLocator) ([]byte, error) // VerifyMessage verifies a signature over a message using the public // key provided. The signature must be fixed-size LN wire format // encoded. VerifyMessage(ctx context.Context, msg, sig []byte, pubkey [33]byte) ( bool, error) // Diffie-Hellman key derivation between the ephemeral public key and // the key specified by the key locator (or the node's identity private // key if no key locator is specified): // // P_shared = privKeyNode * ephemeralPubkey // // The resulting shared public key is serialized in the compressed // format and hashed with SHA256, resulting in a final key length of 256 // bits. DeriveSharedKey(ctx context.Context, ephemeralPubKey *btcec.PublicKey, keyLocator *keychain.KeyLocator) ([32]byte, error) }
SignerClient exposes sign functionality.
type VersionerClient ¶
type VersionerClient interface { // GetVersion returns the version and build information of the lnd // daemon. GetVersion(ctx context.Context) (*verrpc.Version, error) }
VersionerClient exposes the version of lnd.
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 chainfee.SatPerKWeight) (*wire.MsgTx, error) EstimateFee(ctx context.Context, confTarget int32) (chainfee.SatPerKWeight, error) }
WalletKitClient exposes wallet functionality.