monero-c
C ABI for using Monero
Loading...
Searching...
No Matches
monero_c_daemon.h File Reference
#include "utils/monero_c_utils.h"
#include "common/monero_c_rpc_connection.h"
#include <stddef.h>
Include dependency graph for monero_c_daemon.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  monero_daemon_listener_callbacks
 Callbacks of a daemon listener. More...
 

Typedefs

typedef struct monero_daemon monero_daemon
 Copyright (c) Libmonero.
 
typedef struct monero_daemon_listener monero_daemon_listener
 Opaque listener that receives the daemon's notifications.
 
typedef void(* monero_daemon_on_block_header_fn) (void *user_data, const char *header_json)
 Called with the JSON of each new block header.
 
typedef struct monero_daemon_listener_callbacks monero_daemon_listener_callbacks
 Callbacks of a daemon listener.
 
typedef enum monero_key_image_spent_status monero_key_image_spent_status
 Spent status of a key image.
 

Enumerations

enum  monero_key_image_spent_status { MONERO_KEY_IMAGE_NOT_SPENT = 0 , MONERO_KEY_IMAGE_CONFIRMED = 1 , MONERO_KEY_IMAGE_TX_POOL = 2 }
 Spent status of a key image. More...
 

Functions

MONERO_EXPORT monero_result monero_daemon_connect (const char *uri, const char *username, const char *password, const char *proxy_uri, uint32_t timeout_ms, monero_daemon **out_daemon)
 Create a daemon RPC client and checks the connection, which can take a while if the daemon is slow to answer.
 
MONERO_EXPORT monero_result monero_daemon_connect_with (monero_rpc_connection *connection, monero_daemon **out_daemon)
 Create a daemon RPC client that shares a connection, with its proxy, timeout and TLS settings.
 
MONERO_EXPORT void monero_daemon_free (monero_daemon *daemon)
 Release a handle returned by monero_daemon_connect().
 
MONERO_EXPORT monero_result monero_daemon_get_rpc_connection (monero_daemon *daemon, char **out_json)
 Get the connection to the daemon.
 
MONERO_EXPORT monero_result monero_daemon_set_poll_period (monero_daemon *daemon, uint64_t period_ms)
 Set how often the listeners poll the daemon for new blocks.
 
MONERO_EXPORT monero_result monero_daemon_listener_create (const monero_daemon_listener_callbacks *callbacks, monero_daemon_listener **out_listener)
 Create a listener that forwards the daemon's notifications to the callbacks.
 
MONERO_EXPORT void monero_daemon_listener_free (monero_daemon_listener *listener)
 Release a listener.
 
MONERO_EXPORT monero_result monero_daemon_add_listener (monero_daemon *daemon, monero_daemon_listener *listener)
 Register a listener.
 
MONERO_EXPORT monero_result monero_daemon_remove_listener (monero_daemon *daemon, monero_daemon_listener *listener)
 Unregister a listener.
 
MONERO_EXPORT monero_result monero_daemon_get_listeners (monero_daemon *daemon, monero_daemon_listener ***out_listeners, size_t *out_count)
 Get the listeners registered with the daemon.
 
MONERO_EXPORT monero_result monero_daemon_remove_listeners (monero_daemon *daemon)
 Unregister all listeners of the daemon.
 
MONERO_EXPORT monero_result monero_daemon_get_version (monero_daemon *daemon, char **out_json)
 Get the daemon's version.
 
MONERO_EXPORT monero_result monero_daemon_is_trusted (monero_daemon *daemon, bool *out_trusted)
 Indicates if the daemon is trusted or untrusted.
 
MONERO_EXPORT monero_result monero_daemon_get_height (monero_daemon *daemon, uint64_t *out_height)
 Get the number of blocks in the longest chain known to the node.
 
MONERO_EXPORT monero_result monero_daemon_get_block_hash (monero_daemon *daemon, uint64_t height, char **out_hash)
 Get a block's hash by its height.
 
MONERO_EXPORT monero_result monero_daemon_get_info (monero_daemon *daemon, char **out_json)
 Get general information about the state of the node and the network.
 
MONERO_EXPORT monero_result monero_daemon_get_sync_info (monero_daemon *daemon, char **out_json)
 Get synchronization information.
 
MONERO_EXPORT monero_result monero_daemon_get_network_stats (monero_daemon *daemon, char **out_json)
 Get network (bandwidth) statistics since the daemon started.
 
MONERO_EXPORT monero_result monero_daemon_get_hard_fork_info (monero_daemon *daemon, char **out_json)
 Look up information regarding hard fork voting and readiness.
 
MONERO_EXPORT monero_result monero_daemon_get_alt_chains (monero_daemon *daemon, char **out_json)
 Get the alternative chains seen by the node.
 
MONERO_EXPORT monero_result monero_daemon_get_alt_block_hashes (monero_daemon *daemon, char **out_json)
 Get the known block hashes that are not on the main chain.
 
MONERO_EXPORT monero_result monero_daemon_get_block_template (monero_daemon *daemon, const char *wallet_address, const int32_t *reserve_size, char **out_json)
 Get a block template for mining a new block.
 
MONERO_EXPORT monero_result monero_daemon_get_miner_data (monero_daemon *daemon, char **out_json)
 Get the data needed to build a block template, for pools that assemble their own.
 
MONERO_EXPORT monero_result monero_daemon_calculate_pow (monero_daemon *daemon, uint32_t major_version, uint64_t height, const char *block_blob, const char *seed_hash, char **out_pow_hash)
 Calculate the proof-of-work hash of a mined block.
 
MONERO_EXPORT monero_result monero_daemon_add_auxiliary_pow (monero_daemon *daemon, const char *block_template_blob, const char *aux_pow_json, char **out_json)
 Add auxiliary proof-of-work to a block template for merge mining.
 
MONERO_EXPORT monero_result monero_daemon_get_mining_status (monero_daemon *daemon, char **out_json)
 Get the daemon's mining status.
 
MONERO_EXPORT monero_result monero_daemon_start_mining (monero_daemon *daemon, const char *address, const uint64_t *num_threads, const bool *is_background, const bool *ignore_battery)
 Start mining.
 
MONERO_EXPORT monero_result monero_daemon_stop_mining (monero_daemon *daemon)
 Stop mining.
 
MONERO_EXPORT monero_result monero_daemon_generate_blocks (monero_daemon *daemon, const char *wallet_address, uint64_t num_blocks, const char *prev_block_hash, const uint32_t *starting_nonce, char **out_json)
 Generate blocks to a wallet address.
 
MONERO_EXPORT monero_result monero_daemon_submit_block (monero_daemon *daemon, const char *block_blob)
 Submit a mined block to the network.
 
MONERO_EXPORT monero_result monero_daemon_submit_blocks (monero_daemon *daemon, const char *const *block_blobs, size_t num_block_blobs)
 Submit mined blocks to the network.
 
