# Interface: MoneroDaemon

## MoneroDaemon

Monero daemon interface and default implementations.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 30

### Methods

#### (async) addListener(listener)

Register a listener to receive daemon notifications.

##### Parameters:

Name | Type | Description
--- | --- | ---
`listener` | MoneroDaemonListener | listener to receive daemon notifications

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 37

#### (async) checkForUpdate() → {MoneroDaemonUpdateCheckResult}

Check for update.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 664

##### Returns:

the result

Type
  MoneroDaemonUpdateCheckResult

#### (async) downloadUpdate(path) → {MoneroDaemonUpdateDownloadResult}

Download an update.

##### Parameters:

Name | Type | Description
--- | --- | ---
`path` | string | path to download the update (optional)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 674

##### Returns:

the result

Type
  MoneroDaemonUpdateDownloadResult

#### (async) flushTxPool(hashes)

Flush transactions from the tx pool.

##### Parameters:

Name | Type | Description
--- | --- | ---
`hashes` | string | Array.<string> | specific transactions to flush (defaults to all)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 375

#### (async) getAltBlockHashes() → {Array.<string>}

Get known block hashes which are not on the main chain.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 480

##### Returns:

known block hashes which are not on the main chain

Type
  Array.<string>

#### (async) getAltChains() → {Array.<MoneroAltChain>}

Get alternative chains seen by the node.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 471

##### Returns:

alternative chains

Type
  Array.<MoneroAltChain>

#### (async) getBlockByHash(blockHash) → {MoneroBlock}

Get a block by hash.

##### Parameters:

Name | Type | Description
--- | --- | ---
`blockHash` | string | hash of the block to get

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 162

##### Returns:

with the given hash

Type
  MoneroBlock

#### (async) getBlockByHeight(height) → {MoneroBlock}

Get a block by height.

##### Parameters:

Name | Type | Description
--- | --- | ---
`height` | int | height of the block to get

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 186

##### Returns:

with the given height

Type
  MoneroBlock

#### (async) getBlockHash(height) → {string}

Get a block's hash by its height.

##### Parameters:

Name | Type | Description
--- | --- | ---
`height` | int | height of the block hash to get

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 101

##### Returns:

the block's hash at the given height

Type
  string

#### (async) getBlockHashes(blockHashes, startHeight) → {Array.<string>}

Get block hashes as a binary request to the daemon.

##### Parameters:

Name | Type | Description
--- | --- | ---
`blockHashes` | Array.<string> | specify block hashes to fetch; first 10 blocks hash goes sequential, next goes in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block
`startHeight` | int | starting height of block hashes to return

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 233

##### Returns:

requested block hashes

Type
  Array.<string>

#### (async) getBlockHeaderByHash(blockHash) → {MoneroBlockHeader}

Get a block header by its hash.

##### Parameters:

Name | Type | Description
--- | --- | ---
`blockHash` | string | hash of the block to get the header of

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 131

##### Returns:

block's header

Type
  MoneroBlockHeader

#### (async) getBlockHeaderByHeight(height) → {MoneroBlockHeader}

Get a block header by its height.

##### Parameters:

Name | Type | Description
--- | --- | ---
`height` | int | height of the block to get the header of

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 141

##### Returns:

block's header

Type
  MoneroBlockHeader

#### (async) getBlockHeadersByRange(startHeight, endHeight) → {Array.<MoneroBlockHeader>}

Get block headers for the given range.

##### Parameters:

Name | Type | Description
--- | --- | ---
`startHeight` | int | start height lower bound inclusive (optional)
`endHeight` | int | end height upper bound inclusive (optional)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 152

##### Returns:

for the given range

Type
  Array.<MoneroBlockHeader>

#### (async) getBlockTemplate(walletAddress, reserveSize) → {MoneroBlockTemplate}

Get a block template for mining a new block.

##### Parameters:

Name | Type | Description
--- | --- | ---
`walletAddress` | string | address of the wallet to receive miner transactions if block is successfully mined
`reserveSize` | int | reserve size (optional)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 112

##### Returns:

is a block template for mining a new block

Type
  MoneroBlockTemplate

#### (async) getBlocksByHash(blockHashes, startHeight, prune) → {Array.<MoneroBlock>}

Get blocks by hash.

##### Parameters:

Name | Type | Description
--- | --- | ---
`blockHashes` | Array.<string> | array of hashes; first 10 blocks hashes goes sequential, next goes in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block
`startHeight` | int | start height to get blocks by hash
`prune` | boolean | specifies if returned blocks should be pruned (defaults to false) // TODO: test default

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 176

##### Returns:

