Options
All
  • Public
  • Public/Protected
  • All
Menu

A class representing a client to interact with connext.

Hierarchy

Index

Constructors

constructor

  • new ConnextClient(__namedParameters: { config: { disable: boolean; host: string; port: number; webhookhost: string; webhookport: number }; currencyInstances: CurrencyInstance[]; logger: Logger; unitConverter: UnitConverter }): ConnextClient

Properties

Private _totalOutboundAmount

_totalOutboundAmount: Map<string, number> = new Map<string, number>()

Optional address

address: undefined | string

Protected disable

disable: boolean

Private expectedIncomingTransfers

expectedIncomingTransfers: Map<string, { expiry: number; paymentId?: undefined | string; rHash: string; tokenAddress: string; units: number }> = new Map<string, ExpectedIncomingTransfer>()

A map of expected invoices by hash. This is equivalent to invoices of lnd with the difference being that we're managing the state of invoice on xud level.

Readonly finalLock

finalLock: 200 = 200

Private getBalancePromises

getBalancePromises: Map<string, Promise<{ freeBalanceOffChain: string; freeBalanceOnChain: string }>> = new Map<string, Promise<ConnextBalanceResponse>>()

A map of currencies to promises representing balance requests.

Private host

host: string

logger

logger: Logger

Private outgoingTransferHashes

outgoingTransferHashes: Set<string> = new Set<string>()

The set of hashes for outgoing transfers.

Private port

port: number

Protected Optional reconnectionTimer

reconnectionTimer: NodeJS.Timer

Private seed

seed: string | undefined

Protected status

status: ClientStatus = ClientStatus.NotInitialized

tokenAddresses

tokenAddresses: Map<string, string> = new Map<string, string>()

A map of currency symbols to token addresses.

Readonly type

type: Connext = SwapClientType.Connext

Private unitConverter

unitConverter: UnitConverter

Private webhookhost

webhookhost: string

Private webhookport

webhookport: number

Static Readonly RECONNECT_INTERVAL

RECONNECT_INTERVAL: 5000 = 5000

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

Accessors

label

  • get label(): string

minutesPerBlock

  • get minutesPerBlock(): number

Methods

addInvoice

  • addInvoice(__namedParameters: { expectedCurrency: undefined | string; expectedHash: string; expectedTimelock: undefined | number; expectedUnits: number }): Promise<void>
  • Parameters

    • __namedParameters: { expectedCurrency: undefined | string; expectedHash: string; expectedTimelock: undefined | number; expectedUnits: number }
      • expectedCurrency: undefined | string
      • expectedHash: string
      • expectedTimelock: undefined | number
      • expectedUnits: number

    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

canRouteToNode

  • canRouteToNode(): Promise<boolean>

channelBalance

  • channelBalance(currency?: undefined | string): Promise<ChannelBalance>

close

  • close(): void

closeChannel

  • closeChannel(__namedParameters: { currency: undefined | string; destination: undefined | string; units: undefined | number }): Promise<void>
  • Parameters

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

    Returns Promise<void>

deposit

  • deposit(): Promise<string>

depositToChannel

  • depositToChannel(assetId: string, amount: number): Promise<void>

Protected disconnect

  • disconnect(): Promise<void>

emit

  • emit(event: "htlcAccepted", rHash: string, amount: number, currency: string): boolean
  • emit(event: "connectionVerified", swapClientInfo: SwapClientInfo): boolean
  • emit(event: "initialized"): boolean
  • emit(event: "preimage", preimageRequest: ProvidePreimageEvent): void
  • emit(event: "transferReceived", transferReceivedRequest: TransferReceivedEvent): void

eventNames

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

Private executeHashLockTransfer

Private getBalance

getClientConfig

Protected getCurrencyByTokenaddress

  • getCurrencyByTokenaddress(tokenAddress: string): string

Private getHashLockStatus

  • getHashLockStatus(lockHash: string, assetId: string): Promise<{ amount: string; assetId: string; expiry: { _hex: string }; lockHash: string; meta: { sender: string; timelock: string }; preImage?: undefined | string; receiverIdentifier: string; senderIdentifier: string; status: string }>
  • Parameters

    • lockHash: string
    • assetId: string

    Returns Promise<{ amount: string; assetId: string; expiry: { _hex: string }; lockHash: string; meta: { sender: string; timelock: string }; preImage?: undefined | string; receiverIdentifier: string; senderIdentifier: string; status: string }>

getHeight

  • getHeight(): Promise<number>

getInfo

getMaxListeners

  • getMaxListeners(): number

getRoute

  • getRoute(): Promise<{ getTotalTimeLock: any }>

Protected getTokenAddress

  • getTokenAddress(currency: string): string

getVersion

  • getVersion(): Promise<string>

init

  • init(): Promise<void>

initConnextClient

  • initConnextClient(seedMnemonic: string): Promise<{ multisigAddress: string; natsClusterId: string; natsToken: string; nodeUrl: string; signerAddress: string; userIdentifier: string; userPublicIdentifier: string }>
  • Parameters

    • seedMnemonic: string

    Returns Promise<{ multisigAddress: string; natsClusterId: string; natsToken: string; nodeUrl: string; signerAddress: string; userIdentifier: string; userPublicIdentifier: string }>

initSpecific

  • initSpecific(): Promise<void>

initWallet

  • initWallet(seedMnemonic: string): Promise<{ success: boolean }>

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

lookupPayment

  • lookupPayment(rHash: string, currency: string): Promise<PaymentStatus>

maxChannelInboundAmount

  • maxChannelInboundAmount(_currency: string): number

maxChannelOutboundAmount

  • maxChannelOutboundAmount(currency: 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: "preimage", listener: (preimageRequest: ProvidePreimageEvent) => void): void
  • on(event: "transferReceived", listener: (transferReceivedRequest: TransferReceivedEvent) => void): void
  • on(event: "htlcAccepted", listener: (rHash: string, amount: number, currency: string) => void): this
  • on(event: "connectionVerified", listener: (swapClientInfo: SwapClientInfo) => void): this

Private onTransferReceived

once

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

openChannel

  • openChannel(__namedParameters: { currency: undefined | string; units: number }): 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[]

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

sendPayment

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

Private sendRequest

  • sendRequest(endpoint: string, method: string, payload?: undefined | object): Promise<IncomingMessage>
  • Sends a request to the Connext REST API.

    Parameters

    • endpoint: string

      the URL endpoint

    • method: string

      an HTTP request method

    • Optional payload: undefined | object

      the request payload

    Returns Promise<IncomingMessage>

sendSmallestAmount

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

Protected setConnected

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

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

setSeed

  • setSeed(seed: string): void

Protected setStatus

Private setTokenAddresses

settleInvoice

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

Private subscribeIncomingTransfer

  • subscribeIncomingTransfer(): Promise<void>

Private subscribePreimage

  • subscribePreimage(): Promise<void>

totalOutboundAmount

  • totalOutboundAmount(currency: string): number

tradingLimits

Protected updateCapacity

  • updateCapacity(): Promise<void>

Protected verifyConnection

  • verifyConnection(): Promise<void>

verifyConnectionWithTimeout

  • verifyConnectionWithTimeout(): Promise<void>

walletBalance

  • walletBalance(currency?: undefined | string): Promise<WalletBalance>

Generated using TypeDoc