MONERO_EXPORT monero_result monero_daemon_get_last_block_header (monero_daemon *daemon, char **out_json)
 Get the header of the last block.
 
MONERO_EXPORT monero_result monero_daemon_get_block_header_by_hash (monero_daemon *daemon, const char *block_hash, char **out_json)
 Get a block header by its hash.
 
MONERO_EXPORT monero_result monero_daemon_get_block_header_by_height (monero_daemon *daemon, uint64_t height, char **out_json)
 Get a block header by its height.
 
MONERO_EXPORT monero_result monero_daemon_get_block_headers_by_range (monero_daemon *daemon, uint64_t start_height, uint64_t end_height, char **out_json)
 Get block headers in the given height range.
 
MONERO_EXPORT monero_result monero_daemon_get_block_by_hash (monero_daemon *daemon, const char *block_hash, char **out_json)
 Get a block by its hash.
 
MONERO_EXPORT monero_result monero_daemon_get_blocks_by_hash (monero_daemon *daemon, const char *const *block_hashes, size_t num_block_hashes, uint64_t start_height, bool prune, uint64_t max_block_count, char **out_json)
 Get blocks by hash.
 
MONERO_EXPORT monero_result monero_daemon_get_block_by_height (monero_daemon *daemon, uint64_t height, char **out_json)
 Get a block by its height.
 
MONERO_EXPORT monero_result monero_daemon_get_blocks_by_height (monero_daemon *daemon, const uint64_t *heights, size_t num_heights, char **out_json)
 Get blocks at the given heights.
 
MONERO_EXPORT monero_result monero_daemon_get_blocks_by_range (monero_daemon *daemon, const uint64_t *start_height, const uint64_t *end_height, char **out_json)
 Get blocks in the given height range.
 
MONERO_EXPORT monero_result monero_daemon_get_blocks_by_range_chunked (monero_daemon *daemon, const uint64_t *start_height, const uint64_t *end_height, const uint64_t *max_chunk_size, char **out_json)
 Get blocks in the given height range, in chunked requests.
 
MONERO_EXPORT monero_result monero_daemon_get_block_hashes (monero_daemon *daemon, const char *const *block_hashes, size_t num_block_hashes, char **out_json)
 Get block hashes from a chain history, using the same format as monero_daemon_get_blocks_by_hash().
 
MONERO_EXPORT monero_result monero_daemon_wait_for_next_block_header (monero_daemon *daemon, char **out_json)
 Wait for the next block and return its header.
 
MONERO_EXPORT monero_result monero_daemon_get_tx (monero_daemon *daemon, const char *tx_hash, bool prune, char **out_json)
 Get a transaction by its hash.
 
MONERO_EXPORT monero_result monero_daemon_get_txs (monero_daemon *daemon, const char *const *tx_hashes, size_t num_tx_hashes, bool prune, char **out_json)
 Get transactions by their hashes.
 
MONERO_EXPORT monero_result monero_daemon_get_tx_hex (monero_daemon *daemon, const char *tx_hash, bool prune, char **out_tx_hex)
 Get a transaction's hex by its hash.
 
MONERO_EXPORT monero_result monero_daemon_get_tx_hexes (monero_daemon *daemon, const char *const *tx_hashes, size_t num_tx_hashes, bool prune, char **out_json)
 Get transaction hexes by their hashes.
 
MONERO_EXPORT monero_result monero_daemon_get_miner_tx_sum (monero_daemon *daemon, uint64_t height, uint64_t num_blocks, char **out_json)
 Get the total emissions and fees from the genesis block up to the given height.
 
MONERO_EXPORT monero_result monero_daemon_get_fee_estimate (monero_daemon *daemon, uint64_t grace_blocks, char **out_json)
 Get the mining fee estimates per kB.
 
MONERO_EXPORT monero_result monero_daemon_submit_tx_hex (monero_daemon *daemon, const char *tx_hex, bool do_not_relay, char **out_json)
 Submit a transaction to the daemon's pool.
 
MONERO_EXPORT monero_result monero_daemon_relay_tx_by_hash (monero_daemon *daemon, const char *tx_hash)
 Relay a transaction by its hash.
 
MONERO_EXPORT monero_result monero_daemon_relay_txs_by_hash (monero_daemon *daemon, const char *const *tx_hashes, size_t num_tx_hashes)
 Relay transactions by their hashes.
 
MONERO_EXPORT monero_result monero_daemon_get_tx_pool (monero_daemon *daemon, char **out_json)
 Get the valid transactions seen by the node but not yet mined into a block.
 
MONERO_EXPORT monero_result monero_daemon_get_tx_pool_hashes (monero_daemon *daemon, char **out_json)
 Get the hashes of the transactions in the transaction pool.
 
MONERO_EXPORT monero_result monero_daemon_get_tx_pool_backlog (monero_daemon *daemon, char **out_json)
 Get the transaction pool backlog.
 
MONERO_EXPORT monero_result monero_daemon_get_tx_pool_stats (monero_daemon *daemon, char **out_json)
 Get statistics about the transaction pool.
 
MONERO_EXPORT monero_result monero_daemon_flush_tx_pool (monero_daemon *daemon)
 Flush all transactions from the transaction pool.
 
MONERO_EXPORT monero_result monero_daemon_flush_tx_pool_hashes (monero_daemon *daemon, const char *const *tx_hashes, size_t num_tx_hashes)
 Flush transactions from the transaction pool by their hashes.
 
MONERO_EXPORT monero_result monero_daemon_flush_tx_pool_hash (monero_daemon *daemon, const char *tx_hash)
 Flush a single transaction from the transaction pool.
 
MONERO_EXPORT monero_result monero_daemon_get_key_image_spent_status (monero_daemon *daemon, const char *key_image, monero_key_image_spent_status *out_status)
 Get the spent status of a key image.
 
MONERO_EXPORT monero_result monero_daemon_get_key_image_spent_statuses (monero_daemon *daemon, const char *const *key_images, size_t num_key_images, monero_key_image_spent_status **out_statuses, size_t *out_count)
 Get the spent status of each of the given key images.
 
MONERO_EXPORT monero_result monero_daemon_get_output_indices (monero_daemon *daemon, const char *tx_hash, uint64_t **out_indices, size_t *out_count)
 Get the global output index of each output in a transaction.
 
MONERO_EXPORT monero_result monero_daemon_get_outputs (monero_daemon *daemon, const char *outputs_json, char **out_json)
 Get outputs identified by amount and index.
 
MONERO_EXPORT monero_result monero_daemon_get_output_histogram (monero_daemon *daemon, const uint64_t *amounts, size_t num_amounts, const int32_t *min_count, const int32_t *max_count, const bool *is_unlocked, const int32_t *recent_cutoff, char **out_json)
 Get a histogram of output amounts: for each amount, the number of outputs on the chain.
 
MONERO_EXPORT monero_result monero_daemon_get_output_distribution (monero_daemon *daemon, const uint64_t *amounts, size_t num_amounts, const bool *is_cumulative, const uint64_t *start_height, const uint64_t *end_height, char **out_json)
 Create an output distribution for the given amounts.
 
