Package monero.daemon

Interface MoneroDaemon

All Known Implementing Classes:
MoneroDaemonDefault, MoneroDaemonRpc

public interface MoneroDaemon
Monero daemon interface.
  • Method Details

    • addListener

      void addListener(MoneroDaemonListener listener)
      Register a listener to receive daemon notifications.
      Parameters:
      listener - the listener to unregister
    • removeListener

      void removeListener(MoneroDaemonListener listener)
      Unregister a listener to receive daemon notifications.
      Parameters:
      listener - a previously registered listener to be unregistered
    • getListeners

      List<MoneroDaemonListener> getListeners()
      Get the listeners registered with the daemon.
      Returns:
      the registered listeners
    • getVersion

      MoneroVersion getVersion()
      Gets the version of the daemon.
      Returns:
      the version of the daemon
    • isTrusted

      boolean isTrusted()
      Indicates if the daemon is trusted or untrusted.
      Returns:
      true if the daemon is trusted, false otherwise
    • getHeight

      long getHeight()
      Get the number of blocks in the longest chain known to the node.
      Returns:
      the number of blocks
    • getBlockHash

      String getBlockHash(long height)
      Get a block's hash by its height.
      Parameters:
      height - is the height of the block hash to get
      Returns:
      the block's hash at the given height
    • getBlockTemplate

      MoneroBlockTemplate getBlockTemplate(String walletAddress)
      Get a block template for mining a new block.
      Parameters:
      walletAddress - is the address of the wallet to receive miner transactions if block is successfully mined
      Returns:
      a block template for mining a new block
    • getBlockTemplate

      MoneroBlockTemplate getBlockTemplate(String walletAddress, Integer reserveSize)
      Get a block template for mining a new block.
      Parameters:
      walletAddress - is the address of the wallet to receive miner transactions if block is successfully mined
      reserveSize - is the reserve size (optional)
      Returns:
      a block template for mining a new block
    • getLastBlockHeader

      MoneroBlockHeader getLastBlockHeader()
      Get the last block's header.
      Returns:
      the last block's header
    • getBlockHeaderByHash

      MoneroBlockHeader getBlockHeaderByHash(String blockHash)
      Get a block header by its hash.
      Parameters:
      blockHash - is the hash of the block to get the header of
      Returns:
      the block's header
    • getBlockHeaderByHeight

      MoneroBlockHeader getBlockHeaderByHeight(long height)
      Get a block header by its height.
      Parameters:
      height - is the height of the block to get the header of
      Returns:
      the block's header
    • getBlockHeadersByRange

      List<MoneroBlockHeader> getBlockHeadersByRange(Long startHeight, Long endHeight)
      Get block headers for the given range.
      Parameters:
      startHeight - is the start height lower bound inclusive (optional)
      endHeight - is the end height upper bound inclusive (optional)
      Returns:
      block headers in the given range
    • getBlockByHash

      MoneroBlock getBlockByHash(String blockHash)
      Get a block by hash.
      Parameters:
      blockHash - is the hash of the block to get
      Returns:
      the block with the given hash
    • getBlocksByHash

      List<MoneroBlock> getBlocksByHash(List<String> blockHashes, Long startHeight, Boolean prune)
      Get blocks by hash.
      Parameters:
      blockHashes - are array of hashes; 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 - is the start height to get blocks by hash
      prune - specifies if returned blocks should be pruned (defaults to false) // TODO: test default
      Returns:
      the retrieved blocks
    • getBlockByHeight

      MoneroBlock getBlockByHeight(long height)
      Get a block by height.
      Parameters:
      height - is the height of the block to get
      Returns:
      the block at the given height
    • getBlocksByHeight

      List<MoneroBlock> getBlocksByHeight(List<Long> heights)
      Get blocks at the given heights.
      Parameters:
      heights - are the heights of the blocks to get
      Returns:
      blocks at the given heights
    • getBlocksByRange

      List<MoneroBlock> getBlocksByRange(Long startHeight, Long endHeight)
      Get blocks in the given height range.
      Parameters:
      startHeight - is the start height lower bound inclusive (optional)
      endHeight - is the end height upper bound inclusive (optional)
      Returns:
      blocks in the given height range
    • getBlocksByRangeChunked

      List<MoneroBlock> getBlocksByRangeChunked(Long startHeight, Long endHeight)
      Get blocks in the given height range as chunked requests so that each request is not too big.
      Parameters:
      startHeight - is the start height lower bound inclusive (optional)
      endHeight - is the end height upper bound inclusive (optional)
      Returns:
      blocks in the given height range
    • getBlocksByRangeChunked

      List<MoneroBlock> getBlocksByRangeChunked(Long startHeight, Long endHeight, Long maxChunkSize)
      Get blocks in the given height range as chunked requests so that each request is not too big.
      Parameters:
      startHeight - is the start height lower bound inclusive (optional)
      endHeight - is the end height upper bound inclusive (optional)
      maxChunkSize - is the maximum chunk size in any one request (default 3,000,000 bytes)
      Returns:
      blocks in the given height range
    • getBlockHashes

      List<String> getBlockHashes(List<String> blockHashes, Long startHeight)
      Get block hashes as a binary request to the daemon.
      Parameters:
      blockHashes - 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 - is the starting height of block hashes to return
      Returns:
      the requested block hashes
    • getTx

      MoneroTx getTx(String txHash)
      Get a transaction by hash.
      Parameters:
      txHash - is the hash of the transaction to get
      Returns:
      the transaction with the given hash or null if not found
    • getTx

      MoneroTx getTx(String txHash, Boolean prune)
      Get a transaction by hash.
      Parameters:
      txHash - is the hash of the transaction to get
      prune - specifies if the returned tx should be pruned (defaults to false)
      Returns:
      the transaction with the given hash or null if not found
    • getTxs

      List<MoneroTx> getTxs(Collection<String> txHashes)
      Get transactions by hashes.
      Parameters:
      txHashes - are hashes of transactions to get
      Returns:
      found transactions with the given hashes
    • getTxs

      List<MoneroTx> getTxs(Collection<String> txHashes, Boolean prune)
      Get transactions by hashes.
      Parameters:
      txHashes - are hashes of transactions to get
      prune - specifies if the returned txs should be pruned (defaults to false)
      Returns:
      found transactions with the given hashes
    • getTxHex

      String getTxHex(String txHash)
      Get a transaction hex by hash.
      Parameters:
      txHash - is the hash of the transaction to get hex from
      Returns:
      the tx hex with the given hash
    • getTxHex

      String getTxHex(String txHash, Boolean prune)
      Get a transaction hex by hash.
      Parameters:
      txHash - is the hash of the transaction to get hex from
      prune - specifies if the returned tx hex should be pruned (defaults to false)
      Returns:
      the tx hex with the given hash
    • getTxHexes

      List<String> getTxHexes(Collection<String> txHashes)
      Get transaction hexes by hashes.
      Parameters:
      txHashes - are hashes of transactions to get hexes from
      Returns:
      are the tx hexes
    • getTxHexes

      List<String> getTxHexes(Collection<String> txHashes, Boolean prune)
      Get transaction hexes by hashes.
      Parameters:
      txHashes - are hashes of transactions to get hexes from
      prune - specifies if the returned tx hexes should be pruned (defaults to false)
      Returns:
      are the tx hexes
    • getMinerTxSum

      MoneroMinerTxSum getMinerTxSum(long height, Long numBlocks)
      Gets the total emissions and fees from the genesis block to the current height.
      Parameters:
      height - is the height to start computing the miner sum
      numBlocks - are the number of blocks to include in the sum
      Returns:
      the sum emission and fees since the geneis block
    • getFeeEstimate

      MoneroFeeEstimate getFeeEstimate()
      Get mining fee estimates per kB.
      Returns:
      mining fee estimates per kB
    • getFeeEstimate

      MoneroFeeEstimate getFeeEstimate(Integer graceBlocks)
      Get mining fee estimates per kB.
      Parameters:
      graceBlocks - TODO
      Returns:
      mining fee estimates per kB
    • submitTxHex

      MoneroSubmitTxResult submitTxHex(String txHex)
      Submits a transaction to the daemon's pool.
      Parameters:
      txHex - is the raw transaction hex to submit
      Returns:
      the submission results
    • submitTxHex

      MoneroSubmitTxResult submitTxHex(String txHex, Boolean doNotRelay)
      Submits a transaction to the daemon's pool.
      Parameters:
      txHex - is the raw transaction hex to submit
      doNotRelay - specifies if the tx should be relayed (optional)
      Returns:
      the submission results
    • relayTxByHash

      void relayTxByHash(String txHash)
      Relays a transaction by hash.
      Parameters:
      txHash - identifies the transaction to relay
    • relayTxsByHash

      void relayTxsByHash(Collection<String> txHashes)
      Relays transactions by hash.
      Parameters:
      txHashes - identify the transactions to relay
    • getTxPool

      List<MoneroTx> getTxPool()
      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.
      Returns:
      transactions in the transaction pool
    • getTxPoolHashes

      List<String> getTxPoolHashes()
      Get hashes of transactions in the transaction pool.
      Returns:
      hashes of transactions in the transaction pool
    • getTxPoolBacklog

      List<MoneroTxBacklogEntry> getTxPoolBacklog()
      Get all transaction pool backlog.
      Returns:
      transaction pool backlog entries
    • getTxPoolStats

      MoneroTxPoolStats getTxPoolStats()
      Get transaction pool statistics.
      Returns:
      statistics about the transaction pool
    • flushTxPool

      void flushTxPool()
      Flushes all transactions from the tx pool.
    • flushTxPool

      void flushTxPool(String... hashes)
      Flush transactions from the tx pool.
      Parameters:
      hashes - are hashes of transactions to flush
    • flushTxPool

      void flushTxPool(Collection<String> hashes)
      Flush transactions from the tx pool.
      Parameters:
      hashes - are hashes of transactions to flush
    • getKeyImageSpentStatus

      MoneroKeyImageSpentStatus getKeyImageSpentStatus(String keyImage)
      Get the spent status of the given key image.
      Parameters:
      keyImage - is key image hex to get the status of
      Returns:
      the status of the key image
    • getKeyImageSpentStatuses

      List<MoneroKeyImageSpentStatus> getKeyImageSpentStatuses(Collection<String> keyImages)
      Get the spent status of each given key image.
      Parameters:
      keyImages - are hex key images to get the statuses of
      Returns:
      the spent status for each key image
    • getOutputs

      List<MoneroOutput> getOutputs(Collection<MoneroOutput> outputs)
      Get outputs identified by a list of output amounts and indices as a binary request.
      Parameters:
      outputs - identify each output by amount and index
      Returns:
      the identified outputs
    • getOutputHistogram

      List<MoneroOutputHistogramEntry> getOutputHistogram(Collection<BigInteger> amounts, Integer minCount, Integer maxCount, Boolean isUnlocked, Integer recentCutoff)
      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:
      amounts - are amounts of outputs to make the histogram with
      minCount - TODO
      maxCount - TODO
      isUnlocked - makes a histogram with outputs with the specified lock state
      recentCutoff - TODO
      Returns:
      output histogram entries meeting the parameters
    • getOutputDistribution

      List<MoneroOutputDistributionEntry> getOutputDistribution(Collection<BigInteger> amounts)
      Creates an output distribution.
      Parameters:
      amounts - are amounts of outputs to make the distribution with
      Returns:
      output distribution entries meeting the parameters
    • getOutputDistribution

      List<MoneroOutputDistributionEntry> getOutputDistribution(Collection<BigInteger> amounts, Boolean isCumulative, Long startHeight, Long endHeight)
      Creates an output distribution.
      Parameters:
      amounts - are amounts of outputs to make the distribution with
      isCumulative - specifies if the results should be cumulative (defaults to TODO)
      startHeight - is the start height lower bound inclusive (optional)
      endHeight - is the end height upper bound inclusive (optional)
      Returns:
      output distribution entries meeting the parameters
    • getInfo

      MoneroDaemonInfo getInfo()
      Get general information about the state of the node and the network.
      Returns:
      general information about the node and network
    • getSyncInfo

      MoneroDaemonSyncInfo getSyncInfo()
      Get synchronization information.
      Returns:
      contains sync information
    • getHardForkInfo

      MoneroHardForkInfo getHardForkInfo()
      Look up information regarding hard fork voting and readiness.
      Returns:
      hard fork information
    • getAltChains

      List<MoneroAltChain> getAltChains()
      Get alternative chains seen by the node.
      Returns:
      alternative chains seen by the node
    • getAltBlockHashes

      List<String> getAltBlockHashes()
      Get known block hashes which are not on the main chain.
      Returns:
      known block hashes which are not on the main chain
    • getDownloadLimit

      int getDownloadLimit()
      Get the download bandwidth limit.
      Returns:
      is the download bandwidth limit
    • setDownloadLimit

      int setDownloadLimit(int limit)
      Set the download bandwidth limit.
      Parameters:
      limit - is the download limit to set (-1 to reset to default)
      Returns:
      int is the new download limit after setting
    • resetDownloadLimit

      int resetDownloadLimit()
      Reset the download bandwidth limit.
      Returns:
      the download bandwidth limit after resetting
    • getUploadLimit

      int getUploadLimit()
      Get the upload bandwidth limit.
      Returns:
      is the upload bandwidth limit
    • setUploadLimit

      int setUploadLimit(int limit)
      Set the upload bandwidth limit.
      Parameters:
      limit - is the upload limit to set (-1 to reset to default)
      Returns:
      int is the new upload limit after setting
    • resetUploadLimit

      int resetUploadLimit()
      Reset the upload bandwidth limit.
      Returns:
      the upload bandwidth limit after resetting
    • getPeers

      List<MoneroPeer> getPeers()
      Get peers with active incoming or outgoing connections to the node.
      Returns:
      the daemon's peers
    • getKnownPeers

      List<MoneroPeer> getKnownPeers()
      Get all known peers including their last known online status.
      Returns:
      the daemon's known peers
    • setOutgoingPeerLimit

      void setOutgoingPeerLimit(int limit)
      Limit number of outgoing peers.
      Parameters:
      limit - is the maximum number of outgoing peers
    • setIncomingPeerLimit

      void setIncomingPeerLimit(int limit)
      Limit number of incoming peers.
      Parameters:
      limit - is the maximum number of incoming peers
    • getPeerBans

      List<MoneroBan> getPeerBans()
      Get peer bans.
      Returns:
      entries about banned peers
    • setPeerBan

      void setPeerBan(MoneroBan ban)
      Ban a peer node.
      Parameters:
      ban - contains information about a node to ban
    • setPeerBans

      void setPeerBans(List<MoneroBan> bans)
      Ban peers nodes.
      Parameters:
      bans - are bans to apply against peer nodes
    • startMining

      void startMining(String address, Long numThreads, Boolean isBackground, Boolean ignoreBattery)
      Start mining.
      Parameters:
      address - is the address given miner rewards if the daemon mines a block
      numThreads - is the number of mining threads to run
      isBackground - specifies if the miner should run in the background or not
      ignoreBattery - specifies if the battery state (e.g. on laptop) should be ignored or not
    • stopMining

      void stopMining()
      Stop mining.
    • getMiningStatus

      MoneroMiningStatus getMiningStatus()
      Get the daemon's mining status.
      Returns:
      the daemon's mining status
    • submitBlock

      void submitBlock(String blockBlob)
      Submit a mined block to the network.
      Parameters:
      blockBlob - is the mined block to submit
    • submitBlocks

      void submitBlocks(Collection<String> blockBlobs)
      Submit mined blocks to the network.
      Parameters:
      blockBlobs - are the mined blocks to submit
    • pruneBlockchain

      MoneroPruneResult pruneBlockchain(boolean check)
      Prune the blockchain.
      Parameters:
      check - specifies to check the pruning (default false)
      Returns:
      the prune result
    • checkForUpdate

      Check for update.
      Returns:
      the result of the update check
    • downloadUpdate

      Download an update.
      Returns:
      the result of the update download
    • downloadUpdate

      Download an update.
      Parameters:
      path - is the path to download the update (optional)
      Returns:
      the result of the update download
    • stop

      void stop()
      Safely disconnect and shut down the daemon.
    • waitForNextBlockHeader

      MoneroBlockHeader waitForNextBlockHeader()
      Get the header of the next block added to the chain.
      Returns:
      the header of the next block added to the chain
    • parseNetworkType

      static MoneroNetworkType parseNetworkType(String network)
      Parses a network string to an enumerated type.
      Parameters:
      network - is the network string to parse
      Returns:
      the enumerated network type