Options
All
  • Public
  • Public/Protected
  • All
Menu

Haveno daemon client.

Hierarchy

  • HavenoClient

Index

Constructors

Properties

Methods

Constructors

  • new HavenoClient(url: string, password: string): HavenoClient
  • Construct a client connected to a Haveno daemon.

    Parameters

    • url: string

      Haveno daemon url

    • password: string

      Haveno daemon password

    Returns HavenoClient

Properties

_accountClient: AccountClient
_appName: undefined | string
_disputeAgentsClient: DisputeAgentsClient
_disputesClient: DisputesClient
_getVersionClient: GetVersionClient
_keepAliveLooper: any
_keepAlivePeriodMs: number = 60000
_moneroConnectionsClient: MoneroConnectionsClient
_moneroNodeClient: MoneroNodeClient
_notificationListeners: ((_notification: NotificationMessage) => void)[] = []
_notificationStream: undefined | ClientReadableStream<NotificationMessage>
_notificationsClient: NotificationsClient
_offersClient: OffersClient
_password: string
_paymentAccountsClient: PaymentAccountsClient
_paymentMethods: undefined | PaymentMethod[]
_priceClient: PriceClient
_process: any
_processLogging: boolean = false
_registerNotificationListenerCalled: boolean = false
_shutdownServerClient: ShutdownServerClient
_tradesClient: TradesClient
_url: string
_walletRpcPort: undefined | number
_walletsClient: WalletsClient
_fullyInitializedMessage: "Application fully initialized" = "Application fully initialized"
_loginRequiredMessage: "Interactive login required" = "Interactive login required"