MONERO_EXPORT monero_result monero_daemon_get_download_limit (monero_daemon *daemon, int32_t *out_limit)
 Get the download bandwidth limit.
 
MONERO_EXPORT monero_result monero_daemon_set_download_limit (monero_daemon *daemon, int32_t limit, int32_t *out_limit)
 Set the download bandwidth limit.
 
MONERO_EXPORT monero_result monero_daemon_reset_download_limit (monero_daemon *daemon, int32_t *out_limit)
 Reset the download bandwidth limit to the default.
 
MONERO_EXPORT monero_result monero_daemon_get_upload_limit (monero_daemon *daemon, int32_t *out_limit)
 Get the upload bandwidth limit.
 
MONERO_EXPORT monero_result monero_daemon_set_upload_limit (monero_daemon *daemon, int32_t limit, int32_t *out_limit)
 Set the upload bandwidth limit.
 
MONERO_EXPORT monero_result monero_daemon_reset_upload_limit (monero_daemon *daemon, int32_t *out_limit)
 Reset the upload bandwidth limit to the default.
 
MONERO_EXPORT monero_result monero_daemon_get_peers (monero_daemon *daemon, char **out_json)
 Get the peers with active incoming or outgoing connections to the node.
 
MONERO_EXPORT monero_result monero_daemon_get_known_peers (monero_daemon *daemon, char **out_json)
 Get all known peers, including their last known online status.
 
MONERO_EXPORT monero_result monero_daemon_get_public_peers (monero_daemon *daemon, bool include_offline, char **out_json)
 Get the public nodes known to the daemon.
 
MONERO_EXPORT monero_result monero_daemon_set_outgoing_peer_limit (monero_daemon *daemon, int32_t limit)
 Limits the number of outgoing peers.
 
MONERO_EXPORT monero_result monero_daemon_set_incoming_peer_limit (monero_daemon *daemon, int32_t limit)
 Limits the number of incoming peers.
 
MONERO_EXPORT monero_result monero_daemon_get_peer_bans (monero_daemon *daemon, char **out_json)
 Get the peer bans.
 
MONERO_EXPORT monero_result monero_daemon_set_peer_bans (monero_daemon *daemon, const char *bans_json)
 Bans peer nodes.
 
MONERO_EXPORT monero_result monero_daemon_set_peer_ban (monero_daemon *daemon, const char *ban_json)
 Bans a peer node.
 
MONERO_EXPORT monero_result monero_daemon_get_peer_ban (monero_daemon *daemon, const char *address, char **out_json)
 Get the ban status of a peer node.
 
MONERO_EXPORT monero_result monero_daemon_prune_blockchain (monero_daemon *daemon, bool check, char **out_json)
 Prunes the blockchain.
 
MONERO_EXPORT monero_result monero_daemon_save_blockchain (monero_daemon *daemon)
 Saves (flushes) the blockchain to disk.
 
MONERO_EXPORT monero_result monero_daemon_pop_blocks (monero_daemon *daemon, uint64_t num_blocks, uint64_t *out_height)
 Pops (removes) blocks from the top of the blockchain.
 
MONERO_EXPORT monero_result monero_daemon_flush_cache (monero_daemon *daemon, bool bad_blocks)
 Flush the daemon's invalid block and transaction caches.
 
MONERO_EXPORT monero_result monero_daemon_set_bootstrap_daemon (monero_daemon *daemon, const char *address, const char *username, const char *password, const char *proxy)
 Set the bootstrap daemon the node uses to serve requests while it is not fully synced.
 
MONERO_EXPORT monero_result monero_daemon_remove_bootstrap_daemon (monero_daemon *daemon)
 Disables the bootstrap daemon, so the node no longer falls back to it.
 
MONERO_EXPORT monero_result monero_daemon_set_log_hash_rate (monero_daemon *daemon, bool is_visible)
 Show or hide the mining hash rate in the daemon's console log.
 
MONERO_EXPORT monero_result monero_daemon_set_log_level (monero_daemon *daemon, int32_t level)
 Set the daemon's log level.
 
MONERO_EXPORT monero_result monero_daemon_set_log_categories (monero_daemon *daemon, const char *categories, char **out_categories)
 Set the daemon's log categories, e.g.
 
MONERO_EXPORT monero_result monero_daemon_check_for_update (monero_daemon *daemon, char **out_json)
 Check for an update.
 
MONERO_EXPORT monero_result monero_daemon_download_update (monero_daemon *daemon, const char *path, char **out_json)
 Downloads an update.
 
MONERO_EXPORT monero_result monero_daemon_stop (monero_daemon *daemon)
 Safely disconnects from and shuts down the daemon.
 

Typedef Documentation

◆ monero_daemon

typedef struct monero_daemon monero_daemon

Copyright (c) Libmonero.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Opaque handle to a daemon RPC client. Create it with monero_daemon_connect() and release it with monero_daemon_free(). Calls return MONERO_ERROR if the daemon can't be reached or answers with an error.

Thread safety
monero-cpp serializes calls on one handle, so they don't run in parallel. For parallel requests, use one handle per thread. Don't call monero_daemon_free() while another thread uses the handle.

◆ monero_daemon_listener

Opaque listener that receives the daemon's notifications.

Create it with monero_daemon_listener_create() and release it with monero_daemon_listener_free().

Thread safety
The listener has no lock of its own, so don't add, remove or free it from two threads at once. Different listeners on one daemon can be managed from different threads.

◆ monero_daemon_listener_callbacks

Callbacks of a daemon listener.

The struct is copied by monero_daemon_listener_create().

◆ monero_daemon_on_block_header_fn

typedef void(* monero_daemon_on_block_header_fn) (void *user_data, const char *header_json)

Called with the JSON of each new block header.

The string is valid only during the call. The callback runs on a thread owned by monero-cpp. Inside it, monero_daemon_remove_listener() and monero_daemon_remove_listeners() are safe. Don't free the listener or the daemon from inside it. Free them after the callback returns.

Parameters
user_datais the user_data of the monero_daemon_listener_callbacks
header_jsonis the JSON-serialized monero_block_header

◆ monero_key_image_spent_status

Spent status of a key image.

The values match monero-cpp's monero_key_image_spent_status.

Enumeration Type Documentation

◆ monero_key_image_spent_status

Spent status of a key image.

The values match monero-cpp's monero_key_image_spent_status.

Enumerator
MONERO_KEY_IMAGE_NOT_SPENT 
MONERO_KEY_IMAGE_CONFIRMED 
MONERO_KEY_IMAGE_TX_POOL 

Function Documentation

◆ monero_daemon_add_auxiliary_pow()

MONERO_EXPORT monero_result monero_daemon_add_auxiliary_pow ( monero_daemon *  daemon,
const char *  block_template_blob,
const char *  aux_pow_json,
char **  out_json 
)

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

