Options
All
  • Public
  • Public/Protected
  • All
Menu

A base class to represent an external swap client such as lnd or Raiden.

Hierarchy

Index

Constructors

constructor

Properties

Protected disable

disable: boolean

Readonly Abstract finalLock

finalLock: number

The number of blocks of lock time to expect on the final hop of an incoming swap payment.

logger

logger: Logger

Protected Optional reconnectionTimer

reconnectionTimer: NodeJS.Timer

Protected status

status: ClientStatus = ClientStatus.NotInitialized

Readonly Abstract type

Private Optional updateCapacityTimer

updateCapacityTimer: NodeJS.Timer

Static Private CAPACITY_REFRESH_INTERVAL

CAPACITY_REFRESH_INTERVAL: number = 3000

Time in milliseconds between updating the maximum outbound capacity.

Static Private INITIALIZATION_TIME_LIMIT

INITIALIZATION_TIME_LIMIT: number = 5000

The maximum amount of time we will wait for the connection to be verified during initialization.

Static Readonly RECONNECT_INTERVAL

RECONNECT_INTERVAL: 5000 = 5000

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

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: keyof symbol

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

label

  • get label(): string

minutesPerBlock

  • get minutesPerBlock(): number

Methods

Abstract addInvoice

  • addInvoice(__namedParameters: { currency: undefined | string; expiry: undefined | number; rHash: string; units: number }): Promise<void>
  • Notifies that swap client to expect a payment.

    Parameters

    • __namedParameters: { currency: undefined | string; expiry: undefined | number; rHash: string; units: number }
      • currency: undefined | string
      • expiry: undefined | number
      • rHash: string

        the hash of the preimage

      • units: number

        the amount of the invoice denominated in the smallest units supported by its currency

    Returns 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

Abstract canRouteToNode

  • canRouteToNode(destination: string, currency?: undefined | string): Promise<boolean>
  • Checks whether it is possible to route a payment to a node. This does not test or guarantee that a payment can be routed successfully, only whether it is possible to do so currently given the state of the network and graph - without creating new channels or edges.

    Parameters

    • destination: string
    • Optional currency: undefined | string

    Returns Promise<boolean>

Abstract channelBalance

  • channelBalance(currency?: undefined | string): Promise<ChannelBalance>
  • Returns the total balance available across all channels and updates the maximum outbound capacity.

    Parameters

    • Optional currency: undefined | string

      the currency whose balance to query for, otherwise all/any currencies supported by this client are included in the balance.

    Returns Promise<ChannelBalance>

close

  • close(): void

Abstract closeChannel

  • closeChannel(__namedParameters: { currency: undefined | string; destination: undefined | string; force: undefined | false | true; remoteIdentifier: undefined | string; units: undefined | number }): Promise<void>
  • Closes a payment channel.

    Parameters

    • __namedParameters: { currency: undefined | string; destination: undefined | string; force: undefined | false | true; remoteIdentifier: undefined | string; units: undefined | number }
      • currency: undefined | string
      • destination: undefined | string
      • force: undefined | false | true
      • remoteIdentifier: undefined | string
      • units: undefined | number

    Returns Promise<void>

Abstract deposit

  • deposit(): Promise<string>

Protected Abstract disconnect

  • disconnect(): void

emit

  • emit(event: "connectionVerified", swapClientInfo: SwapClientInfo): boolean
  • emit(event: "initialized"): boolean

eventNames

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

Abstract getHeight

  • getHeight(): Promise<number>

getMaxListeners

  • getMaxListeners(): number

Abstract getRoute

  • getRoute(units: number, destination: string, currency: string, finalCltvDelta?: undefined | number): Promise<Route | undefined>
  • Gets routes for the given currency, amount, and swap identifier.

    Parameters

    • units: number

      the capacity the route must support denominated in the smallest units supported by its currency

    • destination: string

      the identifier for the receiving node

    • currency: string
    • Optional finalCltvDelta: undefined | number

    Returns Promise<Route | undefined>

    routes

