Interface DaemonRpcClient


public interface DaemonRpcClient
Represents a connection to a Monero P2P daemon.

See newInstance(URI) to create a new instance.

  • Method Details

    • newInstance

      static DaemonRpcClient newInstance(URI address)
      Create a new instance of a DaemonRpcClient
      Parameters:
      address - address of JSON-RPC endpoint, e.g. URI.create("http://localhost:18081/json_rpc")
      Returns:
      new instance of DaemonRpcClient
    • getBlock

      Block getBlock(long height)
      Get a block header and the transaction hashes it contains by its height.
      Parameters:
      height - height of block to look up (0 based)
      Returns:
      block containing header and transaction hashes
      See Also:
      getBlockAsync(long)
    • getBlockAsync

      CompletableFuture<Block> getBlockAsync(long height)
      Asynchronously get a block header and the transaction hashes it contains by its height.
      Parameters:
      height - height of block to look up (0 based)
      Returns:
      a future that completes to block containing header and transaction hashes
      See Also:
      getBlock(long)
    • getBlock

      Block getBlock(String hash)
      Get a block header and the transaction hashes it contains by its hash.
      Parameters:
      hash - hash of block to lookup
      Returns:
      block containing header and transaction hashes
      See Also:
      getBlock(long), getBlockAsync(String)
    • getBlockAsync

      CompletableFuture<Block> getBlockAsync(String hash)
      Asynchronously get a block header and the transaction hashes it contains by its hash.
      Parameters:
      hash - hash of block to lookup
      Returns:
      a future that completes to block containing header and transaction hashes
      See Also:
      getBlockAsync(long), getBlock(String)
    • getBlockCount

      long getBlockCount()
      Look up how many blocks are in the longest chain known to the daemon.
      Returns:
      number of blocks in longest chain seen by the node
      See Also:
      getBlockCountAsync()
    • getBlockCountAsync

      CompletableFuture<Long> getBlockCountAsync()
      Asynchronously look up how many blocks are in the longest chain known to the daemon.
      Returns:
      a future that completes to the number of blocks in the longest chain seen by the node
      See Also:
      getBlockCount()
    • getBlockHeader

      BlockHeader getBlockHeader(String hash)
      Fetch a block's header by its hash.
      Parameters:
      hash - hash of the block to lookup, as a hex string
      Returns:
      block header
      Throws:
      RpcException - for malformed or non-existent block hash
      See Also:
      getBlockHeader(long), getBlockHeaderAsync(String)
    • getBlockHeaderAsync

      CompletableFuture<BlockHeader> getBlockHeaderAsync(String hash)
      Asynchronously fetch a block's header by its hash.
      Parameters:
      hash - hash of the block to lookup, as a hex string
      Returns:
      a future that completes to the requested block header
      See Also:
      getBlockHeader(String)
    • getBlockHeader

      BlockHeader getBlockHeader(long height)
      Fetch a block's header by its height.
      Parameters:
      height - height of the block to lookup
      Returns:
      block header
      Throws:
      RpcException - for non-existent block height
      See Also:
      getBlockHeader(String), getBlockHeaderAsync(long)
    • getBlockHeaderAsync

      CompletableFuture<BlockHeader> getBlockHeaderAsync(long height)
      Asynchronously fetch a block's header by its height.
      Parameters:
      height - height of the block to lookup
      Returns:
      a future that completes to the requested block header
      See Also:
      getBlockHeader(long)
    • getBlockTemplate

      BlockTemplate getBlockTemplate(String walletAddress, int reserveSize)
      Create a block template.
      Parameters:
      walletAddress - wallet address to send mining reward to
      reserveSize - number of bytes to reserve for extra nonce in miner reward tx
      Returns:
      a new block template
      See Also:
      getBlockTemplateAsync(String, int)
    • getBlockTemplateAsync

      CompletableFuture<BlockTemplate> getBlockTemplateAsync(String walletAddress, int reserveSize)
      Asynchronously create a block template.
      Parameters:
      walletAddress - wallet address to send mining reward to
      reserveSize - number of bytes to reserve for extra nonce in miner reward tx
      Returns:
      a future that completes to a new block template
      See Also:
      getBlockTemplate(String, int)
    • submitBlock

      void submitBlock(String blob)
      Send a mined block for broadcast to the network.
      Parameters:
      blob - hex encoded block blob
    • submitBlockAsync

      CompletableFuture<Void> submitBlockAsync(String blob)
      Asynchronously send a mined block for broadcast to the network.
      Parameters:
      blob - hex encoded block blob
      Returns:
      a future that completes when the call is finished