Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • EventEmitter
    • SwapClientManager

Index

Constructors

constructor

Properties

Private config

config: Config

Optional connextClient

connextClient: ConnextClient

Private loggers

loggers: Loggers

misconfiguredClients

misconfiguredClients: Set<SwapClient> = new Set<SwapClient>()

Optional raidenClient

raidenClient: RaidenClient

swapClients

swapClients: Map<string, SwapClient> = new Map<string, SwapClient>()

A map between currencies and all enabled swap clients

Private unitConverter

unitConverter: UnitConverter

Private Optional walletPassword

walletPassword: undefined | string

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.

Methods

add

  • Adds a new swap client and currency association.

    Parameters

    • currency: Currency

      a currency that should be linked with a swap client.

    Returns void

    Nothing upon success, throws otherwise.

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 bind

  • bind(): void

canRouteToPeer

  • canRouteToPeer(peer: Peer, currency: string): Promise<boolean>
  • Checks whether it is possible to route a payment to a peer for a given currency. This does not guarantee or test that a payment can be routed successfully, only determiens whether it is possible to do so currently given the state of the specified currency's network and graph.

    Parameters

    • peer: Peer
    • currency: string

    Returns Promise<boolean>

close

  • close(): void

closeChannel

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

    Parameters

    • __namedParameters: { amount: undefined | number; currency: string; destination: undefined | string; force: boolean; remoteIdentifier: undefined | string }
      • amount: undefined | number
      • currency: string
      • destination: undefined | string
      • force: boolean
      • remoteIdentifier: undefined | string

    Returns Promise<void>

    Nothing upon success, throws otherwise.

deposit

  • deposit(currency: string): Promise<string>

emit

  • emit(event: "lndUpdate", lndUpdate: LndUpdate): boolean
  • emit(event: "raidenUpdate", tokenAddresses: Map<string, string>, address?: undefined | string): boolean
  • emit(event: "connextUpdate", tokenAddresses: Map<string, string>, pubKey?: undefined | string): boolean
  • emit(event: "htlcAccepted", swapClient: SwapClient, rHash: string, amount: number, currency: string): boolean

eventNames

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

get

  • Gets a swap client instance.

    Parameters

    • currency: string

      a currency that the swap client is linked to.

    Returns SwapClient | undefined

    swap client instance upon success, undefined otherwise.

getLndClientsInfo

  • getLndClientsInfo(): Promise<Map<string, { alias?: undefined | string; blockheight?: undefined | number; chains?: Chain[]; channels?: ChannelCount; error?: undefined | string; status: string; uris?: string[]; version?: undefined | string }>>
  • Gets all lnd clients' info.

    Returns Promise<Map<string, { alias?: undefined | string; blockheight?: undefined | number; chains?: Chain[]; channels?: ChannelCount; error?: undefined | string; status: string; uris?: string[]; version?: undefined | string }>>

    A promise that resolves to an object containing lnd clients' info, throws otherwise.

getLndClientsMap

getMaxListeners

  • getMaxListeners(): number

getType

init

  • init(models: Models): Promise<void>
  • Starts all swap clients, binds event listeners and waits for the swap clients to initialize.

    Parameters

    Returns Promise<void>

    A promise that resolves upon successful initialization, rejects otherwise.

initConnext

  • initConnext(seed: string): Promise<void>

initWallets

  • initWallets(__namedParameters: { lndBackups: undefined | Map<string, Uint8Array>; raidenDatabase: undefined | Uint8Array; raidenDatabasePath: undefined | string; restore: undefined | false | true; seedMnemonic: string[]; walletPassword: string }): Promise<{ initializedLndWallets: string[]; initializedRaiden: boolean }>
  • Initializes wallets with seed and password.

    Parameters

    • __namedParameters: { lndBackups: undefined | Map<string, Uint8Array>; raidenDatabase: undefined | Uint8Array; raidenDatabasePath: undefined | string; restore: undefined | false | true; seedMnemonic: string[]; walletPassword: string }
      • lndBackups: undefined | Map<string, Uint8Array>
      • raidenDatabase: undefined | Uint8Array
      • raidenDatabasePath: undefined | string
      • restore: undefined | false | true
      • seedMnemonic: string[]
      • walletPassword: string

    Returns Promise<{ initializedLndWallets: string[]; initializedRaiden: boolean }>

