Skip to content

Daemon Interface

MoneroDaemon

Monero daemon interface.

__init__()

Initialize a Monero daemon.

add_auxiliary_pow(block_template_blob, aux_pow)

Add auxiliary proof-of-work to a block template for merge mining.

Parameters:

Name Type Description Default
block_template_blob str

the block template blob to add auxiliary PoW to.

required
aux_pow list[MoneroAuxiliaryPow]

identifies each auxiliary chain by id and its block's PoW hash.

required

Returns:

Type Description
MoneroAddAuxiliaryPowResult

the updated block template along with the (possibly reordered) auxiliary PoW.

add_listener(listener)

Register a listener to receive daemon notifications.

Parameters:

Name Type Description Default
listener MoneroDaemonListener

the listener to register.

required

calculate_pow(major_version, height, block_blob, seed_hash)

Calculate the proof-of-work hash of a mined block.

Parameters:

Name Type Description Default
major_version int

the block's major version.

required
height int

the block's height.

required
block_blob str

the block's blob to hash.

required
seed_hash str

the seed hash used to select the RandomX dataset/cache.

required

Returns:

Type Description
str

the block's proof-of-work hash.

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.

flush_cache(bad_blocks=False)

Flush the daemon's invalid block and transaction caches.

Parameters:

Name Type Description Default
bad_blocks bool

specifies to also flush the bad blocks cache.

False

generate_blocks(wallet_address, num_blocks, prev_block_hash=None, starting_nonce=None)

Generate blocks to a wallet address (regtest only).

Parameters:

Name Type Description Default
wallet_address str

is the address of the wallet to receive miner transactions if block is successfully mined.

required
num_blocks int

is the number of blocks to generate.

required
prev_block_hash str|None

is the hash of the previous block to build on top of (optional, builds on the current tip if not given).

None
starting_nonce int|None

is the starting nonce to use (optional).

None

Returns:

Type Description
MoneroGenerateBlocksResult

the result of generating blocks; height is the height of the last block generated.

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)

Get block hashes as a binary request to the daemon.

Parameters:

Name Type Description Default
block_hashes list[str]

a short chain history; first 10 block hashes go sequential, next go in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always the genesis block, which is required or the request fails.

required

Returns:

Type Description
MoneroGetBlockHashesResult

the requested hashes plus their start height and the daemon's current chain height.

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_block_template(wallet_address, reserve_size=None)

Get a block template for mining a new block.

Parameters:

Name Type Description Default
wallet_address str

is the address of the wallet to receive miner transactions if block is successfully mined.

required
reserve_size int|None

is the reserve size (optional).

None

Returns:

Type Description
MoneroBlockTemplate

a block template for mining a new block.

get_blocks_by_hash(block_hashes, start_height, prune, max_block_count=0)

Get blocks by hash.

Parameters:

Name Type Description Default
block_hashes list[str]

a short chain history; first 10 block hashes go sequential, next go in pow(2,n) offset, and the last one is always the genesis block.

required
start_height int

the start height to resume from; when non-zero the daemon skips the search for the last common block and uses it as-is.

required
prune bool

whether returned blocks should be pruned.

required
max_block_count int

