Options
All
  • Public
  • Public/Protected
  • All
Menu

A class representing a client to interact with lnd.

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Object literals

Constructors

constructor

  • new LndClient(__namedParameters: { config: { certpath: string; cltvdelta: number; disable: boolean; host: string; macaroonpath: string; nomacaroons: boolean; port: number }; currency: string; logger: Logger }): LndClient
  • Creates an lnd client.

    Parameters

    • __namedParameters: { config: { certpath: string; cltvdelta: number; disable: boolean; host: string; macaroonpath: string; nomacaroons: boolean; port: number }; currency: string; logger: Logger }
      • config: { certpath: string; cltvdelta: number; disable: boolean; host: string; macaroonpath: string; nomacaroons: boolean; port: number }
        • certpath: string
        • cltvdelta: number
        • disable: boolean
        • host: string
        • macaroonpath: string
        • nomacaroons: boolean
        • port: number
      • currency: string
      • logger: Logger

    Returns LndClient

Properties

Private Optional chainIdentifier

chainIdentifier: undefined | string

The identifier for the chain this lnd instance is using in the format [chain]-[network] like "bitcoin-testnet"

Private Optional channelBackupSubscription

channelBackupSubscription: ClientReadableStream<ChanBackupSnapshot>

config

Private credentials

credentials: ChannelCredentials

currency

currency: string

Protected disable

disable: boolean

Readonly finalLock

finalLock: number

Private Optional identityPubKey

identityPubKey: undefined | string

The identity pub key for this lnd instance.

Private Optional initRetryTimeout

initRetryTimeout: NodeJS.Timeout

Private Optional initWalletResolve

initWalletResolve: undefined | ((value: boolean) => void)

Private invoiceSubscriptions

invoiceSubscriptions: Map<string, ClientReadableStream<Invoice>> = new Map<string, ClientReadableStream<lndrpc.Invoice>>()

Private Optional invoices

invoices: InvoicesClient

Private Optional lightning

lightning: LightningClient

logger

logger: Logger

Private Optional macaroonpath

macaroonpath: undefined | string

The path to the lnd admin macaroon, will be undefined if nomacaroons is enabled

Private maxChannelInboundAmount

maxChannelInboundAmount: number = 0

Private maxChannelOutboundAmount

maxChannelOutboundAmount: number = 0

Private maxClientWaitTime

maxClientWaitTime: number = BASE_MAX_CLIENT_WAIT_TIME

The maximum time to wait for a client to be ready for making grpc calls, can be used for exponential backoff.

Private meta

meta: Metadata = new grpc.Metadata()

Protected Optional reconnectionTimer

reconnectionTimer: NodeJS.Timer

Private Optional router

router: RouterClient

Protected status

status: ClientStatus = ClientStatus.NotInitialized

Private totalInboundAmount

totalInboundAmount: number = 0

Private totalOutboundAmount

totalOutboundAmount: number = 0

Readonly type

type: Lnd = SwapClientType.Lnd

Private uri

uri: string

Private Optional urisList

urisList: string[]

List of client's public listening uris that are advertised to the network

Optional walletPassword

walletPassword: undefined | string

Private Optional walletUnlocker

walletUnlocker: WalletUnlockerClient

Private Optional watchMacaroonResolve

watchMacaroonResolve: undefined | ((value: boolean) => void)

Static Readonly RECONNECT_INTERVAL

RECONNECT_INTERVAL: 5000 = 5000

Time in milliseconds between attempts to recheck connectivity to the client.

Accessors

chain

  • get chain(): undefined | string

label

  • get label(): string

minutesPerBlock

  • get minutesPerBlock(): number

pubKey

  • get pubKey(): undefined | string

uris

  • get uris(): undefined | string[]

Methods

Private addHoldInvoice

  • addHoldInvoice(request: AddHoldInvoiceRequest): Promise<AddHoldInvoiceResp>

addInvoice

  • addInvoice(__namedParameters: { expiry: number; rHash: string; units: number }): Promise<void>

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Private awaitWalletInit

  • awaitWalletInit(): Promise<void>
  • Waits for the lnd wallet to be initialized and for its macaroons to be created then attempts to verify the connection to lnd.

    Returns Promise<void>

Private buildSendRequest

  • buildSendRequest(__namedParameters: { amount: number; cltvLimit: undefined | number; destination: string; finalCltvDelta: number; rHash: string }): SendPaymentRequest
  • Builds a lndrpc.SendRequest

    Parameters

    • __namedParameters: { amount: number; cltvLimit: undefined | number; destination: string; finalCltvDelta: number; rHash: string }
      • amount: number
      • cltvLimit: undefined | number
      • destination: string
      • finalCltvDelta: number
      • rHash: string

    Returns SendPaymentRequest

canRouteToNode

  • canRouteToNode(_destination: string): Promise<boolean>