retrieved blocks

Type
  Array.<MoneroBlock>

#### (async) getBlocksByHeight(heights) → {Array.<MoneroBlock>}

Get blocks at the given heights.

##### Parameters:

Name | Type | Description
--- | --- | ---
`heights` | Array.<int> | heights of the blocks to get

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 196

##### Returns:

are blocks at the given heights

Type
  Array.<MoneroBlock>

#### (async) getBlocksByRange(startHeight, endHeight) → {Array.<MoneroBlock>}

Get blocks in the given height range.

##### Parameters:

Name | Type | Description
--- | --- | ---
`startHeight` | int | start height lower bound inclusive (optional)
`endHeight` | int | end height upper bound inclusive (optional)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 207

##### Returns:

are blocks in the given height range

Type
  Array.<MoneroBlock>

#### (async) getBlocksByRangeChunked(startHeight, endHeight, maxChunkSize) → {Array.<MoneroBlock>}

Get blocks in the given height range as chunked requests so that each request is not too big.

##### Parameters:

Name | Type | Description
--- | --- | ---
`startHeight` | int | start height lower bound inclusive (optional)
`endHeight` | int | end height upper bound inclusive (optional)
`maxChunkSize` | int | maximum chunk size in any one request (default 3,000,000 bytes)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 220

##### Returns:

blocks in the given height range

Type
  Array.<MoneroBlock>

#### (async) getDownloadLimit() → {int}

Get the download bandwidth limit.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 489

##### Returns:

download bandwidth limit

Type
  int

#### (async) getFeeEstimate(graceBlocks) → {MoneroFeeEstimate}

Get mining fee estimates per kB.

##### Parameters:

Name | Type | Description
--- | --- | ---
`graceBlocks` | number | TODO

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 298

##### Returns:

mining fee estimates per kB

Type
  MoneroFeeEstimate

#### (async) getHardForkInfo() → {MoneroHardForkInfo}

Look up information regarding hard fork voting and readiness.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 462

##### Returns:

contains hard fork information

Type
  MoneroHardForkInfo

#### (async) getHeight() → {int}

Get the number of blocks in the longest chain known to the node.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 91

##### Returns:

the number of blocks

Type
  int

#### (async) getInfo() → {MoneroDaemonInfo}

Get general information about the state of the node and the network.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 444

##### Returns:

is general information about the node and network

Type
  MoneroDaemonInfo

#### (async) getKeyImageSpentStatus(keyImage) → {MoneroKeyImageSpentStatus}

Get the spent status of the given key image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`keyImage` | string | key image hex to get the status of

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 385

##### Returns:

status of the key image

Type
  MoneroKeyImageSpentStatus

#### (async) getKeyImageSpentStatuses(keyImages) → {Array.<MoneroKeyImageSpentStatus>}

Get the spent status of each given key image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`keyImages` | Array.<string> | are hex key images to get the statuses of

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 395

##### Returns:

status for each key image

Type
  Array.<MoneroKeyImageSpentStatus>

#### (async) getKnownPeers() → {Array.<MoneroPeer>}

Get known peers including their last known online status.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 554

##### Returns:

the daemon's known peers

Type
  Array.<MoneroPeer>

#### (async) getLastBlockHeader() → {MoneroBlockHeader}

Get the last block's header.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 121

##### Returns:

last block's header

Type
  MoneroBlockHeader

#### getListeners() → {Array.<MoneroDaemonListener>}

Get the listeners registered with the daemon.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 55

##### Returns:

the registered listeners

Type
  Array.<MoneroDaemonListener>

#### (async) getMinerTxSum(height, numBlocks) → {MoneroMinerTxSum}

Gets the total emissions and fees from the genesis block to the current height.

##### Parameters:

Name | Type | Description
--- | --- | ---
`height` | int | height to start computing the miner sum
`numBlocks` | int | number of blocks to include in the sum

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 288

##### Returns:

encapsulates the total emissions and fees since the genesis block

Type
  MoneroMinerTxSum

#### (async) getMiningStatus() → {MoneroMiningStatus}

Get the daemon's mining status.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 627

##### Returns:

daemon's mining status

Type
  MoneroMiningStatus

#### (async) getOutputDistribution(amounts, cumulative, startHeight, endHeight) → {Array.<MoneroOutputDistributionEntry>}

Creates an output distribution.

##### Parameters:

Name | Type | Description
--- | --- | ---
`amounts` | Array.<BigInteger> | amounts of outputs to make the distribution with
`cumulative` | boolean | specifies if the results should be cumulative (defaults to TODO)
`startHeight` | int | start height lower bound inclusive (optional)
`endHeight` | int | end height upper bound inclusive (optional)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 435