Methods

  • _isAppInitialized(): Promise<boolean>
  • _updateNotificationListenerRegistration(): Promise<void>
  • Update notification listener registration. Due to the nature of grpc streaming, this method returns a promise which may be resolved before the listener is actually registered.

    Returns Promise<void>

  • accountExists(): Promise<boolean>
  • Indicates if the Haveno account is created.

    Returns Promise<boolean>

    true if the account is created, false otherwise

  • addMoneroConnection(connection: string | UrlConnection): Promise<void>
  • backupAccount(stream: any): Promise<number>
  • Backup the account to the given stream. TODO: stream type?

    Parameters

    • stream: any

    Returns Promise<number>

  • changePassword(password: string): Promise<void>
  • Change the Haveno account password.

    Parameters

    • password: string

      the new account password

    Returns Promise<void>

  • Check the current Monero daemon connection.

    If disconnected and auto switch enabled, switch to the best available connection and return its status.

    Returns Promise<undefined | UrlConnection>

    the current daemon connection status, undefined if no current connection

  • closeAccount(): Promise<void>
  • confirmPaymentReceived(tradeId: string): Promise<void>
  • Confirm a payment is received.

    Parameters

    • tradeId: string

      the id of the trade

    Returns Promise<void>

  • confirmPaymentStarted(tradeId: string): Promise<void>
  • Confirm a payment is started.

    Parameters

    • tradeId: string

      the id of the trade

    Returns Promise<void>

  • createAccount(password: string): Promise<void>
  • Create and open a new Haveno account.

    Parameters

    • password: string

      the password to encrypt the account

    Returns Promise<void>

  • createCryptoPaymentAccount(accountName: string, assetCode: string, address: string): Promise<PaymentAccount>
  • Create a crypto payment account.

    Parameters

    • accountName: string

      description of the account

    • assetCode: string

      traded asset code

    • address: string

      payment address of the account

    Returns Promise<PaymentAccount>

    the created payment account

  • createPaymentAccount(paymentAccountForm: any): Promise<PaymentAccount>
  • Create a payment account.

    Parameters

    • paymentAccountForm: any

      the completed form as JSON to create the payment account

    Returns Promise<PaymentAccount>

    the created payment account

  • deleteAccount(): Promise<void>
  • Permanently delete the Haveno account and shutdown the server. // TODO: possible to not shutdown server?

    Returns Promise<void>

  • disconnect(): Promise<void>
  • getAppName(): undefined | string
  • Get the best available connection in order of priority then response time.

    Returns Promise<undefined | UrlConnection>

    the best available connection in order of priority then response time, undefined if no connections available

  • getChatMessages(tradeId: string): Promise<ChatMessage[]>
  • getDispute(tradeId: string): Promise<Dispute>
  • Get the market depth of a currency.

    Parameters

    • assetCode: string

      asset to get the market depth of

    Returns Promise<MarketDepthInfo>

    market depth of the given currency

  • Get the current Monero daemon connection.

    Returns Promise<undefined | UrlConnection>

    the current daemon connection, undefined if no current connection

  • getMyOffer(offerId: string): Promise<OfferInfo>
  • Get my offer by id.

    Parameters

    • offerId: string

      id of the user's created offer

    Returns Promise<OfferInfo>

    the user's created offer

  • getMyOffers(assetCode: string, direction?: string): Promise<OfferInfo[]>
  • Get the user's posted offers to buy or sell XMR.

    Parameters

    • assetCode: string

      traded asset code

    • Optional direction: string

      "buy" or "sell" XMR (default all)

    Returns Promise<OfferInfo[]>

    the user's created offers

  • getNewDepositAddress(): Promise<string>
  • Get a new subaddress in the Monero wallet to receive deposits.

    Returns Promise<string>

    the deposit address (a subaddress in the Haveno wallet)

  • getOffers(assetCode: string, direction?: string): Promise<OfferInfo[]>
  • Get available offers to buy or sell XMR.

    Parameters

    • assetCode: string

      traded asset code

    • Optional direction: string

      "buy" or "sell" (default all)

    Returns Promise<OfferInfo[]>

    the available offers

  • getPaymentAccountForm(paymentMethodId: string): Promise<any>
  • Get a form for the given payment method to complete and create a new payment account.

    Parameters

    • paymentMethodId: string

    Returns Promise<any>

    the payment account form as JSON

  • Get payment methods.

    Parameters

    • Optional assetCode: string

      get payment methods supporting this asset code (optional)

    Returns Promise<PaymentMethod[]>

    the payment methods

  • getPrice(assetCode: string): Promise<number>
  • Get the current market price per 1 XMR in the given currency.

    Parameters

    • assetCode: string

      asset code to get the price of

    Returns Promise<number>

    the price of the asset per 1 XMR

  • getProcess(): any
  • Return the process running the haveno daemon.

    Returns any

    the process running the haveno daemon

  • getSupportedAssetCodes(): Promise<string[]>
  • Get all supported assets codes.

    TODO: replace this with getSupportedAssetCodes(): Promise<TradeCurrency[]>)

    Returns Promise<string[]>

    all supported trade assets

  • getTrade(tradeId: string): Promise<TradeInfo>
  • Get a trade by id.

    Parameters

    • tradeId: string

      the id of the trade and its offer

    Returns Promise<TradeInfo>

    the trade with the given id

  • getUrl(): string
  • getVersion(): Promise<string>
  • getWalletRpcPort(): undefined | number
  • Get the port of the primary wallet rpc instance if known.

    Returns undefined | number

    the port of the primary wallet rpc instance if known

  • getXmrSeed(): Promise<string>
  • Get the mnemonic seed phrase of the Monero wallet.

    Returns Promise<string>

    the mnemonic seed phrase of the Monero wallet

  • getXmrTx(txHash: string): Promise<XmrTx>
  • Get a transaction by hash in the Monero wallet.

    Parameters

    • txHash: string

      hash of the transaction to get

    Returns Promise<XmrTx>

    the transaction with the hash

  • getXmrTxs(): Promise<XmrTx[]>
  • isAccountOpen(): Promise<boolean>
  • Indicates if the Haveno account is open and authenticated with the correct password.

    Returns Promise<boolean>

    true if the account is open and authenticated, false otherwise

  • isConnectedToDaemon(): Promise<boolean>
  • Indicates if connected and authenticated with the Haveno daemon.

    Returns Promise<boolean>

    true if connected with the Haveno daemon, false otherwise

  • isConnectedToMonero(): Promise<boolean>
  • Indicates if connected to the Monero network based on last connection check.

    Returns Promise<boolean>

    true if connected to the Monero network, false otherwise

  • isMoneroNodeRunning(): Promise<boolean>
  • openAccount(password: string): Promise<void>
  • Open existing Haveno account.

    Parameters

    • password: string

      the account password

    Returns Promise<void>

  • openDispute(tradeId: string): Promise<void>
  • Open a dispute for a trade.

    Parameters

    • tradeId: string

      the id of the trade

    Returns Promise<void>

  • postOffer(direction: string, amount: bigint, assetCode: string, paymentAccountId: string, buyerSecurityDeposit: number, price?: number, marketPriceMargin?: number, triggerPrice?: number, minAmount?: bigint): Promise<OfferInfo>
  • Post an offer.

    Parameters

    • direction: string

      "buy" or "sell" XMR

    • amount: bigint

      amount of XMR to trade

    • assetCode: string

      asset code to trade for XMR

    • paymentAccountId: string

      payment account id

    • buyerSecurityDeposit: number

      buyer security deposit as % of trade amount

    • Optional price: number

      trade price (optional, default to market price)

    • Optional marketPriceMargin: number

      if using market price, % from market price to accept (optional, default 0%)

    • Optional triggerPrice: number

      price to remove offer (optional)

    • Optional minAmount: bigint

      minimum amount to trade (optional, default to fixed amount)

    Returns Promise<OfferInfo>

    the posted offer

  • registerDisputeAgent(disputeAgentType: string, registrationKey: string): Promise<void>
  • Register as a dispute agent.

    Parameters

    • disputeAgentType: string

      type of dispute agent to register, e.g. mediator, refundagent

    • registrationKey: string

      registration key

    Returns Promise<void>

  • relayXmrTx(metadata: string): Promise<string>
  • Relay a previously created transaction to send funds from the Monero wallet.

    Parameters

    • metadata: string

    Returns Promise<string>

    the hash of the relayed transaction

  • removeMoneroConnection(url: string): Promise<void>
  • Remove a Monero daemon connection.

    Parameters

    • url: string

      url of the daemon connection to remove

    Returns Promise<void>

  • removeNotificationListener(listener: (_notification: NotificationMessage) => void): Promise<void>
  • removeOffer(offerId: string): Promise<void>
  • Remove a posted offer, releasing its reserved funds.

    Parameters

    • offerId: string

      the offer id to cancel

    Returns Promise<void>

  • resolveDispute(tradeId: string, winner: Winner, reason: Reason, summaryNotes: string, customWinnerAmount?: bigint): Promise<void>
  • Resolve a dispute. By default, the winner receives the trade amount and the security deposits are returned, but the arbitrator may award a custom amount to the winner.

    Parameters

    • tradeId: string

      the id of the trade

    • winner: Winner

      the winner of the dispute

    • reason: Reason

      the reason for the dispute

    • summaryNotes: string

      summary of the dispute

    • Optional customWinnerAmount: bigint

      custom amount to award the winner (optional)

    Returns Promise<void>

  • restoreAccount(zipBytes: Uint8Array): Promise<void>
  • Restore the account from zip bytes.

    Sends chunked requests if size over max grpc envelope size (41943404 bytes).

    Parameters

    • zipBytes: Uint8Array

      the bytes of the zipped account to restore

    Returns Promise<void>

  • sendChatMessage(tradeId: string, message: string): Promise<void>
  • Send a trade chat message.

    Parameters

    • tradeId: string

      the id of the trade

    • message: string

      the message

    Returns Promise<void>

  • sendDisputeChatMessage(disputeId: string, message: string, attachments: Attachment[]): Promise<void>
  • Send a dispute chat message.

    Parameters

    • disputeId: string

      the id of the dispute

    • message: string

      the message

    • attachments: Attachment[]

      attachments

    Returns Promise<void>

  • setAutoSwitch(autoSwitch: boolean): Promise<void>
  • Automatically switch to the best available connection if current connection is disconnected after being checked.

    Parameters

    • autoSwitch: boolean

      whether auto switch is enabled or disabled

    Returns Promise<void>

  • setMoneroConnection(connection?: string | UrlConnection): Promise<void>
  • Set the current Monero daemon connection.

    Add the connection if not previously seen. If the connection is provided as string, connect to the URI with any previously set credentials and priority. If the connection is provided as UrlConnection, overwrite any previously set credentials and priority. If undefined connection provided, disconnect the client.

    Parameters

    • Optional connection: string | UrlConnection

      connection to set as current

    Returns Promise<void>

  • setProcessLogging(enabled: boolean): void
  • Enable or disable process logging.

    Parameters

    • enabled: boolean

      specifies if logging is enabled or disabled

    Returns void

  • shutdownServer(): Promise<void>
  • Shutdown the Haveno daemon server and stop the process if applicable.

    Returns Promise<void>

  • startCheckingConnection(refreshPeriod: number): Promise<void>
  • Check the connection and start checking the connection periodically.

    Parameters

    • refreshPeriod: number

      time between checks in milliseconds (default 15000 ms or 15 seconds)

    Returns Promise<void>

  • stopCheckingConnection(): Promise<void>
  • stopMoneroNode(): Promise<void>
  • takeOffer(offerId: string, paymentAccountId: string): Promise<TradeInfo>
  • Take an offer.

    Parameters

    • offerId: string

      id of the offer to take

    • paymentAccountId: string

      id of the payment account

    Returns Promise<TradeInfo>

    the initialized trade

  • startProcess(havenoPath: string, cmd: string[], url: string, enableLogging: boolean): Promise<HavenoClient>
  • Start a new Haveno process.

    Parameters

    • havenoPath: string

      path to Haveno binaries

    • cmd: string[]

      command to start the process

    • url: string

      Haveno daemon url (must proxy to api port)

    • enableLogging: boolean

      specifies if logging is enabled or disabled at log level 3

    Returns Promise<HavenoClient>

    a client connected to the newly started Haveno process

Generated using TypeDoc