Private cancelInvoice

  • cancelInvoice(request: CancelInvoiceMsg): Promise<CancelInvoiceResp>

changePassword

  • changePassword(oldPassword: string, newPassword: string): Promise<void>

channelBalance

close

  • close(): void

closeChannel

  • closeChannel(__namedParameters: { fee: number; force: boolean; remoteIdentifier: undefined | string }): Promise<string[]>
  • Closes any payment channels with a specified node.

    Parameters

    • __namedParameters: { fee: number; force: boolean; remoteIdentifier: undefined | string }
      • fee: number
      • force: boolean
      • remoteIdentifier: undefined | string

    Returns Promise<string[]>

closeChannelSync

  • closeChannelSync(fundingTxId: string, outputIndex: number, force: boolean, fee?: number): Promise<string>
  • A synchronous helper method for the closeChannel call

    Parameters

    • fundingTxId: string
    • outputIndex: number
    • force: boolean
    • Default value fee: number = 0

    Returns Promise<string>

connectPeer

  • connectPeer(pubkey: string, address: string): Promise<ConnectPeerResponse>
  • Connects to another lnd node.

    Parameters

    • pubkey: string
    • address: string

    Returns Promise<ConnectPeerResponse>

Private connectPeerAddresses

  • connectPeerAddresses(peerListeningUris: string[]): Promise<boolean>
  • Tries to connect to a given list of a peer's uris in sequential order.

    Parameters

    • peerListeningUris: string[]

    Returns Promise<boolean>

    true when successful, otherwise false.

deposit

  • deposit(): Promise<string>

Protected disconnect

  • disconnect(): void

emit

  • emit(event: "connectionVerified", swapClientInfo: SwapClientInfo): boolean
  • emit(event: "htlcAccepted", rHash: string, amount: number): boolean
  • emit(event: "channelBackup", channelBackup: Uint8Array): boolean
  • emit(event: "channelBackupEnd"): boolean
  • emit(event: "locked"): boolean
  • emit(event: "initialized"): boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

exportAllChannelBackup

  • exportAllChannelBackup(): Promise<Uint8Array>

getClosedChannels

  • getClosedChannels(): Promise<ClosedChannelsResponse>

getHeight

  • getHeight(): Promise<number>

getInfo

  • getInfo(): Promise<GetInfoResponse>
  • Returns general information concerning the lightning node including it’s identity pubkey, alias, the chains it is connected to, and information concerning the number of open+pending channels.

    Returns Promise<GetInfoResponse>

getLndInfo

getMaxListeners

  • getMaxListeners(): number

getRoute

  • getRoute(units: number, destination: string, _currency: string, finalLock?: number): Promise<undefined | Route>

hasNoInvoiceSupport

  • hasNoInvoiceSupport(): boolean

init

  • init(): Promise<void>

initSpecific

  • initSpecific(): Promise<void>

initWallet

  • initWallet(walletPassword: string, seedMnemonic: string[], restore?: boolean, backup?: Uint8Array): Promise<lndwalletunlocker.InitWalletResponse.AsObject>
  • Parameters

    • walletPassword: string
    • seedMnemonic: string[]
    • Default value restore: boolean = false
    • Optional backup: Uint8Array

    Returns Promise<lndwalletunlocker.InitWalletResponse.AsObject>

isConnected

  • isConnected(): boolean

isDisabled

  • isDisabled(): boolean

isDisconnected

  • isDisconnected(): boolean

isMisconfigured

  • isMisconfigured(): boolean

isNotInitialized

  • isNotInitialized(): boolean

isOperational

  • isOperational(): boolean

isOutOfSync

  • isOutOfSync(): boolean

isWaitingUnlock

  • isWaitingUnlock(): boolean

listChannels

  • listChannels(): Promise<ListChannelsResponse>

Private listPayments

  • listPayments(includeIncomplete?: undefined | false | true): Promise<ListPaymentsResponse>

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

Private loadMacaroon

  • loadMacaroon(): Promise<void>

Private lock

  • lock(): void

lookupPayment

Private newAddress

  • newAddress(addressType?: AddressType): Promise<string>
  • Gets a new address for the internal lnd wallet.

    Parameters

    • Default value addressType: AddressType = lndrpc.AddressType.WITNESS_PUBKEY_HASH

    Returns Promise<string>

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: "connectionVerified", listener: (swapClientInfo: SwapClientInfo) => void): this
  • on(event: "htlcAccepted", listener: (rHash: string, amount: number) => void): this
  • on(event: "channelBackup", listener: (channelBackup: Uint8Array) => void): this
  • on(event: "channelBackupEnd", listener: () => void): this
  • on(event: "locked", listener: () => void): this

once

  • once(event: "initialized", listener: () => void): this