The Merkle root of the updated template commits to the auxiliary blocks.

Parameters
daemonis the handle returned by monero_daemon_connect()
block_template_blobis the block template blob to add auxiliary PoW to
aux_pow_jsonis a JSON array of monero_auxiliary_pow, one per auxiliary chain
out_jsonreceives a JSON-serialized monero_add_auxiliary_pow_result, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_add_listener()

MONERO_EXPORT monero_result monero_daemon_add_listener ( monero_daemon *  daemon,
monero_daemon_listener *  listener 
)

Register a listener.

Adding a listener that is already registered does nothing. A listener can be registered with one daemon at a time, so adding it to another daemon fails until it is removed from the first one.

Parameters
daemonis the handle returned by monero_daemon_connect()
listeneris the listener to register
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_calculate_pow()

MONERO_EXPORT monero_result monero_daemon_calculate_pow ( monero_daemon *  daemon,
uint32_t  major_version,
uint64_t  height,
const char *  block_blob,
const char *  seed_hash,
char **  out_pow_hash 
)

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

Parameters
daemonis the handle returned by monero_daemon_connect()
major_versionis the block's major version
heightis the block's height
block_blobis the block's blob to hash
seed_hashis the seed hash used to select the RandomX dataset and cache
out_pow_hashreceives the proof-of-work hash, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_check_for_update()

MONERO_EXPORT monero_result monero_daemon_check_for_update ( monero_daemon *  daemon,
char **  out_json 
)

Check for an update.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_daemon_update_check_result, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_connect()

MONERO_EXPORT monero_result monero_daemon_connect ( const char *  uri,
const char *  username,
const char *  password,
const char *  proxy_uri,
uint32_t  timeout_ms,
monero_daemon **  out_daemon 
)

Create a daemon RPC client and checks the connection, which can take a while if the daemon is slow to answer.

It still succeeds if the daemon is unreachable. The calls that query the daemon report the failure.

Parameters
uriis the daemon RPC URI, e.g. "http://127.0.0.1:18081"
usernameis the RPC username, or "" for none
passwordis the RPC password, or "" for none
proxy_uriis the proxy to connect through, or "" for none
timeout_msis the RPC timeout in milliseconds, or 0 for the default
out_daemonreceives the new handle, released with monero_daemon_free()
Returns
MONERO_OK on success, or MONERO_ERROR if uri is empty (see monero_last_error())

◆ monero_daemon_connect_with()

MONERO_EXPORT monero_result monero_daemon_connect_with ( monero_rpc_connection *  connection,
monero_daemon **  out_daemon 
)

Create a daemon RPC client that shares a connection, with its proxy, timeout and TLS settings.

It checks the connection if it isn't online yet, and succeeds even if the daemon is unreachable.

Parameters
connectionis the connection to the daemon. It can be freed after the call
out_daemonreceives the new handle, released with monero_daemon_free()
Returns
MONERO_OK or MONERO_ERROR

◆ monero_daemon_download_update()

MONERO_EXPORT monero_result monero_daemon_download_update ( monero_daemon *  daemon,
const char *  path,
char **  out_json 
)

Downloads an update.

Parameters
daemonis the handle returned by monero_daemon_connect()
pathis the path to download the update to, or "" for the daemon's default
out_jsonreceives a JSON-serialized monero_daemon_update_download_result, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_flush_cache()

MONERO_EXPORT monero_result monero_daemon_flush_cache ( monero_daemon *  daemon,
bool  bad_blocks 
)

Flush the daemon's invalid block and transaction caches.

Parameters
daemonis the handle returned by monero_daemon_connect()
bad_blocksspecifies if the bad blocks cache is flushed too
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_flush_tx_pool()

MONERO_EXPORT monero_result monero_daemon_flush_tx_pool ( monero_daemon *  daemon)

Flush all transactions from the transaction pool.

Parameters
daemonis the handle returned by monero_daemon_connect()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_flush_tx_pool_hash()

MONERO_EXPORT monero_result monero_daemon_flush_tx_pool_hash ( monero_daemon *  daemon,
const char *  tx_hash 
)

Flush a single transaction from the transaction pool.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashis the hash of the transaction to flush
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_flush_tx_pool_hashes()

MONERO_EXPORT monero_result monero_daemon_flush_tx_pool_hashes ( monero_daemon *  daemon,
const char *const *  tx_hashes,
size_t  num_tx_hashes 
)

Flush transactions from the transaction pool by their hashes.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashesare the hashes of the transactions to flush
num_tx_hashesis the number of elements in tx_hashes
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_free()

MONERO_EXPORT void monero_daemon_free ( monero_daemon *  daemon)

Release a handle returned by monero_daemon_connect().

Passing NULL does nothing.

Parameters
daemonis the handle to release

◆ monero_daemon_generate_blocks()

MONERO_EXPORT monero_result monero_daemon_generate_blocks ( monero_daemon *  daemon,
const char *  wallet_address,
uint64_t  num_blocks,
const char *  prev_block_hash,
const uint32_t *  starting_nonce,
char **  out_json 
)

Generate blocks to a wallet address.

Regtest only.

Parameters
daemonis the handle returned by monero_daemon_connect()
wallet_addressis the address that receives the miner transactions
num_blocksis the number of blocks to generate
prev_block_hashis the hash of the block to build on, or NULL to build on the tip
starting_nonceis the starting nonce, or NULL for the daemon's default
out_jsonreceives a JSON-serialized monero_generate_blocks_result, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_alt_block_hashes()

MONERO_EXPORT monero_result monero_daemon_get_alt_block_hashes ( monero_daemon *  daemon,
char **  out_json 
)

Get the known block hashes that are not on the main chain.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON array of hex strings, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_alt_chains()

MONERO_EXPORT monero_result monero_daemon_get_alt_chains ( monero_daemon *  daemon,
char **  out_json 
)

Get the alternative chains seen by the node.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON array of monero_alt_chain, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_block_by_hash()

MONERO_EXPORT monero_result monero_daemon_get_block_by_hash ( monero_daemon *  daemon,
const char *  block_hash,
char **  out_json 
)

Get a block by its hash.

Parameters
daemonis the handle returned by monero_daemon_connect()
block_hashis the hash of the block
out_jsonreceives a JSON-serialized monero_block, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_block_by_height()

MONERO_EXPORT monero_result monero_daemon_get_block_by_height ( monero_daemon *  daemon,
uint64_t  height,
char **  out_json 
)

Get a block by its height.

Parameters
daemonis the handle returned by monero_daemon_connect()
heightis the height of the block
out_jsonreceives a JSON-serialized monero_block, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_block_hash()

MONERO_EXPORT monero_result monero_daemon_get_block_hash ( monero_daemon *  daemon,
uint64_t  height,
char **  out_hash 
)

Get a block's hash by its height.

Parameters
daemonis the handle returned by monero_daemon_connect()
heightis the height of the block
out_hashreceives the block's hash, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_block_hashes()

