|
monero-c
C ABI for using Monero
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>

Go to the source code of this file.
Macros | |
| #define | MONERO_EXPORT __attribute__((visibility("default"))) |
| Copyright (c) Libmonero. | |
| #define | MONERO_C_ABI_VERSION_MAJOR 0 |
| #define | MONERO_C_ABI_VERSION_MINOR 1 |
| #define | MONERO_C_ABI_VERSION_PATCH 1 |
Typedefs | |
| typedef enum monero_result | monero_result |
| typedef enum monero_utils_network_type | monero_utils_network_type |
Enumerations | |
| enum | monero_result { MONERO_OK = 0 , MONERO_ERROR = -1 } |
| enum | monero_utils_network_type { MONERO_UTILS_NETWORK_MAINNET = 0 , MONERO_UTILS_NETWORK_TESTNET = 1 , MONERO_UTILS_NETWORK_STAGENET = 2 , MONERO_UTILS_NETWORK_REGTEST = 3 } |
Functions | |
| MONERO_EXPORT const char * | monero_last_error (void) |
| Return the message of the most recent MONERO_ERROR result on the calling thread, from any monero_c function. | |
| MONERO_EXPORT void | monero_utils_free (void *ptr) |
| Frees a string or byte buffer returned by any monero_utils_* function. | |
| MONERO_EXPORT monero_result | monero_utils_get_abi_version (uint32_t *out_major, uint32_t *out_minor, uint32_t *out_patch) |
| Get the version of the C ABI of the loaded library. | |
| MONERO_EXPORT void | monero_utils_set_log_level (int32_t level) |
| Set the log level, which picks default category filters (0 = warnings and errors only, 4 = full trace). | |
| MONERO_EXPORT void | monero_utils_set_log_categories (const char *categories) |
| Set the log categories filter directly, overriding whatever monero_utils_set_log_level() last selected. | |
| MONERO_EXPORT void | monero_utils_configure_logging (const char *path, bool console) |
| Configures where log output is written. | |
| MONERO_EXPORT bool | monero_utils_is_valid_address (const char *address, int32_t network_type) |
| Check whether an address is valid for a given network. | |
| MONERO_EXPORT bool | monero_utils_is_valid_private_view_key (const char *private_view_key) |
| Check whether a private view key is valid. | |
| MONERO_EXPORT bool | monero_utils_is_valid_private_spend_key (const char *private_spend_key) |
| Check whether a private spend key is valid. | |
| MONERO_EXPORT bool | monero_utils_is_valid_public_view_key (const char *public_view_key) |
| Check whether a public view key is valid. | |
| MONERO_EXPORT bool | monero_utils_is_valid_public_spend_key (const char *public_spend_key) |
| Check whether a public spend key is valid. | |
| MONERO_EXPORT bool | monero_utils_is_valid_payment_id (const char *payment_id) |
| Check whether a payment id is valid. | |
| MONERO_EXPORT bool | monero_utils_is_valid_mnemonic (const char *mnemonic, const char *language) |
| Check whether a mnemonic seed is valid. | |
| MONERO_EXPORT bool | monero_utils_is_valid_language (const char *language) |
| Indicates if the given language is valid. | |
| MONERO_EXPORT monero_result | monero_utils_validate_address (const char *address, int32_t network_type) |
| Validate an address for a given network, like monero_utils_is_valid_address() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT monero_result | monero_utils_validate_private_view_key (const char *private_view_key) |
| Validate a private view key, like monero_utils_is_valid_private_view_key() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT monero_result | monero_utils_validate_private_spend_key (const char *private_spend_key) |
| Validate a private spend key, like monero_utils_is_valid_private_spend_key() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT monero_result | monero_utils_validate_public_view_key (const char *public_view_key) |
| Validate a public view key, like monero_utils_is_valid_public_view_key() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT monero_result | monero_utils_validate_public_spend_key (const char *public_spend_key) |
| Validate a public spend key, like monero_utils_is_valid_public_spend_key() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT monero_result | monero_utils_validate_payment_id (const char *payment_id) |
| Validate a payment id, like monero_utils_is_valid_payment_id() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT monero_result | monero_utils_validate_mnemonic (const char *mnemonic, const char *language) |
| Validate a mnemonic seed, like monero_utils_is_valid_mnemonic() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT monero_result | monero_utils_get_integrated_address (int32_t network_type, const char *standard_address, const char *payment_id, char **out_json) |
| Builds an integrated address from a standard address and payment id. | |
| MONERO_EXPORT monero_result | monero_utils_get_payment_uri (const char *tx_config_json, int32_t network_type, char **out_uri) |
| Create a payment URI from a transaction configuration. | |
| MONERO_EXPORT monero_result | monero_utils_parse_payment_uri (const char *uri, int32_t network_type, char **out_tx_config_json) |
| Parse a payment URI into a transaction configuration. | |
| MONERO_EXPORT monero_result | monero_utils_json_to_binary (const char *json, uint8_t **out_data, size_t *out_len) |
| Convert a JSON string to its binary-encoded (portable storage format) equivalent. | |
| MONERO_EXPORT monero_result | monero_utils_binary_to_json (const uint8_t *data, size_t len, char **out_json) |
| Convert a binary-encoded (portable storage format) buffer to its JSON equivalent. | |
| MONERO_EXPORT monero_result | monero_utils_binary_blocks_to_json (const uint8_t *data, size_t len, char **out_json) |
| Decodes a get_blocks.bin-style response. | |
| MONERO_EXPORT monero_result | monero_utils_binary_blocks_fast_to_json (const uint8_t *data, size_t len, char **out_json) |
| Decodes a get_blocks_by_height.bin-style response. | |
| MONERO_EXPORT monero_result | monero_utils_xmr_to_atomic_units (double amount_xmr, uint64_t *out_atomic_units) |
| Convert an amount in XMR to atomic units. | |
| MONERO_EXPORT double | monero_utils_atomic_units_to_xmr (uint64_t amount_atomic_units) |
| Convert an amount in atomic units to XMR. | |
| MONERO_EXPORT bool | monero_utils_parse_payment_id_long (const char *payment_id_str, uint8_t out_payment_id[32]) |
| Parse a long payment ID from a string. | |
| MONERO_EXPORT bool | monero_utils_parse_payment_id_short (const char *payment_id_str, uint8_t out_payment_id[8]) |
| Parse a short payment ID from a string. | |
| MONERO_EXPORT bool | monero_utils_is_valid_payment_id_long (const char *payment_id_str) |
| Check whether a long payment id is valid. | |
| MONERO_EXPORT bool | monero_utils_is_valid_payment_id_short (const char *payment_id_str) |
| Check whether a short payment id is valid. | |
| MONERO_EXPORT monero_result | monero_utils_validate_payment_id_long (const char *payment_id_str) |
| Validate a long payment id, like monero_utils_is_valid_payment_id_long() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT monero_result | monero_utils_validate_payment_id_short (const char *payment_id_str) |
| Validate a short payment id, like monero_utils_is_valid_payment_id_short() but reports the reason through monero_last_error() on failure. | |
| MONERO_EXPORT int32_t | monero_utils_get_ring_size (void) |
| Return the network-enforced ring size. | |
| #define MONERO_C_ABI_VERSION_MAJOR 0 |
| #define MONERO_C_ABI_VERSION_MINOR 1 |
| #define MONERO_C_ABI_VERSION_PATCH 1 |
| #define MONERO_EXPORT __attribute__((visibility("default"))) |
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.
Parts of this file are originally copyright (c) woodser
Parts of this file are originally copyright (c) 2014-2019, The Monero Project
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
| typedef enum monero_result monero_result |
| typedef enum monero_utils_network_type monero_utils_network_type |
| enum monero_result |
| MONERO_EXPORT const char * monero_last_error | ( | void | ) |
Return the message of the most recent MONERO_ERROR result on the calling thread, from any monero_c function.
A successful call doesn't clear it, so read it only after MONERO_ERROR.
| MONERO_EXPORT double monero_utils_atomic_units_to_xmr | ( | uint64_t | amount_atomic_units | ) |
Convert an amount in atomic units to XMR.
| amount_atomic_units | is the amount in atomic units to convert |
| MONERO_EXPORT monero_result monero_utils_binary_blocks_fast_to_json | ( | const uint8_t * | data, |
| size_t | len, | ||
| char ** | out_json | ||
| ) |
Decodes a get_blocks_by_height.bin-style response.
| data | is the binary-encoded buffer to decode |
| len | is the length of the binary-encoded buffer |
| out_json | receives the decoded JSON string, freed with monero_utils_free(). See monero_utils_binary_to_json(). |
| MONERO_EXPORT monero_result monero_utils_binary_blocks_to_json | ( | const uint8_t * | data, |
| size_t | len, | ||
| char ** | out_json | ||
| ) |
Decodes a get_blocks.bin-style response.
| data | is the binary-encoded buffer to decode |
| len | is the length of the binary-encoded buffer |
| out_json | receives the decoded JSON string, freed with monero_utils_free(). See monero_utils_binary_to_json(). |
| MONERO_EXPORT monero_result monero_utils_binary_to_json | ( | const uint8_t * | data, |
| size_t | len, | ||
| char ** | out_json | ||
| ) |
Convert a binary-encoded (portable storage format) buffer to its JSON equivalent.
| data | is the binary-encoded buffer to convert |
| len | is the length of the binary-encoded buffer |
| out_json | receives the decoded JSON string, freed with monero_utils_free() |
| MONERO_EXPORT void monero_utils_configure_logging | ( | const char * | path, |
| bool | console | ||
| ) |
Configures where log output is written.
| path | is the log file's base path |
| console | is whether to also write log output to the console |
| MONERO_EXPORT void monero_utils_free | ( | void * | ptr | ) |
Frees a string or byte buffer returned by any monero_utils_* function.
| ptr | is the pointer previously returned by a monero_utils_* function |
| MONERO_EXPORT monero_result monero_utils_get_abi_version | ( | uint32_t * | out_major, |
| uint32_t * | out_minor, | ||
| uint32_t * | out_patch | ||
| ) |
Get the version of the C ABI of the loaded library.
A binding compares it with the version it was written for, to detect a library that doesn't match.
| out_major | receives the major version |
| out_minor | receives the minor version |
| out_patch | receives the patch version |
| MONERO_EXPORT monero_result monero_utils_get_integrated_address | ( | int32_t | network_type, |
| const char * | standard_address, | ||
| const char * | payment_id, | ||
| char ** | out_json | ||
| ) |
Builds an integrated address from a standard address and payment id.
| network_type | is the network to validate the address against |
| standard_address | is the base address to integrate the payment id into |
| payment_id | is the payment id to integrate, or "" to generate a random one |
| out_json | receives a JSON-serialized monero_integrated_address, freed with monero_utils_free() |
| MONERO_EXPORT monero_result monero_utils_get_payment_uri | ( | const char * | tx_config_json, |
| int32_t | network_type, | ||
| char ** | out_uri | ||
| ) |
Create a payment URI from a transaction configuration.
| tx_config_json | is a JSON-serialized monero_tx_config with exactly one destination (address + amount) |
| network_type | is the network to format the URI's address for |
| out_uri | receives the payment URI string, freed with monero_utils_free() |
| MONERO_EXPORT int32_t monero_utils_get_ring_size | ( | void | ) |
Return the network-enforced ring size.
| MONERO_EXPORT bool monero_utils_is_valid_address | ( | const char * | address, |
| int32_t | network_type | ||
| ) |
Check whether an address is valid for a given network.
| address | is the address to validate |
| network_type | is the network to validate the address against |
| MONERO_EXPORT bool monero_utils_is_valid_language | ( | const char * | language | ) |
Indicates if the given language is valid.
| language | is the language to validate (case-sensitive, e.g. "English") |
| MONERO_EXPORT bool monero_utils_is_valid_mnemonic | ( | const char * | mnemonic, |
| const char * | language | ||
| ) |
Check whether a mnemonic seed is valid.
A mnemonic of more than 4096 bytes is never valid.
| mnemonic | is the mnemonic seed to validate |
| language | restricts validation to that seed language, or "" to accept any language |
| MONERO_EXPORT bool monero_utils_is_valid_payment_id | ( | const char * | payment_id | ) |
Check whether a payment id is valid.
| payment_id | is the payment id to validate, as 16 or 64 hex characters |
| MONERO_EXPORT bool monero_utils_is_valid_payment_id_long | ( | const char * | payment_id_str | ) |
Check whether a long payment id is valid.
| payment_id_str | is the payment id to validate, as 64 hex characters |
| MONERO_EXPORT bool monero_utils_is_valid_payment_id_short | ( | const char * | payment_id_str | ) |
Check whether a short payment id is valid.
| payment_id_str | is the payment id to validate, as 16 hex characters |
| MONERO_EXPORT bool monero_utils_is_valid_private_spend_key | ( | const char * | private_spend_key | ) |
Check whether a private spend key is valid.
| private_spend_key | is the private spend key to validate |
| MONERO_EXPORT bool monero_utils_is_valid_private_view_key | ( | const char * | private_view_key | ) |
Check whether a private view key is valid.
| private_view_key | is the private view key to validate |
| MONERO_EXPORT bool monero_utils_is_valid_public_spend_key | ( | const char * | public_spend_key | ) |
Check whether a public spend key is valid.
| public_spend_key | is the public spend key to validate |
| MONERO_EXPORT bool monero_utils_is_valid_public_view_key | ( | const char * | public_view_key | ) |
Check whether a public view key is valid.
| public_view_key | is the public view key to validate |
| MONERO_EXPORT monero_result monero_utils_json_to_binary | ( | const char * | json, |
| uint8_t ** | out_data, | ||
| size_t * | out_len | ||
| ) |
Convert a JSON string to its binary-encoded (portable storage format) equivalent.
| json | is the JSON string to convert |
| out_data | receives the binary-encoded buffer, freed with monero_utils_free() |
| out_len | receives the length of the binary-encoded buffer |
| MONERO_EXPORT bool monero_utils_parse_payment_id_long | ( | const char * | payment_id_str, |
| uint8_t | out_payment_id[32] | ||
| ) |
Parse a long payment ID from a string.
| payment_id_str | is the string to parse |
| out_payment_id | receives the parsed 32-byte payment id if valid |
| MONERO_EXPORT bool monero_utils_parse_payment_id_short | ( | const char * | payment_id_str, |
| uint8_t | out_payment_id[8] | ||
| ) |
Parse a short payment ID from a string.
| payment_id_str | is the string to parse |
| out_payment_id | receives the parsed 8-byte payment id if valid |
| MONERO_EXPORT monero_result monero_utils_parse_payment_uri | ( | const char * | uri, |
| int32_t | network_type, | ||
| char ** | out_tx_config_json | ||
| ) |
Parse a payment URI into a transaction configuration.
| uri | is the payment URI to parse |
| network_type | is the network to validate the URI's address against |
| out_tx_config_json | receives a JSON-serialized monero_tx_config parsed from the URI, freed with monero_utils_free() |
| MONERO_EXPORT void monero_utils_set_log_categories | ( | const char * | categories | ) |
Set the log categories filter directly, overriding whatever monero_utils_set_log_level() last selected.
| categories | is a comma-separated list of "category:level" pairs (e.g. "*:WARNING,net:FATAL"). Prefix with '+' to append to the current filter, or '-' to remove matching categories from it |
| MONERO_EXPORT void monero_utils_set_log_level | ( | int32_t | level | ) |
Set the log level, which picks default category filters (0 = warnings and errors only, 4 = full trace).
Use monero_utils_set_log_categories() for finer control.
| level | is the log level, 0 (least verbose) through 4 (most verbose) |
| MONERO_EXPORT monero_result monero_utils_validate_address | ( | const char * | address, |
| int32_t | network_type | ||
| ) |
Validate an address for a given network, like monero_utils_is_valid_address() but reports the reason through monero_last_error() on failure.
| address | is the address to validate |
| network_type | is the network to validate the address against |
| MONERO_EXPORT monero_result monero_utils_validate_mnemonic | ( | const char * | mnemonic, |
| const char * | language | ||
| ) |
Validate a mnemonic seed, like monero_utils_is_valid_mnemonic() but reports the reason through monero_last_error() on failure.
A mnemonic of more than 4096 bytes fails.
| mnemonic | is the mnemonic seed to validate |
| language | restricts validation to that seed language, or "" to accept any language |
| MONERO_EXPORT monero_result monero_utils_validate_payment_id | ( | const char * | payment_id | ) |
Validate a payment id, like monero_utils_is_valid_payment_id() but reports the reason through monero_last_error() on failure.
| payment_id | is the payment id to validate, as 16 or 64 hex characters |
| MONERO_EXPORT monero_result monero_utils_validate_payment_id_long | ( | const char * | payment_id_str | ) |
Validate a long payment id, like monero_utils_is_valid_payment_id_long() but reports the reason through monero_last_error() on failure.
| payment_id_str | is the payment id to validate, as 64 hex characters |
| MONERO_EXPORT monero_result monero_utils_validate_payment_id_short | ( | const char * | payment_id_str | ) |
Validate a short payment id, like monero_utils_is_valid_payment_id_short() but reports the reason through monero_last_error() on failure.
| payment_id_str | is the payment id to validate, as 16 hex characters |
| MONERO_EXPORT monero_result monero_utils_validate_private_spend_key | ( | const char * | private_spend_key | ) |
Validate a private spend key, like monero_utils_is_valid_private_spend_key() but reports the reason through monero_last_error() on failure.
| private_spend_key | is the private spend key to validate |
| MONERO_EXPORT monero_result monero_utils_validate_private_view_key | ( | const char * | private_view_key | ) |
Validate a private view key, like monero_utils_is_valid_private_view_key() but reports the reason through monero_last_error() on failure.
| private_view_key | is the private view key to validate |
| MONERO_EXPORT monero_result monero_utils_validate_public_spend_key | ( | const char * | public_spend_key | ) |
Validate a public spend key, like monero_utils_is_valid_public_spend_key() but reports the reason through monero_last_error() on failure.
| public_spend_key | is the public spend key to validate |
| MONERO_EXPORT monero_result monero_utils_validate_public_view_key | ( | const char * | public_view_key | ) |
Validate a public view key, like monero_utils_is_valid_public_view_key() but reports the reason through monero_last_error() on failure.
| public_view_key | is the public view key to validate |
| MONERO_EXPORT monero_result monero_utils_xmr_to_atomic_units | ( | double | amount_xmr, |
| uint64_t * | out_atomic_units | ||
| ) |
Convert an amount in XMR to atomic units.
| amount_xmr | is the amount in XMR to convert |
| out_atomic_units | receives the amount in atomic units (1 XMR = 10^12) |