Package monero.daemon
Class MoneroDaemonRpc
java.lang.Object
monero.daemon.MoneroDaemonDefault
monero.daemon.MoneroDaemonRpc
- All Implemented Interfaces:
MoneroDaemon
Implements a Monero daemon using monerod.
TODO: every call needs to checkResponseStatus
-
Constructor Summary
ConstructorsConstructorDescriptionMoneroDaemonRpc(String uri) MoneroDaemonRpc(String uri, String username, String password) MoneroDaemonRpc(URI uri) MoneroDaemonRpc(List<String> cmd) Create an internal process running monerod and connect to it. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(MoneroDaemonListener listener) Register a listener to receive daemon notifications.Check for update.downloadUpdate(String path) Download an update.voidFlushes all transactions from the tx pool.voidflushTxPool(String... hashes) Flush transactions from the tx pool.voidflushTxPool(Collection<String> hashes) Flush transactions from the tx pool.Get known block hashes which are not on the main chain.Get alternative chains seen by the node.getBlockByHash(String blockHash) Get a block by hash.getBlockByHeight(long height) Get a block by height.getBlockHash(long height) Get a block's hash by its height.getBlockHashes(List<String> blockHashes, Long startHeight) Get block hashes as a binary request to the daemon.getBlockHeaderByHash(String blockHash) Get a block header by its hash.getBlockHeaderByHeight(long height) Get a block header by its height.getBlockHeadersByRange(Long startHeight, Long endHeight) Get block headers for the given range.getBlocksByHash(List<String> blockHashes, Long startHeight, Boolean prune) Get blocks by hash.getBlocksByHeight(List<Long> heights) Get blocks at the given heights.getBlocksByRange(Long startHeight, Long endHeight) Get blocks in the given height range.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.getBlockTemplate(String walletAddress, Integer reserveSize) Get a block template for mining a new block.intGet the download bandwidth limit.getFeeEstimate(Integer graceBlocks) Get mining fee estimates per kB.Look up information regarding hard fork voting and readiness.longGet the number of blocks in the longest chain known to the node.getInfo()Get general information about the state of the node and the network.getKeyImageSpentStatuses(List<String> keyImages) Get the spent status of each given key image.Get all known peers including their last known online status.Get the last block's header.Get the listeners registered with the daemon.getMinerTxSum(long height, Long numBlocks) Gets the total emissions and fees from the genesis block to the current height.Get the daemon's mining status.getOutputDistribution(Collection<BigInteger> amounts, Boolean isCumulative, Long startHeight, Long endHeight) Creates an output distribution.getOutputHistogram(Collection<BigInteger> amounts, Integer minCount, Integer maxCount, Boolean isUnlocked, Integer recentCutoff) Get a histogram of output amounts.getOutputs(Collection<MoneroOutput> outputs) Get outputs identified by a list of output amounts and indices as a binary request.Get peer bans.getPeers()Get peers with active incoming or outgoing connections to the node.Get the internal process running monero-wallet-rpc.Get the daemon's RPC connection.Get synchronization information.getTxHexes(Collection<String> txHashes, Boolean prune) Get transaction hexes by hashes.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.Get all transaction pool backlog.Get hashes of transactions in the transaction pool.Get transaction pool statistics.getTxs(Collection<String> txHashes, Boolean prune) Get transactions by hashes.intGet the upload bandwidth limit.Gets the version of the daemon.booleanIndicates if the client is connected to the daemon via RPC.booleanIndicates if the daemon is trusted or untrusted.pruneBlockchain(boolean check) Prune the blockchain.voidrelayTxsByHash(Collection<String> txHashes) Relays transactions by hash.voidremoveListener(MoneroDaemonListener listener) Unregister a listener to receive daemon notifications.intReset the download bandwidth limit.intReset the upload bandwidth limit.intsetDownloadLimit(int limit) Set the download bandwidth limit.voidsetIncomingPeerLimit(int limit) Limit number of incoming peers.voidsetOutgoingPeerLimit(int limit) Limit number of outgoing peers.voidsetPeerBans(List<MoneroBan> bans) Ban peers nodes.voidsetProxyUri(String uri) Set the Tor proxy to the daemon.voidSet the daemon's RPC connection.intsetUploadLimit(int limit) Set the upload bandwidth limit.voidstartMining(String address, Long numThreads, Boolean isBackground, Boolean ignoreBattery) Start mining.voidstop()Safely disconnect and shut down the daemon.voidStop mining.intStop the internal process running monero-wallet-rpc, if applicable.intstopProcess(boolean force) Stop the internal process running monerod, if applicable.voidsubmitBlocks(Collection<String> blockBlobs) Submit mined blocks to the network.submitTxHex(String txHex, Boolean doNotRelay) Submits a transaction to the daemon's pool.Get the header of the next block added to the chain.Methods inherited from class monero.daemon.MoneroDaemonDefault
downloadUpdate, getBlocksByRangeChunked, getBlockTemplate, getFeeEstimate, getKeyImageSpentStatus, getOutputDistribution, getTx, getTx, getTxHex, getTxHex, getTxHexes, getTxs, relayTxByHash, setPeerBan, submitBlock, submitTxHex
-
Constructor Details
-
MoneroDaemonRpc
-
MoneroDaemonRpc
-
MoneroDaemonRpc
-
MoneroDaemonRpc
-
MoneroDaemonRpc
Create an internal process running monerod and connect to it. Use `stopProcess()` to stop the newly created process.- Parameters:
cmd- path then arguments to external monerod executable- Throws:
IOException- if input/output error with process
-
-
Method Details
-
getProcess
Get the internal process running monero-wallet-rpc.- Returns:
- the process running monero-wallet-rpc, null if not created from new process
-
stopProcess
public int stopProcess()Stop the internal process running monero-wallet-rpc, if applicable.- Returns:
- the error code from stopping the process
-
stopProcess
public int stopProcess(boolean force) Stop the internal process running monerod, if applicable.- Parameters:
force- specifies if the process should be destroyed forcibly- Returns:
- the error code from stopping the process
-
addListener
Description copied from interface:MoneroDaemonRegister a listener to receive daemon notifications.- Parameters:
listener- the listener to unregister
-
removeListener
Description copied from interface:MoneroDaemonUnregister a listener to receive daemon notifications.- Parameters:
listener- a previously registered listener to be unregistered
-
getListeners
Description copied from interface:MoneroDaemonGet the listeners registered with the daemon.- Returns:
- the registered listeners
-
getRpcConnection
Get the daemon's RPC connection.- Returns:
- the daemon's rpc connection
-
setRpcConnection
Set the daemon's RPC connection.- Parameters:
rpc- the daemon's rpc connection
-
setProxyUri
Set the Tor proxy to the daemon.- Parameters:
uri- the Tor proxy URI
-
isConnected
public boolean isConnected()Indicates if the client is connected to the daemon via RPC.- Returns:
- true if the client is connected to the daemon, false otherwise
-
getVersion
Description copied from interface:MoneroDaemonGets the version of the daemon.- Returns:
- the version of the daemon
-
isTrusted
public boolean isTrusted()Description copied from interface:MoneroDaemonIndicates if the daemon is trusted or untrusted.- Returns:
- true if the daemon is trusted, false otherwise
-
getHeight
public long getHeight()Description copied from interface:MoneroDaemonGet the number of blocks in the longest chain known to the node.- Returns:
- the number of blocks
-
getBlockHash
Description copied from interface:MoneroDaemonGet 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
Description copied from interface:MoneroDaemonGet a block template for mining a new block.- Parameters:
walletAddress- is the address of the wallet to receive miner transactions if block is successfully minedreserveSize- is the reserve size (optional)- Returns:
- a block template for mining a new block
-
getLastBlockHeader
Description copied from interface:MoneroDaemonGet the last block's header.- Returns:
- the last block's header
-
getBlockHeaderByHash
Description copied from interface:MoneroDaemonGet 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
Description copied from interface:MoneroDaemonGet 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
Description copied from interface:MoneroDaemonGet 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
Description copied from interface:MoneroDaemonGet a block by hash.- Parameters:
blockHash- is the hash of the block to get- Returns:
- the block with the given hash
-
getBlocksByHash
Description copied from interface:MoneroDaemonGet 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 blockstartHeight- is the start height to get blocks by hashprune- specifies if returned blocks should be pruned (defaults to false) // TODO: test default- Returns:
- the retrieved blocks
-
getBlockByHeight
Description copied from interface:MoneroDaemonGet a block by height.- Parameters:
height- is the height of the block to get- Returns:
- the block at the given height
-
getBlocksByHeight
Description copied from interface:MoneroDaemonGet blocks at the given heights.- Parameters:
heights- are the heights of the blocks to get- Returns:
- blocks at the given heights
-
getBlocksByRange
Description copied from interface:MoneroDaemonGet 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
public List<MoneroBlock> getBlocksByRangeChunked(Long startHeight, Long endHeight, Long maxChunkSize) Description copied from interface:MoneroDaemonGet 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
Description copied from interface:MoneroDaemonGet 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 blockstartHeight- is the starting height of block hashes to return- Returns:
- the requested block hashes
-
getTxs
Description copied from interface:MoneroDaemonGet transactions by hashes.- Parameters:
txHashes- are hashes of transactions to getprune- specifies if the returned txs should be pruned (defaults to false)- Returns:
- found transactions with the given hashes
-
getTxHexes
Description copied from interface:MoneroDaemonGet transaction hexes by hashes.- Parameters:
txHashes- are hashes of transactions to get hexes fromprune- specifies if the returned tx hexes should be pruned (defaults to false)- Returns:
- are the tx hexes
-
getMinerTxSum
Description copied from interface:MoneroDaemonGets the total emissions and fees from the genesis block to the current height.- Parameters:
height- is the height to start computing the miner sumnumBlocks- are the number of blocks to include in the sum- Returns:
- the sum emission and fees since the geneis block
-
getFeeEstimate
Description copied from interface:MoneroDaemonGet mining fee estimates per kB.- Parameters:
graceBlocks- TODO- Returns:
- mining fee estimates per kB
-
submitTxHex
Description copied from interface:MoneroDaemonSubmits a transaction to the daemon's pool.- Parameters:
txHex- is the raw transaction hex to submitdoNotRelay- specifies if the tx should be relayed (optional)- Returns:
- the submission results
-
relayTxsByHash
Description copied from interface:MoneroDaemonRelays transactions by hash.- Parameters:
txHashes- identify the transactions to relay
-
getTxPool
Description copied from interface:MoneroDaemonGet 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
Description copied from interface:MoneroDaemonGet hashes of transactions in the transaction pool.- Returns:
- hashes of transactions in the transaction pool
-
getTxPoolBacklog
Description copied from interface:MoneroDaemonGet all transaction pool backlog.- Returns:
- transaction pool backlog entries
-
getTxPoolStats
Description copied from interface:MoneroDaemonGet transaction pool statistics.- Returns:
- statistics about the transaction pool
-
flushTxPool
public void flushTxPool()Description copied from interface:MoneroDaemonFlushes all transactions from the tx pool. -
flushTxPool
Description copied from interface:MoneroDaemonFlush transactions from the tx pool.- Parameters:
hashes- are hashes of transactions to flush
-
flushTxPool
Description copied from interface:MoneroDaemonFlush transactions from the tx pool.- Parameters:
hashes- are hashes of transactions to flush
-
getKeyImageSpentStatuses
Description copied from interface:MoneroDaemonGet 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
Description copied from interface:MoneroDaemonGet 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
public List<MoneroOutputHistogramEntry> getOutputHistogram(Collection<BigInteger> amounts, Integer minCount, Integer maxCount, Boolean isUnlocked, Integer recentCutoff) Description copied from interface:MoneroDaemonGet 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 withminCount- TODOmaxCount- TODOisUnlocked- makes a histogram with outputs with the specified lock staterecentCutoff- TODO- Returns:
- output histogram entries meeting the parameters
-
getOutputDistribution
public List<MoneroOutputDistributionEntry> getOutputDistribution(Collection<BigInteger> amounts, Boolean isCumulative, Long startHeight, Long endHeight) Description copied from interface:MoneroDaemonCreates an output distribution.- Parameters:
amounts- are amounts of outputs to make the distribution withisCumulative- 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
Description copied from interface:MoneroDaemonGet general information about the state of the node and the network.- Returns:
- general information about the node and network
-
getSyncInfo
Description copied from interface:MoneroDaemonGet synchronization information.- Returns:
- contains sync information
-
getHardForkInfo
Description copied from interface:MoneroDaemonLook up information regarding hard fork voting and readiness.- Returns:
- hard fork information
-
getAltChains
Description copied from interface:MoneroDaemonGet alternative chains seen by the node.- Returns:
- alternative chains seen by the node
-
getAltBlockHashes
Description copied from interface:MoneroDaemonGet known block hashes which are not on the main chain.- Returns:
- known block hashes which are not on the main chain
-
getDownloadLimit
public int getDownloadLimit()Description copied from interface:MoneroDaemonGet the download bandwidth limit.- Returns:
- is the download bandwidth limit
-
setDownloadLimit
public int setDownloadLimit(int limit) Description copied from interface:MoneroDaemonSet 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
public int resetDownloadLimit()Description copied from interface:MoneroDaemonReset the download bandwidth limit.- Returns:
- the download bandwidth limit after resetting
-
getUploadLimit
public int getUploadLimit()Description copied from interface:MoneroDaemonGet the upload bandwidth limit.- Returns:
- is the upload bandwidth limit
-
setUploadLimit
public int setUploadLimit(int limit) Description copied from interface:MoneroDaemonSet 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
public int resetUploadLimit()Description copied from interface:MoneroDaemonReset the upload bandwidth limit.- Returns:
- the upload bandwidth limit after resetting
-
getPeers
Description copied from interface:MoneroDaemonGet peers with active incoming or outgoing connections to the node.- Returns:
- the daemon's peers
-
getKnownPeers
Description copied from interface:MoneroDaemonGet all known peers including their last known online status.- Returns:
- the daemon's known peers
-
setOutgoingPeerLimit
public void setOutgoingPeerLimit(int limit) Description copied from interface:MoneroDaemonLimit number of outgoing peers.- Parameters:
limit- is the maximum number of outgoing peers
-
setIncomingPeerLimit
public void setIncomingPeerLimit(int limit) Description copied from interface:MoneroDaemonLimit number of incoming peers.- Parameters:
limit- is the maximum number of incoming peers
-
getPeerBans
Description copied from interface:MoneroDaemonGet peer bans.- Returns:
- entries about banned peers
-
setPeerBans
Description copied from interface:MoneroDaemonBan peers nodes.- Parameters:
bans- are bans to apply against peer nodes
-
startMining
public void startMining(String address, Long numThreads, Boolean isBackground, Boolean ignoreBattery) Description copied from interface:MoneroDaemonStart mining.- Parameters:
address- is the address given miner rewards if the daemon mines a blocknumThreads- is the number of mining threads to runisBackground- specifies if the miner should run in the background or notignoreBattery- specifies if the battery state (e.g. on laptop) should be ignored or not
-
stopMining
public void stopMining()Description copied from interface:MoneroDaemonStop mining. -
getMiningStatus
Description copied from interface:MoneroDaemonGet the daemon's mining status.- Returns:
- the daemon's mining status
-
submitBlocks
Description copied from interface:MoneroDaemonSubmit mined blocks to the network.- Parameters:
blockBlobs- are the mined blocks to submit
-
pruneBlockchain
Description copied from interface:MoneroDaemonPrune the blockchain.- Parameters:
check- specifies to check the pruning (default false)- Returns:
- the prune result
-
checkForUpdate
Description copied from interface:MoneroDaemonCheck for update.- Returns:
- the result of the update check
-
downloadUpdate
Description copied from interface:MoneroDaemonDownload an update.- Parameters:
path- is the path to download the update (optional)- Returns:
- the result of the update download
-
stop
public void stop()Description copied from interface:MoneroDaemonSafely disconnect and shut down the daemon. -
waitForNextBlockHeader
Description copied from interface:MoneroDaemonGet the header of the next block added to the chain.- Returns:
- the header of the next block added to the chain
-