isConnected

  • isConnected(currency: string): boolean
  • Returns whether the swap client for a specified currency is connected.

    Parameters

    • currency: string

    Returns boolean

    true if a swap client exists and is connected, otherwise false

listenerCount

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

    • type: string | symbol

    Returns number

listeners

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

    • event: string | symbol

    Returns Function[]

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: "lndUpdate", listener: (lndUpdate: LndUpdate) => void): this
  • on(event: "raidenUpdate", listener: (tokenAddresses: Map<string, string>, address?: undefined | string) => void): this
  • on(event: "connextUpdate", listener: (tokenAddresses: Map<string, string>, pubKey?: undefined | string) => void): this
  • on(event: "htlcAccepted", listener: (swapClient: SwapClient, rHash: string, amount: number, currency: string) => void): this
  • Parameters

    • event: "lndUpdate"
    • listener: (lndUpdate: LndUpdate) => void

    Returns this

  • Parameters

    • event: "raidenUpdate"
    • listener: (tokenAddresses: Map<string, string>, address?: undefined | string) => void
        • (tokenAddresses: Map<string, string>, address?: undefined | string): void
        • Parameters

          • tokenAddresses: Map<string, string>
          • Optional address: undefined | string

          Returns void

    Returns this

  • Parameters

    • event: "connextUpdate"
    • listener: (tokenAddresses: Map<string, string>, pubKey?: undefined | string) => void
        • (tokenAddresses: Map<string, string>, pubKey?: undefined | string): void
        • Parameters

          • tokenAddresses: Map<string, string>
          • Optional pubKey: undefined | string

          Returns void

    Returns this

  • Parameters

    • event: "htlcAccepted"
    • listener: (swapClient: SwapClient, rHash: string, amount: number, currency: string) => void
        • (swapClient: SwapClient, rHash: string, amount: number, currency: string): void
        • Parameters

          • swapClient: SwapClient
          • rHash: string
          • amount: number
          • currency: string

          Returns void

    Returns this

once

  • once(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

openChannel

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

    Parameters

    • __namedParameters: { amount: number; currency: string; pushAmount: number; remoteIdentifier: undefined | string; uris: undefined | string[] }
      • amount: number
      • currency: string
      • pushAmount: number
      • remoteIdentifier: undefined | string
      • uris: undefined | string[]

    Returns Promise<void>

    Nothing upon success, throws otherwise.

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[]

remove

  • remove(currency: string): void
  • Removes a new swap client and currency association.

    Parameters

    • currency: string

      a currency that should be unlinked from a swap client.

    Returns void

    Nothing upon success, throws otherwise.

removeAllListeners

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

    • Optional event: string | symbol

    Returns this

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

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

unlockWallets

  • unlockWallets(__namedParameters: { walletPassword: string }): Promise<{ lockedLndClients: string[]; unlockedLndClients: string[] }>
  • Unlocks wallets with a password.

    Parameters

    • __namedParameters: { walletPassword: string }
      • walletPassword: string

    Returns Promise<{ lockedLndClients: string[]; unlockedLndClients: string[] }>

    an array of currencies for each lnd client that was unlocked

waitForLnd

  • waitForLnd(): Promise<void>
  • Checks to make sure all enabled lnd instances are available and waits up to a short time for them to become available in case they are not. Throws an error if any lnd clients remain unreachable.

    Returns Promise<void>

withdraw

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

    • __namedParameters: { all: undefined | false | true; amount: undefined | number; currency: string; destination: string; fee: undefined | number }
      • all: undefined | false | true
      • amount: undefined | number
      • currency: string
      • destination: string
      • fee: undefined | number

    Returns Promise<string>

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