##### Returns:

are entries meeting the parameters

Type
  Array.<MoneroOutputDistributionEntry>

#### (async) getOutputHistogram(amounts, minCount, maxCount, isUnlocked, recentCutoff) → {Array.<MoneroOutputHistogramEntry>}

Get a histogram of output amounts. For all amounts (possibly filtered by parameters), gives the number of outputs on the chain for that amount. RingCT outputs counts as 0 amount.

##### Parameters:

Name | Type | Description
--- | --- | ---
`amounts` | Array.<BigInteger> | amounts of outputs to make the histogram with
`minCount` | int | TODO
`maxCount` | int | TODO
`isUnlocked` | boolean | makes a histogram with outputs with the specified lock state
`recentCutoff` | int | TODO

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 422

##### Returns:

are entries meeting the parameters

Type
  Array.<MoneroOutputHistogramEntry>

#### (async) getOutputs(outputs) → {Array.<MoneroOutput>}

Get outputs identified by a list of output amounts and indices as a binary request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`outputs` | Array.<MoneroOutput> | identify each output by amount and index

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 406

##### Returns:

identified outputs

Type
  Array.<MoneroOutput>

#### (async) getPeerBans() → {Array.<MoneroBan>}

Get peer bans.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 581

##### Returns:

entries about banned peers

Type
  Array.<MoneroBan>

#### (async) getPeers() → {Array.<MoneroPeer>}

Get peers with active incoming or outgoing connections to the node.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 545

##### Returns:

the daemon's peers

Type
  Array.<MoneroPeer>

#### (async) getSyncInfo() → {MoneroDaemonSyncInfo}

Get synchronization information.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 453

##### Returns:

contains sync information

Type
  MoneroDaemonSyncInfo

#### (async) getTx(txHash, prune) → {MoneroTx}

Get a transaction by hash.

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`txHash` | string |  | hash of the transaction to get
`prune` | boolean | false | specifies if the returned tx should be pruned (defaults to false)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 244

##### Returns:

transaction with the given hash or undefined if not found

Type
  MoneroTx

#### (async) getTxHex(txHash, prune) → {string}

Get a transaction hex by hash.

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`txHash` | string |  | hash of the transaction to get hex from
`prune` | boolean | false | specifies if the returned tx hex should be pruned (defaults to false)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 266

##### Returns:

tx hex with the given hash

Type
  string

#### (async) getTxHexes(txHashes, prune) → {Array.<string>}

Get transaction hexes by hashes.

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`txHashes` | Array.<string> |  | hashes of transactions to get hexes from
`prune` | boolean | false | specifies if the returned tx hexes should be pruned (defaults to false)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 277

##### Returns:

tx hexes

Type
  Array.<string>

#### (async) getTxPool() → {Array.<MoneroTx>}

Get valid transactions seen by the node but not yet mined into a block, as well as spent key image information for the tx pool.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 339

##### Returns:

are transactions in the transaction pool

Type
  Array.<MoneroTx>

#### (async) getTxPoolBacklog() → {Array.<MoneroTxBacklogEntry>}

Get all transaction pool backlog.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 357

##### Returns:

backlog entries

Type
  Array.<MoneroTxBacklogEntry>

#### (async) getTxPoolHashes() → {Array.<string>}

Get hashes of transactions in the transaction pool.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 348

##### Returns:

are hashes of transactions in the transaction pool

Type
  Array.<string>

#### (async) getTxPoolStats() → {MoneroTxPoolStats}

Get transaction pool statistics.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 366

##### Returns:

contains statistics about the transaction pool

Type
  MoneroTxPoolStats

#### (async) getTxs(txHashes, prune) → {Array.<MoneroTx>}

Get transactions by hashes.

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`txHashes` | Array.<string> |  | hashes of transactions to get
`prune` | boolean | false | specifies if the returned txs should be pruned (defaults to false)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 255

##### Returns:

found transactions with the given hashes

Type
  Array.<MoneroTx>

#### (async) getUploadLimit() → {int}

Get the upload bandwidth limit.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 517

##### Returns:

upload bandwidth limit

Type
  int

#### (async) getVersion() → {MoneroVersion}

Gets the version of the daemon.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 73

##### Returns:

the version of the daemon

Type
  MoneroVersion

#### (async) isConnected() → {boolean}

Indicates if the client is connected to the daemon via RPC.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 64

##### Returns:

true if the client is connected to the daemon, false otherwise

Type
  boolean

#### (async) isTrusted() → {boolean}

Indicates if the daemon is trusted xor untrusted.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 82