openChannel

  • openChannel(__namedParameters: { fee: number; pushUnits: number; remoteIdentifier: undefined | string; units: number; uris: undefined | string[] }): Promise<string>
  • Opens a channel given peerPubKey and amount.

    Parameters

    • __namedParameters: { fee: number; pushUnits: number; remoteIdentifier: undefined | string; units: number; uris: undefined | string[] }
      • fee: number
      • pushUnits: number
      • remoteIdentifier: undefined | string
      • units: number
      • uris: undefined | string[]

    Returns Promise<string>

Private openChannelSync

  • openChannelSync(nodePubkeyString: string, localFundingAmount: number, pushSat?: number, fee?: number): Promise<ChannelPoint>
  • Opens a channel with a connected lnd node.

    Parameters

    • nodePubkeyString: string
    • localFundingAmount: number
    • Default value pushSat: number = 0
    • Default value fee: number = 0

    Returns Promise<ChannelPoint>

Private pendingChannels

  • pendingChannels(): Promise<PendingChannelsResponse>

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

Private queryRoutes

  • queryRoutes(request: QueryRoutesRequest): Promise<QueryRoutesResponse>
  • Lists all routes to destination.

    Parameters

    • request: QueryRoutesRequest

    Returns Promise<QueryRoutesResponse>

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeInvoice

  • removeInvoice(rHash: string): Promise<void>

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

restoreChannelBackup

  • restoreChannelBackup(multiChannelBackup: Uint8Array): Promise<RestoreBackupResponse>

sendPayment

  • sendPayment(deal: SwapDeal): Promise<string>

Private sendPaymentV2

  • sendPaymentV2(request: SendPaymentRequest): Promise<string>
  • Sends a payment through the Lightning Network.

    Parameters

    • request: SendPaymentRequest

    Returns Promise<string>

    the preimage in hex format

sendSmallestAmount

  • sendSmallestAmount(rHash: string, destination: string): Promise<string>

Protected setConnected

  • setConnected(newIdentifier?: undefined | string, newUris?: string[]): Promise<void>

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

setReservedInboundAmount

  • setReservedInboundAmount(_reservedInboundAmount: number): void

Protected setStatus

Private setUnlocked

  • setUnlocked(): void

settleInvoice

  • settleInvoice(rHash: string, rPreimage: string): Promise<void>

Private settleInvoiceLnd

  • settleInvoiceLnd(request: SettleInvoiceMsg): Promise<SettleInvoiceResp>

subscribeChannelBackups

  • subscribeChannelBackups(): void

Private subscribeSingleInvoice

  • subscribeSingleInvoice(rHash: string): void

swapCapacities

Private unaryCall

  • unaryCall<T, U>(methodName: Exclude<keyof LightningClient, ClientMethods>, params: T): Promise<U>

Private unaryInvoiceCall

  • unaryInvoiceCall<T, U>(methodName: Exclude<keyof InvoicesClient, ClientMethods>, params: T): Promise<U>

Private unaryWalletUnlockerCall

  • unaryWalletUnlockerCall<T, U>(methodName: Exclude<keyof WalletUnlockerClient, ClientMethods>, params: T): Promise<U>

unlockWallet

  • unlockWallet(walletPassword: string): Promise<void>

Protected updateCapacity

  • updateCapacity(): Promise<void>

Private updateChannelBalances

  • updateChannelBalances(): Promise<{ balance: number; inactiveBalance: number; maxInbound: number; maxOutbound: number; pendingOpenBalance: number; totalInboundAmount: number; totalOutboundAmount: number }>
  • Updates all balances related to channels including active, inactive, and pending balances. Sets trading limits for this client accordingly.

    Returns Promise<{ balance: number; inactiveBalance: number; maxInbound: number; maxOutbound: number; pendingOpenBalance: number; totalInboundAmount: number; totalOutboundAmount: number }>

Protected verifyConnection

  • verifyConnection(): Promise<void>

verifyConnectionWithTimeout

  • verifyConnectionWithTimeout(): Promise<void>

Private waitForClientReady

  • waitForClientReady(client: Client): Promise<unknown>

walletBalance

  • walletBalance(): Promise<lndrpc.WalletBalanceResponse.AsObject>

Private watchThenLoadMacaroon

  • watchThenLoadMacaroon(): Promise<void>
  • Watches for a change in the admin.macaroon file at the configured path, then loads the macaroon.

    Returns Promise<void>

withdraw

  • withdraw(__namedParameters: { all: boolean; amount: undefined | number; destination: string; fee: undefined | number }): Promise<string>
  • Parameters

    • __namedParameters: { all: boolean; amount: undefined | number; destination: string; fee: undefined | number }
      • all: boolean
      • amount: undefined | number
      • destination: string
      • fee: undefined | number

    Returns Promise<string>

Object literals

Static Private MINUTES_PER_BLOCK_BY_CURRENCY

MINUTES_PER_BLOCK_BY_CURRENCY: object

BTC

BTC: number = 10

LTC

LTC: number = 2.5

Generated using TypeDoc