Class HavenoClient

Haveno daemon client.

Hierarchy

  • HavenoClient

Constructors

  • Construct a client connected to a Haveno daemon.

    Parameters

    • url: string

      Haveno daemon url

    • password: string

      Haveno daemon password

    Returns HavenoClient

Methods

  • Indicates if the Haveno account is created.

    Returns

    true if the account is created, false otherwise

    Returns Promise<boolean>

  • Backup the account to the given stream. TODO: stream type?

    Parameters

    • stream: any

    Returns Promise<number>

  • Change the Haveno account password.

    Parameters

    • oldPassword: string
    • newPassword: string

    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

    the current daemon connection status, undefined if no current connection

    Returns Promise<undefined | UrlConnection>

  • Close the currently open account.

    Returns Promise<void>

  • Acknowledge that a trade has completed.

    Parameters

    • tradeId: string

      the id of the trade

    Returns Promise<void>

  • Confirm a payment is received.

    Parameters

    • tradeId: string

      the id of the trade

    Returns Promise<void>

  • Confirm a payment is sent.

    Parameters

    • tradeId: string

      the id of the trade

    Returns Promise<void>

  • Create and open a new Haveno account.

    Parameters

    • password: string

      the password to encrypt the account

    Returns Promise<void>

  • Create a crypto payment account.

    Returns

    the created payment account

    Parameters

    • accountName: string

      description of the account

    • assetCode: string

      traded asset code

    • address: string

      payment address of the account

    Returns Promise<PaymentAccount>

  • Permanently delete the Haveno account.

    Returns Promise<void>

  • Disconnect this client from the server.

    Returns Promise<void>

  • Get the name of the Haveno application folder.

    Returns undefined | string

  • Get the best available connection in order of priority then response time.

    Returns

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

    Returns Promise<undefined | UrlConnection>

  • Get the market depth of a currency.

    Returns

    market depth of the given currency

    Parameters

    • assetCode: string

      asset to get the market depth of

    Returns Promise<MarketDepthInfo>

  • Get the current Monero daemon connection.

    Returns

    the current daemon connection, undefined if no current connection

    Returns Promise<undefined | UrlConnection>

  • Get my offer by id.

    Returns

    the user's created offer

    Parameters

    • offerId: string

      id of the user's created offer

    Returns Promise<OfferInfo>

  • Get the user's posted offers to buy or sell XMR.

    Returns

    the user's created offers

    Parameters

    • Optional assetCode: string

      traded asset code

    • Optional direction: string

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

    Returns Promise<OfferInfo[]>

  • Get available offers to buy or sell XMR.

    Returns

    the available offers

    Parameters

    • assetCode: string

      traded asset code

    • Optional direction: string

      "buy" or "sell" (default all)

    Returns Promise<OfferInfo[]>

  • Get a payment account by id.

    Returns

    the payment account

    Parameters

    • paymentAccountId: string

      the payment account id to get

    Returns Promise<PaymentAccount>

  • Get a form for the given payment method to complete and create a new payment account.

    Returns

    the payment account form

    Parameters

    • paymentMethodId: string

      the id of the payment method

    Returns Promise<PaymentAccountForm>

  • Get payment methods.

    Returns

    the payment methods

    Parameters

    • Optional assetCode: string

      get payment methods supporting this asset code (optional)

    Returns Promise<PaymentMethod[]>

  • Get the current market price per 1 XMR in the given currency.

    Returns

    the price of the asset per 1 XMR

    Parameters

    • assetCode: string

      asset code to get the price of

    Returns Promise<number>

  • Return the process running the haveno daemon.

    Returns

    the process running the haveno daemon

    Returns any

  • Get all supported assets codes.

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

    Returns

    all supported trade assets

    Returns Promise<string[]>

  • Get a trade by id.

    Returns

    the trade with the given id

    Parameters

    • tradeId: string

      the id of the trade and its offer

    Returns Promise<TradeInfo>

  • Get the URL of the Haveno daemon.

    Returns

    the URL of the Haveno daemon

    Returns string

  • Get the Haveno version.

    Returns

    the Haveno daemon version

    Returns Promise<string>

  • Get the port of the primary wallet rpc instance if known.

    Returns

    the port of the primary wallet rpc instance if known

    Returns undefined | number

  • Get a new subaddress in the Monero wallet to receive deposits.

    Returns

    the deposit address (a subaddress in the Haveno wallet)

    Returns Promise<string>

  • Get the primary address of the Monero wallet.

    Returns

    the primary address of the Monero wallet

    Returns Promise<string>

  • Get the mnemonic seed phrase of the Monero wallet.

    Returns

    the mnemonic seed phrase of the Monero wallet

    Returns Promise<string>

  • Get a transaction by hash in the Monero wallet.

    Returns

    the transaction with the hash

    Parameters

    • txHash: string

      hash of the transaction to get

    Returns Promise<undefined | XmrTx>

  • Indicates if the Haveno account is open and authenticated with the correct password.

    Returns

    true if the account is open and authenticated, false otherwise

    Returns Promise<boolean>

  • Indicates if connected and authenticated with the Haveno daemon.

    Returns

    true if connected with the Haveno daemon, false otherwise

    Returns Promise<boolean>

  • Indicates if connected to the Monero network based on last connection check.

    Returns

    true if connected to the Monero network, false otherwise

    Returns Promise<boolean>

  • Returns whether daemon is running a local monero node.

    Returns Promise<boolean>

  • Open existing Haveno account.

    Parameters

    • password: string

      the account password

    Returns Promise<void>

  • Open a dispute for a trade.

    Parameters

    • tradeId: string

      the id of the trade

    Returns Promise<void>

  • Post an offer.

    Returns

    the posted 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

    • buyerSecurityDepositPct: number

      buyer security deposit as % of trade amount

    • Optional price: number

      trade price (optional, default to market price)

    • Optional marketPriceMarginPct: 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)

    • Optional reserveExactAmount: boolean

      reserve exact amount needed for offer, incurring on-chain transaction and 10 confirmations before the offer goes live (default = false)

    Returns Promise<OfferInfo>

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

  • Relay a previously created transaction to send funds from the Monero wallet.

    Returns

    the hash of the relayed transaction

    Parameters

    • metadata: string

    Returns Promise<string>

  • Remove a Monero daemon connection.

    Parameters

    • url: string

      url of the daemon connection to remove

    Returns Promise<void>

  • Remove a posted offer, releasing its reserved funds.

    Parameters

    • offerId: string

      the offer id to cancel

    Returns 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 and the loser will get the rest.

    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>

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

  • Send a trade chat message.

    Parameters

    • tradeId: string

      the id of the trade

    • message: string

      the message

    Returns 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>

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

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

  • Enable or disable process logging.

    Parameters

    • enabled: boolean

      specifies if logging is enabled or disabled

    Returns void

  • Shutdown the Haveno daemon server and stop the process if applicable.

    Returns 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>

  • Stop checking the connection status periodically.

    Returns Promise<void>

  • Stops the local monero node.

    Returns Promise<void>

  • Take an offer.

    Returns

    the initialized trade

    Parameters

    • offerId: string

      id of the offer to take

    • paymentAccountId: string

      id of the payment account

    • Optional amount: bigint

      amount the taker chooses to buy or sell within the offer range (default is max offer amount)

    Returns Promise<TradeInfo>

  • Unregister as a dispute agent.

    Parameters

    • disputeAgentType: string

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

    Returns Promise<void>

  • Start a new Haveno process.

    Returns

    a client connected to the newly started 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>

Generated using TypeDoc