Skip to content

Monero Utilities

MoneroUtils

Collection of Monero utilities.

atomic_units_to_xmr(amount_atomic_units) staticmethod

Convert atomic units to XMR.

Parameters:

Name Type Description Default
amount_atomic_units int

amount in atomic units to convert to XMR.

required

Returns:

Type Description
float

amount in XMR.

configure_logging(path, console) staticmethod

Initialize logging.

Parameters:

Name Type Description Default
path str

the path to write logs to.

required
console bool

specifies whether or not to write to the console.

required

dict_to_binary(dictionary) staticmethod

Converts a dictionary into binary format.

Parameters:

Name Type Description Default
dictionary dict

The dictionary to convert in binary format.

required

Returns:

Type Description
bytes

Binary format.

get_blocks_from_outputs(outputs) staticmethod

Get distinct blocks from outputs.

Parameters:

Name Type Description Default
outputs list[MoneroOutputWallet]

Outputs to get blocks from.

required

Returns:

Type Description
list[MoneroBlock]

Distinct blocks obtained from outputs.

get_blocks_from_transfers(transfers) staticmethod

Get distinct blocks from transfers.

Parameters:

Name Type Description Default
transfers list[MoneroTransfer]

Transfers to get blocks from.

required

Returns:

Type Description
list[MoneroBlock]

Distinct blocks obtained from transfers.

get_blocks_from_txs(txs) staticmethod

Get distinct blocks from transactions.

Parameters:

Name Type Description Default
txs list[MoneroTxWallet]

Transactions to get blocks from.

required

Returns:

Type Description
list[MoneroBlock]

Distinct blocks obtained from transactions.

get_integrated_address(network_type, standard_address, payment_id='') staticmethod

Get an integrated address.

Parameters:

Name Type Description Default
network_type MoneroNetworkType

is the network type of the integrated address.

required
standard_address str

is the address to derive the integrated address from.

required
payment_id str

optionally specifies the integrated address's payment id (defaults to random payment id).

''

Returns:

Type Description
MoneroIntegratedAddress

the integrated address.

get_payment_uri(config) staticmethod

Creates a payment URI from a tx configuration.

Parameters:

Name Type Description Default
config MoneroTxConfig

specifies configuration for a payment URI.

required

Returns:

Type Description
str

the payment URI.

get_ring_size() staticmethod

Get network-enforced ring size.

Returns:

Type Description
int

network-enforced ring size.

get_version() staticmethod

Get the version of the monero-python library.

Returns:

Type Description
str

the version of this monero-python library

is_valid_address(address, network_type) staticmethod

Determine if the given address is valid.

Parameters:

Name Type Description Default
address str

is the address to validate.

required
network_type MoneroNetworkType

is the address's network type.

required

Returns:

Type Description
bool

True if the address is valid, False otherwise.

is_valid_language(language) staticmethod

Indicates if the given language is valid.

Parameters:

Name Type Description Default
language str

is the language to validate

required

Returns:

Type Description
bool

True if the language is valid, False otherwise.

is_valid_mnemonic(mnemonic) staticmethod

Indicates if a mnemonic is valid.

Parameters:

Name Type Description Default
mnemonic str

is the mnemonic to validate.

required

Returns:

Type Description
bool

True if the mnemonic is valid, False otherwise.

is_valid_payment_id(payment_id) staticmethod

Indicates if a payment id is valid.

Parameters:

Name Type Description Default
payment_id str

is the payment id to validate.

required

Returns:

Type Description
bool

True if the payment id is valid, False otherwise.

is_valid_private_spend_key(private_spend_key) staticmethod

Indicates if a private spend key is valid.

Parameters:

Name Type Description Default
private_spend_key str

is the private spend key to validate.

required

Returns:

Type Description
bool

True if the private spend key is valid, False otherwise.

is_valid_private_view_key(private_view_key) staticmethod

Indicates if a private view key is valid.

Parameters:

Name Type Description Default
private_view_key str

is the private view key to validate.

required

Returns:

Type Description
bool

True if the private view key is valid, False otherwise.

is_valid_public_spend_key(public_spend_key) staticmethod

Indicates if a public spend key is valid.

Parameters:

Name Type Description Default
public_spend_key str

is the public spend key to validate.

required

Returns:

Type Description
bool

True if the public spend key is valid, False otherwise.

is_valid_public_view_key(public_view_key) staticmethod

Indicates if a public view key is valid.

Parameters:

Name Type Description Default
public_view_key str

is the public view key to validate.

required

Returns:

Type Description
bool

True if the public view key is valid, False otherwise.

json_to_binary(json) staticmethod

Convert a JSON string into binary format.

Returns:

Type Description
bytes

Binary format.

set_log_level(loglevel) staticmethod

Set the library's log level with 0 being least verbose.

Parameters:

Name Type Description Default
loglevel int

the library's log level.

required

validate_address(address, network_type) staticmethod

Validates the given address.

Parameters:

Name Type Description Default
address str

is the address to validate.

required
network_type MoneroNetworkType

is the address's network type.

required

validate_mnemonic(mnemonic) staticmethod

Validates the given mnemonic phrase.

Parameters:

Name Type Description Default
mnemonic str

is the mnemonic to validate.

required

Raises:

Type Description
MoneroError

if the given mnemonic is invalid.

validate_payment_id(payment_id) staticmethod

Validate a payment id.

Parameters:

Name Type Description Default
payment_id str

is the payment id to validate.

required

Raises:

Type Description
MoneroError

if the given payment id is invalid.

validate_private_spend_key(private_spend_key) staticmethod

Validate a private spend key.

Parameters:

Name Type Description Default
private_spend_key str

is the private spend key to validate.

required

Raises:

Type Description
MoneroError

if the given private spend key is invalid.

validate_private_view_key(private_view_key) staticmethod

Validate a private view key.

Parameters:

Name Type Description Default
private_view_key str

is the private view key to validate.

required

Raises:

Type Description
MoneroError

if the given private view key is invalid.

validate_public_spend_key(public_spend_key) staticmethod

Validate a public spend key.

Parameters:

Name Type Description Default
public_spend_key str

is the public spend key to validate.

required

Raises:

Type Description
MoneroError

if the given public spend key is invalid.

validate_public_view_key(public_view_key) staticmethod

Validate a public view key.

Parameters:

Name Type Description Default
public_view_key str

is the public view key to validate.

required

Raises:

Type Description
MoneroError

if the given public view key is invalid.

xmr_to_atomic_units(amount_xmr) staticmethod

Convert XMR to atomic units.

Parameters:

Name Type Description Default
amount_xmr float

amount in XMR to convert to atomic units.

required

Returns:

Type Description
int

amount in atomic units.