##### Returns:

true if the daemon is trusted, false otherwise

Type
  boolean

#### (async) pruneBlockchain(check) → {MoneroPruneResult}

Prune the blockchain.

##### Parameters:

Name | Type | Description
--- | --- | ---
`check` | boolean | specifies to check the pruning (default false)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 646

##### Returns:

the prune result

Type
  MoneroPruneResult

#### (async) relayTxByHash(txHash)

Relays a transaction by hash.

##### Parameters:

Name | Type | Description
--- | --- | ---
`txHash` | string | hash of the transaction to relay

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 318

#### (async) relayTxsByHash(txHashes)

Relays transactions by hash.

##### Parameters:

Name | Type | Description
--- | --- | ---
`txHashes` | Array.<string> | hashes of the transactinos to relay

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 329

#### (async) removeListener(listener)

Unregister a listener to receive daemon notifications.

##### Parameters:

Name | Type | Description
--- | --- | ---
`listener` | MoneroDaemonListener | listener to unregister

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 46

#### (async) resetDownloadLimit() → {int}

Reset the download bandwidth limit.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 508

##### Returns:

download bandwidth limit after resetting

Type
  int

#### (async) resetUploadLimit() → {int}

Reset the upload bandwidth limit.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 536

##### Returns:

upload bandwidth limit after resetting

Type
  int

#### (async) setDownloadLimit(limit) → {int}

Set the download bandwidth limit.

##### Parameters:

Name | Type | Description
--- | --- | ---
`limit` | int | download limit to set (-1 to reset to default)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 499

##### Returns:

new download limit after setting

Type
  int

#### (async) setIncomingPeerLimit(limit)

Limit number of incoming peers.

##### Parameters:

Name | Type | Description
--- | --- | ---
`limit` | int | maximum number of incoming peers

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 572

#### (async) setOutgoingPeerLimit(limit)

Limit number of outgoing peers.

##### Parameters:

Name | Type | Description
--- | --- | ---
`limit` | int | maximum number of outgoing peers

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 563

#### (async) setPeerBan(ban)

Ban a peer node.

##### Parameters:

Name | Type | Description
--- | --- | ---
`ban` | MoneroBan | contains information about a node to ban

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 590

#### (async) setPeerBans(bans)

Ban peers nodes.

##### Parameters:

Name | Type | Description
--- | --- | ---
`bans` | Array.<MoneroBan> | specify which peers to ban

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 599

#### (async) setUploadLimit(limit) → {int}

Set the upload bandwidth limit.

##### Parameters:

Name | Type | Description
--- | --- | ---
`limit` |  | upload limit to set (-1 to reset to default)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 527

##### Returns:

new upload limit after setting

Type
  int

#### (async) startMining(address, numThreads, isBackground, ignoreBattery)

Start mining.

##### Parameters:

Name | Type | Description
--- | --- | ---
`address` | string | address given miner rewards if the daemon mines a block
`numThreads` | integer | number of mining threads to run
`isBackground` | boolean | specifies if the miner should run in the background or not
`ignoreBattery` | boolean | specifies if the battery state (e.g. on laptop) should be ignored or not

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 611

#### (async) stop()

Safely disconnect and shut down the daemon.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 681

#### (async) stopMining()

Stop mining.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 618

#### (async) submitBlock(blockBlob)

Submit a mined block to the network.

##### Parameters:

Name | Type | Description
--- | --- | ---
`blockBlob` | string | mined block to submit

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 636

#### (async) submitBlocks(blockBlobs)

Submit mined blocks to the network.

##### Parameters:

Name | Type | Description
--- | --- | ---
`blockBlobs` | Array.<string> | mined blocks to submit

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 655

#### (async) submitTxHex(txHex, doNotRelay) → {MoneroSubmitTxResult}

Submits a transaction to the daemon's pool.

##### Parameters:

Name | Type | Description
--- | --- | ---
`txHex` | string | raw transaction hex to submit
`doNotRelay` | boolean | specifies if the tx should be relayed (optional)

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 309

##### Returns:

contains submission results

Type
  MoneroSubmitTxResult

#### (async) waitForNextBlockHeader() → {MoneroBlockHeader}

Get the header of the next block added to the chain.

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 690

##### Returns:

header of the next block added to the chain

Type
  MoneroBlockHeader

#### (static) parseNetworkType(network) → {MoneroNetworkType}

Parses a network string to an enumerated type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`network` | string | network string to parse

Source:
  - src/main/js/daemon/MoneroDaemon.js, line 702

##### Returns:

enumerated network type

Type
  MoneroNetworkType