Daemon Interface¶
MoneroDaemon ¶
Monero daemon interface.
__init__() ¶
Initialize a Monero daemon.
add_listener(listener) ¶
Register a listener to receive daemon notifications.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
listener | MoneroDaemonListener | the listener to register. | required |
check_for_update() ¶
Check for update.
Returns:
| Type | Description |
|---|---|
MoneroDaemonUpdateCheckResult | the result of the update check. |
download_update(path='') ¶
Download an update.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | download path. | '' |
Returns:
| Type | Description |
|---|---|
MoneroDaemonUpdateDownloadResult | the result of the update download. |
get_alt_block_hashes() ¶
Get known block hashes which are not on the main chain.
Returns:
| Type | Description |
|---|---|
list[str] | known block hashes which are not on the main chain. |
get_alt_chains() ¶
Get alternative chains seen by the node.
Returns:
| Type | Description |
|---|---|
list[MoneroAltChain] | alternative chains seen by the node. |
get_block_by_hash(hash) ¶
Get a block by hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hash | str | is the hash of the block to get. | required |
Returns:
| Type | Description |
|---|---|
MoneroBlock | the block with the given hash. |
get_block_by_height(height) ¶
Get a block by height.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
height | int | is the height of the block to get. | required |
Returns:
| Type | Description |
|---|---|
MoneroBlock | the block at the given height. |
get_block_hash(height) ¶
Get a block's hash by its height.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
height | int | is the height of the block hash to get. | required |
Returns:
| Type | Description |
|---|---|
str | the block's hash at the given height. |
get_block_hashes(block_hashes, start_height) ¶
Get block hashes as a binary request to the daemon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_hashes | list[str] | 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. | required |
start_height | int | is the starting height of block hashes to return. | required |
Returns:
| Type | Description |
|---|---|
list[str] | the requested block hashes. |
get_block_header_by_hash(hash) ¶
Get a block header by its hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hash | str | is the hash of the block to get the header of. | required |
Returns:
| Type | Description |
|---|---|
MoneroBlockHeader | the block's header. |
get_block_header_by_height(height) ¶
Get a block header by its height.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
height | int | is the height of the block to get the header of. | required |
Returns:
| Type | Description |
|---|---|
MoneroBlockHeader | the block's header. |
get_block_headers_by_range(start_height, end_height) ¶
Get block headers for the given range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_height | int | is the start height lower bound inclusive (optional). | required |
end_height | int | is the end height upper bound inclusive (optional). | required |
Returns:
| Type | Description |
|---|---|
list[MoneroBlockHeader] | block headers in the given range. |
get_blocks_by_hash(block_hashes, start_height, prune) ¶
Get a block by hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_hashes | list[str] | is the hash of the block to get. | required |
start_height | int | filter blocks by block height. | required |
prune | bool | prune hash. | required |
Returns:
| Type | Description |
|---|---|
list[MoneroBlock] | the block with the given hash. |
get_blocks_by_height(heights) ¶
Get blocks at the given heights.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
heights | list[int] | are the heights of the blocks to get. | required |
Returns:
| Type | Description |
|---|---|
list[MoneroBlock] | blocks at the given heights. |
get_blocks_by_range(start_height, end_height) ¶
Get blocks in the given height range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_height | int | is the start height lower bound inclusive (optional). | required |
end_height | int | is the end height upper bound inclusive (optional). | required |
Returns:
| Type | Description |
|---|---|
list[MoneroBlock] | blocks in the given height range. |
get_blocks_by_range_chunked(start_height, end_height, max_chunk_size=None) ¶
Get blocks in the given height range as chunked requests so that each request is not too big.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_height | int | is the start height lower bound inclusive (optional). | required |
end_height | int | is the end height upper bound inclusive (optional). | required |
max_chunk_size | int | is the maximum chunk size in any one request (default 3,000,000 bytes). | None |
Returns:
| Type | Description |
|---|---|
list[MoneroBlock] | blocks in the given height range. |
get_download_limit() ¶
Get the download bandwidth limit.
Returns:
| Type | Description |
|---|---|
int | is the download bandwidth limit. |
get_fee_estimate(grace_blocks=0) ¶
Get mining fee estimates per kB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grace_blocks | int | number of blocks we want the fee estimate to be valid for. | 0 |
Returns:
| Type | Description |
|---|---|
MoneroFeeEstimate | mining fee estimates per kB. |
get_hard_fork_info() ¶
Look up information regarding hard fork voting and readiness.
Returns:
| Type | Description |
|---|---|
MoneroHardForkInfo | hard fork information. |
get_height() ¶
Get the number of blocks in the longest chain known to the node.
Returns:
| Type | Description |
|---|---|
int | the number of blocks. |
get_info() ¶
Get general information about the state of the node and the network.
Returns:
| Type | Description |
|---|---|
MoneroDaemonInfo | general information about the node and network. |
get_key_image_spent_status(key_image) ¶
Get the spent status of the given key image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_image | str | is key image hex to get the status of. | required |
Returns:
| Type | Description |
|---|---|
MoneroKeyImageSpentStatus | the status of the key image. |
get_key_image_spent_statuses(key_images) ¶
Get the spent status of each given key image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key_images | list[str] | are hex key images to get the statuses of. | required |
Returns:
| Type | Description |
|---|---|
list[MoneroKeyImageSpentStatus] | the spent status for each key image. |
get_known_peers() ¶
Get all known peers including their last known online status.
Returns:
| Type | Description |
|---|---|
list[MoneroPeer] | the daemon's known peers. |
get_last_block_header() ¶
get_listeners() ¶
Get the listeners registered with the daemon.
Returns:
| Type | Description |
|---|---|
list[MoneroDaemonListener] | the registered listeners. |
get_miner_tx_sum(height, num_blocks) ¶
Gets the total emissions and fees from the genesis block to the current height.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
height | int | is the height to start computing the miner sum. | required |
num_blocks | int | are the number of blocks to include in the sum. | required |
Returns:
| Type | Description |
|---|---|
MoneroMinerTxSum | the sum emission and fees since the geneis block. |
get_mining_status() ¶
Get the daemon's mining status.
Returns:
| Type | Description |
|---|---|
MoneroMiningStatus | the daemon's mining status. |
get_output_histogram(amounts, min_count, max_count, is_unlocked, recent_cutoff) ¶
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 | Default |
|---|---|---|---|
amounts | list[int] | are amounts of outputs to make the histogram with (atomic-units). | required |
min_count | Optional[int] | filter amounts with at least this number of outputs. | required |
max_count | Optional[int] | filter amounts with at most this number of outputs. | required |
is_unlocked | Optional[bool] | makes a histogram with outputs with the specified lock state. | required |
recent_cutoff | Optional[int] | exclude outputs from older than this timestamp. | required |
Returns:
| Type | Description |
|---|---|
list[MoneroOutputHistogramEntry] | output histogram entries meeting the parameters. |
get_outputs(outputs) ¶
Get outputs identified by a list of output amounts and indices as a binary request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outputs | list[MoneroOutput] | identify each output by amount and index. | required |
Returns:
| Type | Description |
|---|---|
list[MoneroOutput] | the identified outputs. |
get_peer_bans() ¶
get_peers() ¶
Get peers with active incoming or outgoing connections to the node.
Returns:
| Type | Description |
|---|---|
list[MoneroPeer] | the daemon's peers. |
get_sync_info() ¶
Get synchronization information.
Returns:
| Type | Description |
|---|---|
MoneroDaemonSyncInfo | contains sync information. |
get_tx(tx_hash, prune=False) ¶
Get a transaction by hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_hash | str | is the hash of the transaction to get. | required |
prune | bool | specifies if the returned tx should be pruned (defaults to | False |
Returns:
| Type | Description |
|---|---|
MoneroTx | None | the transaction with the given hash or null if not found. |
get_tx_hex(tx_hash, prune=False) ¶
Get a transaction hex by hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_hash | str | is the hash of the transaction to get hex from. | required |
prune | bool | specifies if the returned tx hex should be pruned (defaults to | False |
Returns:
| Type | Description |
|---|---|
str | None | the tx hex with the given hash. |
get_tx_hexes(tx_hashes, prune=False) ¶
Get transaction hexes by hashes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_hashes | list[str] | are hashes of transactions to get hexes from | required |
prune | bool | Prune transaction hashes. | False |
Returns:
| Type | Description |
|---|---|
list[str] | are the tx hexes. |
get_tx_pool() ¶
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:
| Type | Description |
|---|---|
list[MoneroTx] | transactions in the transaction pool. |
get_tx_pool_backlog() ¶
Get all transaction pool backlog.
Returns:
| Type | Description |
|---|---|
list[MoneroTxBacklogEntry] | transaction pool backlog entries. |
get_tx_pool_hashes() ¶
Get hashes of transactions in the transaction pool.
Returns:
| Type | Description |
|---|---|
list[str] | hashes of transactions in the transaction pool. |
get_tx_pool_stats() ¶
Get transaction pool statistics.
Returns:
| Type | Description |
|---|---|
MoneroTxPoolStats | statistics about the transaction pool. |
get_txs(tx_hashes, prune=False) ¶
Get transactions by hashes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_hashes | list[str] | are hashes of transactions to get. | required |
prune | bool | Prune transactions. | False |
Returns:
| Type | Description |
|---|---|
list[MoneroTx] | found transactions with the given hashes. |
get_upload_limit() ¶
Get the upload bandwidth limit.
Returns:
| Type | Description |
|---|---|
int | is the upload bandwidth limit. |
get_version() ¶
is_trusted() ¶
Indicates if the daemon is trusted or untrusted.
Returns:
| Type | Description |
|---|---|
bool |
|
prune_blockchain(check) ¶
Prune the blockchain.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check | bool | specifies to check the pruning (default | required |
Returns:
| Type | Description |
|---|---|
MoneroPruneResult | the prune result. |
relay_tx_by_hash(tx_hash) ¶
Relays a transaction by hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_hash | str | identifies the transaction to relay. | required |
relay_txs_by_hash(tx_hashes) ¶
Relays transactions by hash.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_hashes | list[str] | identify the transactions to relay. | required |
remove_listener(listener) ¶
Unregister a listener to receive daemon notifications.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
listener | MoneroDaemonListener | a previously registered listener to be unregistered. | required |
reset_download_limit() ¶
Reset the download bandwidth limit.
Returns:
| Type | Description |
|---|---|
int | the download bandwidth limit after resetting. |
reset_upload_limit() ¶
Reset the upload bandwidth limit.
Returns:
| Type | Description |
|---|---|
int | the upload bandwidth limit after resetting. |
set_download_limit(limit) ¶
Set the download bandwidth limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | is the download limit to set ( | required |
Returns:
| Type | Description |
|---|---|
int | is the new download limit after setting. |
set_incoming_peer_limit(limit) ¶
Limit number of incoming peers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | is the maximum number of incoming peers. | required |
set_outgoing_peer_limit(limit) ¶
Limit number of outgoing peers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | is the maximum number of outgoing peers. | required |
set_peer_ban(ban) ¶
Ban a peer node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ban | MoneroBan | contains information about a node to ban. | required |
set_peer_bans(bans) ¶
Ban peers nodes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bans | list[MoneroBan] | are bans to apply against peer nodes. | required |
set_upload_limit(limit) ¶
Set the upload bandwidth limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit | int | is the upload limit to set ( | required |
Returns:
| Type | Description |
|---|---|
int | is the new upload limit after setting. |
start_mining(address, num_threads, is_background, ignore_battery) ¶
Start mining.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
address | str | is the address given miner rewards if the daemon mines a block. | required |
num_threads | int | is the number of mining threads to run. | required |
is_background | bool | specifies if the miner should run in the background or not. | required |
ignore_battery | bool | specifies if the battery state (e.g. on laptop) should be ignored or not. | required |
stop() ¶
Safely disconnect and shut down the daemon.
stop_mining() ¶
Stop mining.
submit_block(block_blob) ¶
Submit a mined block to the network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_blob | str | is the mined block to submit. | required |
submit_blocks(block_blobs) ¶
Submit mined blocks to the network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_blobs | list[str] | are the mined blocks to submit. | required |
submit_tx_hex(tx_hex, do_not_relay=False) ¶
Submits a transaction to the daemon's pool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tx_hex | str | is the raw transaction hex to submit. | required |
Returns:
| Type | Description |
|---|---|
MoneroSubmitTxResult | the submission results. |
wait_for_next_block_header() ¶
Get the header of the next block added to the chain.
Returns:
| Type | Description |
|---|---|
MoneroBlockHeader | the header of the next block added to the chain. |