caps how many blocks the daemon returns in one call (0 leaves it to the daemon's own default limit).

0

Returns:

Type Description
MoneroGetBlocksByHashResult

the retrieved blocks plus the daemon's current chain height.

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 the last block's header.

Returns:

Type Description
MoneroBlockHeader

the last block's header.

get_listeners()

Get the listeners registered with the daemon.

Returns:

Type Description
list[MoneroDaemonListener]

the registered listeners.

get_miner_data()

Get the data needed to construct a block template for mining, e.g. for use by a pool that assembles its own block templates.

Returns:

Type Description
MoneroMinerData

the current data for mining a new block.

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_network_stats()

Get network (bandwidth) statistics since the daemon started.

Returns:

Type Description
MoneroDaemonNetworkStats

the daemon's network statistics.

get_output_distribution(amounts, is_cumulative=None, start_height=None, end_height=None)

Creates an output distribution.

Parameters:

Name Type Description Default
amounts list[int]

are amounts of outputs to make the distribution with.

required
is_cumulative bool|None

specifies if the results should be cumulative (optional).

None
start_height int|None

is the start height lower bound inclusive (optional).

None
end_height int|None

is the end height upper bound inclusive (optional).

None

Returns:

Type Description
list[MoneroOutputDistributionEntry]

output distribution entries meeting the parameters.

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_output_indices(tx_hash)

Get the global output index of each output in a transaction.

Parameters:

Name Type Description Default
tx_hash str

the hash of the transaction to get output indices for.

required

Returns:

Type Description
list[int]

the global output index of each output in the transaction, in order.

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_ban(address)

Get the ban status of a peer node.

Parameters:

Name Type Description Default
address str

the address of the peer node to check, e.g. "1.2.3.4" or "1.2.3.4:18080".

required

Returns:

Type Description
MoneroBan

the peer's ban status.

get_peer_bans()

Get peer bans.

Returns:

Type Description
list[MoneroBan]

entries about banned peers.

get_peers()

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

Returns:

Type Description
list[MoneroPeer]

the daemon's peers.

get_public_peers(include_offline=False)

Get public nodes known to the daemon.

Parameters:

Name Type Description Default
include_offline bool

specifies if offline nodes should be included.

False

Returns:

Type Description
list[MoneroPeer]

the daemon's known public nodes.

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).

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).

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()

Gets the version of the daemon.

Returns:

Type Description
MoneroVersion

the version of the daemon.

is_trusted()

Indicates if the daemon is trusted or untrusted.

Returns:

Type Description
bool

True if the daemon is trusted, False otherwise.

pop_blocks(num_blocks)

Pop (remove) blocks from the top of the blockchain.

Parameters:

Name Type Description Default
num_blocks int

the number of blocks to pop.

required

Returns:

Type Description
int

the blockchain height after popping the blocks.

prune_blockchain(check)

Prune the blockchain.

Parameters:

Name Type Description Default
check bool

specifies to check the pruning (default False).

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_bootstrap_daemon()

Disable the bootstrap daemon so the daemon no longer falls back to it.

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

remove_listeners()

Unregister all listeners registered with the daemon.

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.

save_blockchain()

Save (flush) the blockchain to disk.

set_bootstrap_daemon(address, username='', password='', proxy='')

Set the bootstrap daemon used by the daemon to serve requests while it is not fully synced, e.g. a remote node.

Parameters:

Name Type Description Default
address str

the bootstrap daemon's address (host:port), "auto" to select a public node automatically, or an empty string to disable the bootstrap daemon.

required
username str

the username to authenticate with the bootstrap daemon (optional).

''
password str

the password to authenticate with the bootstrap daemon (optional).

''
proxy str

the proxy used to reach the bootstrap daemon, e.g. a SOCKS proxy (optional).

''

set_download_limit(limit)

Set the download bandwidth limit.

Parameters:

Name Type Description Default
limit int

is the download limit to set (-1 to reset to default).

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_log_categories(categories='')

Set the daemon's log categories.

Parameters:

Name Type Description Default
categories str

the log categories to set, e.g. "*:WARNING,net.p2p:DEBUG" (an empty string resets categories to the default).

''

Returns:

Type Description
str

the daemon's resulting log categories.

set_log_hash_rate(is_visible)

Show or hide the mining hash rate in the daemon's console log.

Parameters:

Name Type Description Default
is_visible bool

specifies if the hash rate should be logged.

required

set_log_level(level)

Set the daemon's log level.

Parameters:

Name Type Description Default
level int

the log level to set, from 0 (least verbose) to 4 (most verbose).

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 (-1 to reset to default).

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.