Options
All
  • Public
  • Public/Protected
  • All
Menu

Provides an interface to a daemon or similar, such as a blockchain cache

Hierarchy

  • IDaemon

Index

Events

  • on(event: "disconnect", callback: (error: Error) => void): IDaemon
  • on(event: "connect", callback: () => void): IDaemon
  • on(event: "heightchange", callback: (localDaemonBlockCount: number, networkDaemonBlockCount: number) => void): IDaemon
  • This is emitted whenever the interface fails to contact the underlying daemon. This event will only be emitted on the first disconnection. It will not be emitted again, until the daemon connects, and then disconnects again.

    Example:

    daemon.on('disconnect', (error) => {
    console.log('Possibly lost connection to daemon: ' + error.toString());
    });

    Parameters

    • event: "disconnect"
    • callback: (error: Error) => void
        • (error: Error): void
        • Parameters

          • error: Error

          Returns void

    Returns IDaemon

  • This is emitted whenever the interface previously failed to contact the underlying daemon, and has now reconnected. This event will only be emitted on the first connection. It will not be emitted again, until the daemon disconnects, and then reconnects again.

    Example:

    daemon.on('connect', () => {
    console.log('Regained connection to daemon!');
    });

    Parameters

    • event: "connect"
    • callback: () => void
        • (): void
        • Returns void

    Returns IDaemon

  • This is emitted whenever either the localDaemonBlockCount or the networkDaemonBlockCount changes.

    Example:

    daemon.on('heightchange', (localDaemonBlockCount, networkDaemonBlockCount) => {
    console.log(localDaemonBlockCount, networkDaemonBlockCount);
    });

    @event

    Parameters

    • event: "heightchange"
    • callback: (localDaemonBlockCount: number, networkDaemonBlockCount: number) => void
        • (localDaemonBlockCount: number, networkDaemonBlockCount: number): void
        • Parameters

          • localDaemonBlockCount: number
          • networkDaemonBlockCount: number

          Returns void

    Returns IDaemon

Methods

  • getCancelledTransactions(transactionHashes: string[]): Promise<string[]>
  • Get any transactions which we have sent, but are no longer present in the pool or a block. (They have returned to our wallet)

    Parameters

    • transactionHashes: string[]

    Returns Promise<string[]>

  • getConnectionString(): string
  • getGlobalIndexesForRange(startHeight: number, endHeight: number): Promise<Map<string, number[]>>
  • Parameters

    • startHeight: number
    • endHeight: number

    Returns Promise<Map<string, number[]>>

    Returns a mapping of transaction hashes to global indexes

    Get global indexes for the transactions in the range [startHeight, endHeight]

  • getLocalDaemonBlockCount(): number
  • Returns the height that the local daemon has.

    Returns number

  • getNetworkBlockCount(): number
  • Returns the height that the network has. Possibly 0 if can't connect to daemon

    Returns number

  • getRandomOutputsByAmount(amounts: number[], requestedOuts: number): Promise<[number, [number, string][]][]>
  • Gets random outputs for the given amounts. requestedOuts per. Usually mixin+1.

    Parameters

    • amounts: number[]
    • requestedOuts: number

    Returns Promise<[number, [number, string][]][]>

    Returns an array of amounts to global indexes and keys. There should be requestedOuts indexes if the daemon fully fulfilled our request.

  • getWalletSyncData(blockHashCheckpoints: string[], startHeight: number, startTimestamp: number): Promise<[Block[], boolean | TopBlock]>
  • Parameters

    • blockHashCheckpoints: string[]

      Hashes of the last known blocks. Later blocks (higher block height) should be ordered at the front of the array.

    • startHeight: number

      Height to start taking blocks from

    • startTimestamp: number

      Block timestamp to start taking blocks from

      Gets blocks from the daemon. Blocks are returned starting from the last known block hash (if higher than the startHeight/startTimestamp)

      Returns TopBlock data if daemon is synced, and daemon supports this feature.

    Returns Promise<[Block[], boolean | TopBlock]>

  • init(): Promise<void>
  • Initializes the daemon if necessary, with node fee and internal data

    Returns Promise<void>

  • nodeFee(): [string, number]
  • Gets the node fee address and amount. Will be ['', 0] if none/invalid

    Returns [string, number]

  • sendTransaction(rawTransaction: string): Promise<[boolean, undefined | string]>
  • Sends a raw serialized transaction to the daemon. Returns true/false based on daemon status.

    Will throw on timeout.

    Parameters

    • rawTransaction: string

    Returns Promise<[boolean, undefined | string]>

    Whether the transaction was accepted and an optional extra error message.

  • updateConfig(config: IConfig): void
  • updateDaemonInfo(): Promise<void>

Generated using TypeDoc