MONERO_EXPORT monero_result monero_daemon_get_block_hashes ( monero_daemon *  daemon,
const char *const *  block_hashes,
size_t  num_block_hashes,
char **  out_json 
)

Get block hashes from a chain history, using the same format as monero_daemon_get_blocks_by_hash().

Parameters
daemonis the handle returned by monero_daemon_connect()
block_hashesis the chain history. The last hash must be the genesis block.
num_block_hashesis the number of elements in block_hashes
out_jsonreceives a JSON-serialized monero_get_block_hashes_result, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_block_header_by_hash()

MONERO_EXPORT monero_result monero_daemon_get_block_header_by_hash ( monero_daemon *  daemon,
const char *  block_hash,
char **  out_json 
)

Get a block header by its hash.

Parameters
daemonis the handle returned by monero_daemon_connect()
block_hashis the hash of the block
out_jsonreceives a JSON-serialized monero_block_header, or NULL if the daemon has no such block. Free with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_block_header_by_height()

MONERO_EXPORT monero_result monero_daemon_get_block_header_by_height ( monero_daemon *  daemon,
uint64_t  height,
char **  out_json 
)

Get a block header by its height.

Parameters
daemonis the handle returned by monero_daemon_connect()
heightis the height of the block
out_jsonreceives a JSON-serialized monero_block_header, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_block_headers_by_range()

MONERO_EXPORT monero_result monero_daemon_get_block_headers_by_range ( monero_daemon *  daemon,
uint64_t  start_height,
uint64_t  end_height,
char **  out_json 
)

Get block headers in the given height range.

Parameters
daemonis the handle returned by monero_daemon_connect()
start_heightis the lower bound of the range, inclusive
end_heightis the upper bound of the range, inclusive
out_jsonreceives a JSON array of monero_block_header, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_block_template()

MONERO_EXPORT monero_result monero_daemon_get_block_template ( monero_daemon *  daemon,
const char *  wallet_address,
const int32_t *  reserve_size,
char **  out_json 
)

Get a block template for mining a new block.

Parameters
daemonis the handle returned by monero_daemon_connect()
wallet_addressis the address that receives the miner transaction if the block is mined
reserve_sizeis the reserve size, or NULL for none
out_jsonreceives a JSON-serialized monero_block_template, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_blocks_by_hash()

MONERO_EXPORT monero_result monero_daemon_get_blocks_by_hash ( monero_daemon *  daemon,
const char *const *  block_hashes,
size_t  num_block_hashes,
uint64_t  start_height,
bool  prune,
uint64_t  max_block_count,
char **  out_json 
)

Get blocks by hash.

The hashes form a short chain history: the first 10 are consecutive, then the gap doubles, and the last one is always the genesis block.

Parameters
daemonis the handle returned by monero_daemon_connect()
block_hashesis the chain history
num_block_hashesis the number of elements in block_hashes
start_heightis the height to resume from, used as-is when non-zero
prunespecifies if the returned blocks should be pruned
max_block_countcaps the number of blocks returned in one call, or 0 for the daemon's default
out_jsonreceives a JSON-serialized monero_get_blocks_by_hash_result, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_blocks_by_height()

MONERO_EXPORT monero_result monero_daemon_get_blocks_by_height ( monero_daemon *  daemon,
const uint64_t *  heights,
size_t  num_heights,
char **  out_json 
)

Get blocks at the given heights.

Parameters
daemonis the handle returned by monero_daemon_connect()
heightsare the heights of the blocks
num_heightsis the number of elements in heights
out_jsonreceives a JSON array of monero_block, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_blocks_by_range()

MONERO_EXPORT monero_result monero_daemon_get_blocks_by_range ( monero_daemon *  daemon,
const uint64_t *  start_height,
const uint64_t *  end_height,
char **  out_json 
)

Get blocks in the given height range.

A range of more than 100000 blocks fails, so use monero_daemon_get_blocks_by_range_chunked() for a longer one.

Parameters
daemonis the handle returned by monero_daemon_connect()
start_heightis the lower bound of the range, inclusive, or NULL for none
end_heightis the upper bound of the range, inclusive, or NULL for none
out_jsonreceives a JSON array of monero_block, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_blocks_by_range_chunked()

MONERO_EXPORT monero_result monero_daemon_get_blocks_by_range_chunked ( monero_daemon *  daemon,
const uint64_t *  start_height,
const uint64_t *  end_height,
const uint64_t *  max_chunk_size,
char **  out_json 
)

Get blocks in the given height range, in chunked requests.

Parameters
daemonis the handle returned by monero_daemon_connect()
start_heightis the lower bound of the range, inclusive, or NULL for none
end_heightis the upper bound of the range, inclusive, or NULL for none
max_chunk_sizeis the maximum size in bytes of each request, or NULL for the default. A larger block fails the call.
out_jsonreceives a JSON array of monero_block, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_download_limit()

MONERO_EXPORT monero_result monero_daemon_get_download_limit ( monero_daemon *  daemon,
int32_t *  out_limit 
)

Get the download bandwidth limit.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_limitreceives the limit
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_fee_estimate()

MONERO_EXPORT monero_result monero_daemon_get_fee_estimate ( monero_daemon *  daemon,
uint64_t  grace_blocks,
char **  out_json 
)

Get the mining fee estimates per kB.

Parameters
daemonis the handle returned by monero_daemon_connect()
grace_blocksis the number of grace blocks to use for the estimate
out_jsonreceives a JSON-serialized monero_fee_estimate, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_hard_fork_info()

MONERO_EXPORT monero_result monero_daemon_get_hard_fork_info ( monero_daemon *  daemon,
char **  out_json 
)

Look up information regarding hard fork voting and readiness.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_hard_fork_info, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_height()

MONERO_EXPORT monero_result monero_daemon_get_height ( monero_daemon *  daemon,
uint64_t *  out_height 
)

Get the number of blocks in the longest chain known to the node.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_heightreceives the number of blocks
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_info()

MONERO_EXPORT monero_result monero_daemon_get_info ( monero_daemon *  daemon,
char **  out_json 
)

Get general information about the state of the node and the network.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_daemon_info, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_key_image_spent_status()

MONERO_EXPORT monero_result monero_daemon_get_key_image_spent_status ( monero_daemon *  daemon,
const char *  key_image,
monero_key_image_spent_status *  out_status 
)

Get the spent status of a key image.

Parameters
daemonis the handle returned by monero_daemon_connect()
key_imageis the key image hex
out_statusreceives the spent status
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_key_image_spent_statuses()

MONERO_EXPORT monero_result monero_daemon_get_key_image_spent_statuses ( monero_daemon *  daemon,
const char *const *  key_images,
size_t  num_key_images,
monero_key_image_spent_status **  out_statuses,
size_t *  out_count 
)

Get the spent status of each of the given key images.

Parameters
daemonis the handle returned by monero_daemon_connect()
key_imagesare the key image hex strings
num_key_imagesis the number of elements in key_images
out_statusesreceives an array of spent statuses, in order, freed with monero_utils_free()
out_countreceives the number of elements in out_statuses
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_known_peers()

MONERO_EXPORT monero_result monero_daemon_get_known_peers ( monero_daemon *  daemon,
char **  out_json 
)

Get all known peers, including their last known online status.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON array of monero_peer, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_last_block_header()

MONERO_EXPORT monero_result monero_daemon_get_last_block_header ( monero_daemon *  daemon,
char **  out_json 
)

Get the header of the last block.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_block_header, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_listeners()

MONERO_EXPORT monero_result monero_daemon_get_listeners ( monero_daemon *  daemon,
monero_daemon_listener ***  out_listeners,
size_t *  out_count 
)

Get the listeners registered with the daemon.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_listenersreceives an array of listener handles the caller still owns. Free the array with monero_utils_free()
out_countreceives the number of handles in out_listeners
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_miner_data()

MONERO_EXPORT monero_result monero_daemon_get_miner_data ( monero_daemon *  daemon,
char **  out_json 
)

Get the data needed to build a block template, for pools that assemble their own.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_miner_data, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_miner_tx_sum()

MONERO_EXPORT monero_result monero_daemon_get_miner_tx_sum ( monero_daemon *  daemon,
uint64_t  height,
uint64_t  num_blocks,
char **  out_json 
)

Get the total emissions and fees from the genesis block up to the given height.

Parameters
daemonis the handle returned by monero_daemon_connect()
heightis the height to start the sum at
num_blocksis the number of blocks to include in the sum
out_jsonreceives a JSON-serialized monero_miner_tx_sum, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_mining_status()

MONERO_EXPORT monero_result monero_daemon_get_mining_status ( monero_daemon *  daemon,
char **  out_json 
)

Get the daemon's mining status.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_mining_status, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_network_stats()

MONERO_EXPORT monero_result monero_daemon_get_network_stats ( monero_daemon *  daemon,
char **  out_json 
)

Get network (bandwidth) statistics since the daemon started.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_daemon_network_stats, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_output_distribution()

MONERO_EXPORT monero_result monero_daemon_get_output_distribution ( monero_daemon *  daemon,
const uint64_t *  amounts,
size_t  num_amounts,
const bool *  is_cumulative,
const uint64_t *  start_height,
const uint64_t *  end_height,
char **  out_json 
)

Create an output distribution for the given amounts.

Parameters
daemonis the handle returned by monero_daemon_connect()
amountsare the amounts to make the distribution with
num_amountsis the number of elements in amounts
is_cumulativespecifies if the results are cumulative, or NULL for the daemon's default
start_heightis the lower bound of the range, inclusive, or NULL for none
end_heightis the upper bound of the range, inclusive, or NULL for none
out_jsonreceives a JSON array of monero_output_distribution_entry, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_output_histogram()

MONERO_EXPORT monero_result monero_daemon_get_output_histogram ( monero_daemon *  daemon,
const uint64_t *  amounts,
size_t  num_amounts,
const int32_t *  min_count,
const int32_t *  max_count,
const bool *  is_unlocked,
const int32_t *  recent_cutoff,
char **  out_json 
)

Get a histogram of output amounts: for each amount, the number of outputs on the chain.

RingCT outputs count as amount 0.

Parameters
daemonis the handle returned by monero_daemon_connect()
amountsare the amounts to make the histogram with
num_amountsis the number of elements in amounts
min_countis the minimum count to include, or NULL for none
max_countis the maximum count to include, or NULL for none
is_unlockedselects the lock state of the outputs to count, or NULL for both
recent_cutoffis the recent cutoff, or NULL for none
out_jsonreceives a JSON array of monero_output_histogram_entry, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_output_indices()

MONERO_EXPORT monero_result monero_daemon_get_output_indices ( monero_daemon *  daemon,
const char *  tx_hash,
uint64_t **  out_indices,
size_t *  out_count 
)

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

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashis the hash of the transaction
out_indicesreceives the output indices, in order, freed with monero_utils_free()
out_countreceives the number of elements in out_indices
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_outputs()

MONERO_EXPORT monero_result monero_daemon_get_outputs ( monero_daemon *  daemon,
const char *  outputs_json,
char **  out_json 
)

Get outputs identified by amount and index.

Parameters
daemonis the handle returned by monero_daemon_connect()
outputs_jsonis a JSON array of monero_output, each identified by amount and index
out_jsonreceives a JSON array of the outputs found, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_peer_ban()

MONERO_EXPORT monero_result monero_daemon_get_peer_ban ( monero_daemon *  daemon,
const char *  address,
char **  out_json 
)

Get the ban status of a peer node.

Parameters
daemonis the handle returned by monero_daemon_connect()
addressis the address of the peer, e.g. "1.2.3.4" or "1.2.3.4:18080"
out_jsonreceives a JSON-serialized monero_ban, whose isBanned is false if the peer isn't banned. Free with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_peer_bans()

MONERO_EXPORT monero_result monero_daemon_get_peer_bans ( monero_daemon *  daemon,
char **  out_json 
)

Get the peer bans.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON array of monero_ban, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_peers()

MONERO_EXPORT monero_result monero_daemon_get_peers ( monero_daemon *  daemon,
char **  out_json 
)

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

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON array of monero_peer, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_public_peers()

MONERO_EXPORT monero_result monero_daemon_get_public_peers ( monero_daemon *  daemon,
bool  include_offline,
char **  out_json 
)

Get the public nodes known to the daemon.

Parameters
daemonis the handle returned by monero_daemon_connect()
include_offlinespecifies if offline nodes are included
out_jsonreceives a JSON array of monero_peer, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_rpc_connection()

MONERO_EXPORT monero_result monero_daemon_get_rpc_connection ( monero_daemon *  daemon,
char **  out_json 
)

Get the connection to the daemon.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives the JSON-serialized monero_rpc_connection, with the password. Free with monero_utils_free()
Returns
MONERO_OK or MONERO_ERROR

◆ monero_daemon_get_sync_info()

MONERO_EXPORT monero_result monero_daemon_get_sync_info ( monero_daemon *  daemon,
char **  out_json 
)

Get synchronization information.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_daemon_sync_info, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_tx()

MONERO_EXPORT monero_result monero_daemon_get_tx ( monero_daemon *  daemon,
const char *  tx_hash,
bool  prune,
char **  out_json 
)

Get a transaction by its hash.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashis the hash of the transaction
prunespecifies if the returned transaction should be pruned
out_jsonreceives a JSON object with the transaction in its block, {"blocks":[...]}. The block has the height and the timestamp of the transaction, and neither if it is in the pool. It is NULL if the daemon doesn't have the transaction. Free with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_tx_hex()

MONERO_EXPORT monero_result monero_daemon_get_tx_hex ( monero_daemon *  daemon,
const char *  tx_hash,
bool  prune,
char **  out_tx_hex 
)

Get a transaction's hex by its hash.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashis the hash of the transaction
prunespecifies if the returned hex should be pruned
out_tx_hexreceives the transaction hex, or NULL if the daemon doesn't have it. Free with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_tx_hexes()

MONERO_EXPORT monero_result monero_daemon_get_tx_hexes ( monero_daemon *  daemon,
const char *const *  tx_hashes,
size_t  num_tx_hashes,
bool  prune,
char **  out_json 
)

Get transaction hexes by their hashes.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashesare the hashes of the transactions
num_tx_hashesis the number of elements in tx_hashes
prunespecifies if the returned hexes should be pruned
out_jsonreceives a JSON array of hex strings, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_tx_pool()

MONERO_EXPORT monero_result monero_daemon_get_tx_pool ( monero_daemon *  daemon,
char **  out_json 
)

Get the valid transactions seen by the node but not yet mined into a block.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON object with the transactions in one block that has no height, {"blocks":[...]}, and {"blocks":[]} if the pool is empty. Freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_tx_pool_backlog()

MONERO_EXPORT monero_result monero_daemon_get_tx_pool_backlog ( monero_daemon *  daemon,
char **  out_json 
)

Get the transaction pool backlog.

monero-cpp doesn't implement it, so this always fails.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON array of monero_tx_backlog_entry, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_tx_pool_hashes()

MONERO_EXPORT monero_result monero_daemon_get_tx_pool_hashes ( monero_daemon *  daemon,
char **  out_json 
)

Get the hashes of the transactions in the transaction pool.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON array of hex strings, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_tx_pool_stats()

MONERO_EXPORT monero_result monero_daemon_get_tx_pool_stats ( monero_daemon *  daemon,
char **  out_json 
)

Get statistics about the transaction pool.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_tx_pool_stats, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_txs()

MONERO_EXPORT monero_result monero_daemon_get_txs ( monero_daemon *  daemon,
const char *const *  tx_hashes,
size_t  num_tx_hashes,
bool  prune,
char **  out_json 
)

Get transactions by their hashes.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashesare the hashes of the transactions
num_tx_hashesis the number of elements in tx_hashes
prunespecifies if the returned transactions should be pruned
out_jsonreceives a JSON object with the transactions found in their blocks, {"blocks":[...]}. The transactions of one block are in one block, which has its height and its timestamp, and the transactions of the pool are in one block that has neither. The blocks come in the order that they first appear, so the transactions are not always in the order of the hashes, and the caller sorts them. Freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_upload_limit()

MONERO_EXPORT monero_result monero_daemon_get_upload_limit ( monero_daemon *  daemon,
int32_t *  out_limit 
)

Get the upload bandwidth limit.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_limitreceives the limit
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_get_version()

MONERO_EXPORT monero_result monero_daemon_get_version ( monero_daemon *  daemon,
char **  out_json 
)

Get the daemon's version.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_version, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_is_trusted()

MONERO_EXPORT monero_result monero_daemon_is_trusted ( monero_daemon *  daemon,
bool *  out_trusted 
)

Indicates if the daemon is trusted or untrusted.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_trustedreceives true if the daemon is trusted, false otherwise
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_listener_create()

MONERO_EXPORT monero_result monero_daemon_listener_create ( const monero_daemon_listener_callbacks *  callbacks,
monero_daemon_listener **  out_listener 
)

Create a listener that forwards the daemon's notifications to the callbacks.

Parameters
callbacksare the callbacks to call. They are copied.
out_listenerreceives the new listener, released with monero_daemon_listener_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_listener_free()

MONERO_EXPORT void monero_daemon_listener_free ( monero_daemon_listener *  listener)

Release a listener.

If the listener is still registered with a daemon, it is unregistered first. Passing NULL does nothing.

Parameters
listeneris the listener to release

◆ monero_daemon_pop_blocks()

MONERO_EXPORT monero_result monero_daemon_pop_blocks ( monero_daemon *  daemon,
uint64_t  num_blocks,
uint64_t *  out_height 
)

Pops (removes) blocks from the top of the blockchain.

Parameters
daemonis the handle returned by monero_daemon_connect()
num_blocksis the number of blocks to pop
out_heightreceives the blockchain height after popping the blocks
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_prune_blockchain()

MONERO_EXPORT monero_result monero_daemon_prune_blockchain ( monero_daemon *  daemon,
bool  check,
char **  out_json 
)

Prunes the blockchain.

Parameters
daemonis the handle returned by monero_daemon_connect()
checkspecifies if the pruning is checked
out_jsonreceives a JSON-serialized monero_prune_result, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_relay_tx_by_hash()

MONERO_EXPORT monero_result monero_daemon_relay_tx_by_hash ( monero_daemon *  daemon,
const char *  tx_hash 
)

Relay a transaction by its hash.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashis the hash of the transaction to relay
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_relay_txs_by_hash()

MONERO_EXPORT monero_result monero_daemon_relay_txs_by_hash ( monero_daemon *  daemon,
const char *const *  tx_hashes,
size_t  num_tx_hashes 
)

Relay transactions by their hashes.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hashesare the hashes of the transactions to relay
num_tx_hashesis the number of elements in tx_hashes
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_remove_bootstrap_daemon()

MONERO_EXPORT monero_result monero_daemon_remove_bootstrap_daemon ( monero_daemon *  daemon)

Disables the bootstrap daemon, so the node no longer falls back to it.

Parameters
daemonis the handle returned by monero_daemon_connect()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_remove_listener()

MONERO_EXPORT monero_result monero_daemon_remove_listener ( monero_daemon *  daemon,
monero_daemon_listener *  listener 
)

Unregister a listener.

Returns after any callback of that listener in progress has finished.

Parameters
daemonis the handle returned by monero_daemon_connect()
listeneris the listener to unregister
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_remove_listeners()

MONERO_EXPORT monero_result monero_daemon_remove_listeners ( monero_daemon *  daemon)

Unregister all listeners of the daemon.

Returns after callbacks in progress have finished.

Parameters
daemonis the handle returned by monero_daemon_connect()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_reset_download_limit()

MONERO_EXPORT monero_result monero_daemon_reset_download_limit ( monero_daemon *  daemon,
int32_t *  out_limit 
)

Reset the download bandwidth limit to the default.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_limitreceives the limit in effect after resetting it
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_reset_upload_limit()

MONERO_EXPORT monero_result monero_daemon_reset_upload_limit ( monero_daemon *  daemon,
int32_t *  out_limit 
)

Reset the upload bandwidth limit to the default.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_limitreceives the limit in effect after resetting it
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_save_blockchain()

MONERO_EXPORT monero_result monero_daemon_save_blockchain ( monero_daemon *  daemon)

Saves (flushes) the blockchain to disk.

Parameters
daemonis the handle returned by monero_daemon_connect()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_bootstrap_daemon()

MONERO_EXPORT monero_result monero_daemon_set_bootstrap_daemon ( monero_daemon *  daemon,
const char *  address,
const char *  username,
const char *  password,
const char *  proxy 
)

Set the bootstrap daemon the node uses to serve requests while it is not fully synced.

Parameters
daemonis the handle returned by monero_daemon_connect()
addressis the bootstrap daemon's address (host:port), "auto" to select a public node, or "" to disable it
usernameis the username to authenticate with, or "" for none
passwordis the password to authenticate with, or "" for none
proxyis the proxy used to reach the bootstrap daemon, or "" for none
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_download_limit()

MONERO_EXPORT monero_result monero_daemon_set_download_limit ( monero_daemon *  daemon,
int32_t  limit,
int32_t *  out_limit 
)

Set the download bandwidth limit.

Parameters
daemonis the handle returned by monero_daemon_connect()
limitis the limit to set, or -1 to reset it to the default
out_limitreceives the limit in effect after setting it
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_incoming_peer_limit()

MONERO_EXPORT monero_result monero_daemon_set_incoming_peer_limit ( monero_daemon *  daemon,
int32_t  limit 
)

Limits the number of incoming peers.

Parameters
daemonis the handle returned by monero_daemon_connect()
limitis the maximum number of incoming peers
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_log_categories()

MONERO_EXPORT monero_result monero_daemon_set_log_categories ( monero_daemon *  daemon,
const char *  categories,
char **  out_categories 
)

Set the daemon's log categories, e.g.

"*:WARNING,net.p2p:DEBUG".

Parameters
daemonis the handle returned by monero_daemon_connect()
categoriesare the log categories to set, or "" to reset them to the default
out_categoriesreceives the log categories in effect, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_log_hash_rate()

MONERO_EXPORT monero_result monero_daemon_set_log_hash_rate ( monero_daemon *  daemon,
bool  is_visible 
)

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

The daemon must be mining (see monero_daemon_start_mining()), otherwise the call fails.

Parameters
daemonis the handle returned by monero_daemon_connect()
is_visiblespecifies if the hash rate is logged
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_log_level()

MONERO_EXPORT monero_result monero_daemon_set_log_level ( monero_daemon *  daemon,
int32_t  level 
)

Set the daemon's log level.

Parameters
daemonis the handle returned by monero_daemon_connect()
levelis the log level, from 0 (least verbose) to 4 (most verbose)
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_outgoing_peer_limit()

MONERO_EXPORT monero_result monero_daemon_set_outgoing_peer_limit ( monero_daemon *  daemon,
int32_t  limit 
)

Limits the number of outgoing peers.

Parameters
daemonis the handle returned by monero_daemon_connect()
limitis the maximum number of outgoing peers
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_peer_ban()

MONERO_EXPORT monero_result monero_daemon_set_peer_ban ( monero_daemon *  daemon,
const char *  ban_json 
)

Bans a peer node.

Parameters
daemonis the handle returned by monero_daemon_connect()
ban_jsonis a JSON-serialized monero_ban to apply
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_peer_bans()

MONERO_EXPORT monero_result monero_daemon_set_peer_bans ( monero_daemon *  daemon,
const char *  bans_json 
)

Bans peer nodes.

Parameters
daemonis the handle returned by monero_daemon_connect()
bans_jsonis a JSON array of monero_ban to apply
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_set_poll_period()

MONERO_EXPORT monero_result monero_daemon_set_poll_period ( monero_daemon *  daemon,
uint64_t  period_ms 
)

Set how often the listeners poll the daemon for new blocks.

Parameters
daemonis the handle returned by monero_daemon_connect()
period_msis the poll period in milliseconds, from 1 to 2147483647. A period of 0 would poll again at once, over and over
Returns
MONERO_OK or MONERO_ERROR

◆ monero_daemon_set_upload_limit()

MONERO_EXPORT monero_result monero_daemon_set_upload_limit ( monero_daemon *  daemon,
int32_t  limit,
int32_t *  out_limit 
)

Set the upload bandwidth limit.

Parameters
daemonis the handle returned by monero_daemon_connect()
limitis the limit to set, or -1 to reset it to the default
out_limitreceives the limit in effect after setting it
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_start_mining()

MONERO_EXPORT monero_result monero_daemon_start_mining ( monero_daemon *  daemon,
const char *  address,
const uint64_t *  num_threads,
const bool *  is_background,
const bool *  ignore_battery 
)

Start mining.

Parameters
daemonis the handle returned by monero_daemon_connect()
addressis the address that receives the rewards if the daemon mines a block
num_threadsis the number of mining threads, or NULL for the daemon's default
is_backgroundspecifies if the miner runs in the background, or NULL for the daemon's default
ignore_batteryspecifies if the battery state is ignored, or NULL for the daemon's default
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_stop()

MONERO_EXPORT monero_result monero_daemon_stop ( monero_daemon *  daemon)

Safely disconnects from and shuts down the daemon.

Parameters
daemonis the handle returned by monero_daemon_connect()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_stop_mining()

MONERO_EXPORT monero_result monero_daemon_stop_mining ( monero_daemon *  daemon)

Stop mining.

Parameters
daemonis the handle returned by monero_daemon_connect()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_submit_block()

MONERO_EXPORT monero_result monero_daemon_submit_block ( monero_daemon *  daemon,
const char *  block_blob 
)

Submit a mined block to the network.

Parameters
daemonis the handle returned by monero_daemon_connect()
block_blobis the mined block to submit
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_submit_blocks()

MONERO_EXPORT monero_result monero_daemon_submit_blocks ( monero_daemon *  daemon,
const char *const *  block_blobs,
size_t  num_block_blobs 
)

Submit mined blocks to the network.

Parameters
daemonis the handle returned by monero_daemon_connect()
block_blobsare the mined blocks to submit
num_block_blobsis the number of elements in block_blobs
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_submit_tx_hex()

MONERO_EXPORT monero_result monero_daemon_submit_tx_hex ( monero_daemon *  daemon,
const char *  tx_hex,
bool  do_not_relay,
char **  out_json 
)

Submit a transaction to the daemon's pool.

Parameters
daemonis the handle returned by monero_daemon_connect()
tx_hexis the raw transaction hex to submit
do_not_relayspecifies if the transaction should not be relayed
out_jsonreceives a JSON-serialized monero_submit_tx_result, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())

◆ monero_daemon_wait_for_next_block_header()

MONERO_EXPORT monero_result monero_daemon_wait_for_next_block_header ( monero_daemon *  daemon,
char **  out_json 
)

Wait for the next block and return its header.

Only the calling thread blocks. Other calls on the same handle can run meanwhile. Fails if no block arrives within 30 minutes.

Parameters
daemonis the handle returned by monero_daemon_connect()
out_jsonreceives a JSON-serialized monero_block_header, freed with monero_utils_free()
Returns
MONERO_OK on success, or MONERO_ERROR (see monero_last_error())