init

  • init(): Promise<void>

Protected Abstract initSpecific

  • initSpecific(): Promise<void>

isConnected

  • isConnected(): boolean

isDisabled

  • isDisabled(): boolean

isDisconnected

  • isDisconnected(): boolean

isMisconfigured

  • isMisconfigured(): boolean

isNotInitialized

  • isNotInitialized(): boolean

isOperational

  • isOperational(): boolean

isOutOfSync

  • isOutOfSync(): boolean

isWaitingUnlock

  • isWaitingUnlock(): boolean

listenerCount

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

    • type: string | symbol

    Returns number

listeners

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

    • event: string | symbol

    Returns Function[]

Abstract lookupPayment

  • lookupPayment(rHash: string, currency?: undefined | string, destination?: undefined | string): Promise<PaymentStatus>
  • Checks to see whether we've made a payment using a given rHash.

    Parameters

    • rHash: string
    • Optional currency: undefined | string
    • Optional destination: undefined | string

    Returns Promise<PaymentStatus>

    the preimage for the payment, or undefined if no payment was made

Abstract maxChannelInboundAmount

  • maxChannelInboundAmount(currency?: undefined | string): number

Abstract maxChannelOutboundAmount

  • maxChannelOutboundAmount(currency?: undefined | string): number

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

once

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

Abstract openChannel

  • openChannel(__namedParameters: { currency: undefined | string; pushUnits: undefined | number; remoteIdentifier: undefined | string; units: number; uris: undefined | string[] }): Promise<void>
  • Opens a payment channel.

    Parameters

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

    Returns Promise<void>

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

rawListeners

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

    • event: string | symbol

    Returns Function[]

Private reconnectionTimerCallback

  • reconnectionTimerCallback(): Promise<void>

removeAllListeners

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

    • Optional event: string | symbol

    Returns this

Abstract 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

Abstract sendPayment

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

Abstract sendSmallestAmount

  • sendSmallestAmount(rHash: string, destination: string, currency: string): Promise<string>
  • Sends the smallest amount supported by the client to the given destination. Throws an error if the payment fails.

    Parameters

    • rHash: string
    • destination: string
    • currency: string

    Returns Promise<string>

    the preimage for the payment hash

Protected setConnected

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

    • Optional newIdentifier: undefined | string
    • Optional newUris: string[]

    Returns Promise<void>

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

Protected setStatus

Private setTimers

  • setTimers(): void

Abstract settleInvoice

  • settleInvoice(rHash: string, rPreimage: string, currency?: undefined | string): Promise<void>
  • Parameters

    • rHash: string
    • rPreimage: string
    • Optional currency: undefined | string

    Returns Promise<void>

Abstract totalOutboundAmount

  • totalOutboundAmount(currency?: undefined | string): number

Abstract tradingLimits

  • tradingLimits(currency?: undefined | string): Promise<TradingLimits>
  • Returns and updates the maximum outbound and inbound capacities for a distinct channel.

    Parameters

    • Optional currency: undefined | string

      the currency whose trading limits to query for, otherwise all/any currencies supported by this client are included in the trading limits.

    Returns Promise<TradingLimits>

Protected Abstract updateCapacity

  • updateCapacity(): Promise<void>

Private updateCapacityTimerCallback

  • updateCapacityTimerCallback(): Promise<void>

Protected Abstract verifyConnection

  • verifyConnection(): Promise<void>

verifyConnectionWithTimeout

  • verifyConnectionWithTimeout(): Promise<void>

Abstract walletBalance

  • walletBalance(currency?: undefined | string): Promise<WalletBalance>
  • Returns total unspent outputs (confirmed and unconfirmed), all confirmed unspent outputs and all unconfirmed unspent outputs under control of the wallet).

    Parameters

    • Optional currency: undefined | string

      the currency whose balance to query for, otherwise all/any currencies supported by this client are included in the balance.

    Returns Promise<WalletBalance>

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc