DaemonHTTP¶
- class nerva.daemon.DaemonHTTP(*, host='localhost', port=17566, ssl=False, timeout=10.0, username=None, password=None)¶
Bases:
objectA class to interact with the Nerva daemon’s HTTP endpoint interface.
- Parameters:
host (str, optional) – The host of the daemon.
port (int, optional) – The port of the daemon.
ssl (bool, optional) – Whether to use SSL.
timeout (float, optional) – The timeout for the request.
username (Optional[str])
password (Optional[str])
- url¶
The URL of the daemon.
- Type:
str
- timeout¶
The timeout for the request.
- Type:
float
- headers¶
The headers for the request.
- Type:
dict[str, str]
- async get_height()¶
Get the current block height.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_blocks_bin(*, block_ids, start_height, prune)¶
Get a list of blocks.
- Parameters:
block_ids (list[str]) – Binary list of block IDs.
start_height (int) – The start height.
prune (bool) – Whether to prune the blocks.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_blocks_by_height_bin(*, heights)¶
Get a list of blocks by height.
- Parameters:
heights (list[int]) – The block heights to get.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_hashes_bin(*, block_ids, start_height)¶
Get the hashes of blocks.
- Parameters:
block_ids (list[str]) – Binary list of block IDs.
start_height (int) – The start height.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_o_indexes_bin(*, txid)¶
Get the output indexes of a transaction.
- Parameters:
txid (str) – Binary transaction ID.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_outs_bin(*, outputs)¶
Get the outputs.
- Parameters:
outputs (list[dict[str, Any]]) –
- List of outputs as dictionaries with the following keys:
- amountint
The amount.
- indexint
The index.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_transactions(*, txs_hashes, decode_as_json=False, prune=False, split=False)¶
Get a list of transactions.
- Parameters:
txs_hashes (list[str]) – List of transaction hashes.
decode_as_json (bool, optional) – Whether to decode as JSON.
prune (bool, optional) – Whether to prune the transactions.
split (bool, optional) – Whether to split the transactions.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_alt_blocks_hashes()¶
Get the hashes of alternate blocks.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async is_key_image_spent(*, key_images)¶
Check if key images are spent.
- Parameters:
key_images (list[str]) – List of key images.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async send_raw_transaction(*, tx_as_hex, do_not_relay=False)¶
Send a raw transaction.
- Parameters:
tx_as_hex (str) – The transaction as hex.
do_not_relay (bool, optional) – Whether to relay the transaction.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async start_mining(*, address, threads_count, do_background_mining, ignore_battery)¶
Start mining.
- Parameters:
address (str) – The address to mine to.
threads_count (int) – The number of threads.
do_background_mining (bool) – Whether to mine in the background.
ignore_battery (bool) – Whether to ignore the battery.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async set_donate_level(*, blocks)¶
Set the donate level.
- Parameters:
blocks (int) – The number of blocks to donate.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async stop_mining()¶
Stop mining.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async mining_status()¶
Get the mining status.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async save_bc()¶
Save the blockchain.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_peer_list()¶
Get the peer list.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_public_nodes()¶
Get the public nodes.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async set_log_hash_rate(*, visible)¶
Set the log hash rate.
- Parameters:
visible (bool) – Whether to make the hash rate visible.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async set_log_level(*, level)¶
Set the log level.
- Parameters:
level (int) – The log level.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async set_log_categories(*, categories)¶
Set the log categories.
- Parameters:
categories (str) – The log categories.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_transaction_pool()¶
Get the transaction pool.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_transaction_pool_hashes_bin()¶
Get the transaction pool hashes.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_transaction_pool_hashes()¶
Get the transaction pool hashes.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_transaction_pool_stats()¶
Get the transaction pool stats.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async set_bootstrap_daemon(*, address, username, password)¶
Set the bootstrap daemon.
- Parameters:
address (str) – The address of the daemon.
username (str) – The username.
password (str) – The password.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async stop_daemon()¶
Stop the daemon.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_info()¶
Get the information of the daemon.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_net_stats()¶
Get the network stats.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_limit()¶
Get daemon bandwidth limits.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async set_limit(*, limit_down, limit_up)¶
Set daemon bandwidth limits.
- Parameters:
limit_down (int) – The download limit. (-1 to change to default; 0 for no change)
limit_up (int) – The upload limit. (-1 to change to default; 0 for no change)
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async out_peers()¶
Get the outgoing peers.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async in_peers()¶
Get the incoming peers.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_outs(*, outputs, get_txid)¶
Get outputs.
- Parameters:
outputs (list[dict[str, Any]]) –
- List of outputs as dictionaries with the following keys:
- amountint
The amount.
- indexint
The index.
get_txid (bool) – Whether to get the transaction ID.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async update()¶
Update the daemon.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async get_output_distribution_bin(*, amounts, from_height=0, to_height=0, cumulative=False, binary=True, compress=False)¶
Get the output distribution.
- Parameters:
amounts (list[int]) – The amounts to get the distribution for.
from_height (int, optional) – The height to start from.
to_height (int, optional) – The height to end at.
cumulative (bool, optional) – Whether to get the cumulative distribution.
binary (bool, optional) – Whether to get the binary distribution.
compress (bool, optional) – Whether to compress the distribution.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]
- async pop_blocks(*, nblocks)¶
Pop blocks from the blockchain.
- Parameters:
nblocks (int) – The number of blocks to pop.
- Returns:
The response from the daemon.
- Return type:
dict[str, Any]