diff --git a/src/cpp/common/py_monero_common_bindings.cpp b/src/cpp/common/py_monero_common_bindings.cpp index 9124d5a..a530e6a 100644 --- a/src/cpp/common/py_monero_common_bindings.cpp +++ b/src/cpp/common/py_monero_common_bindings.cpp @@ -298,8 +298,8 @@ void py_monero_bind_common(py::module_& m, PyMoneroTypes& t) { }); // monero_rpc_payment_info + def_keyword_init(t.py_monero_rpc_payment_info, monero_rpc_payment_info_keywords()); t.py_monero_rpc_payment_info - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_rpc_payment_info::deserialize(json)); }, py::arg("json")) @@ -307,8 +307,13 @@ void py_monero_bind_common(py::module_& m, PyMoneroTypes& t) { .def_readwrite("top_block_hash", &monero_rpc_payment_info::m_top_block_hash); // monero_ssl_options + def_keyword_init(t.py_monero_ssl_options, + keyword("ssl_private_key_path", &ssl_options::m_ssl_private_key_path), + keyword("ssl_certificate_path", &ssl_options::m_ssl_certificate_path), + keyword("ssl_ca_file", &ssl_options::m_ssl_ca_file), + keyword("ssl_allowed_fingerprints", &ssl_options::m_ssl_allowed_fingerprints), + keyword("ssl_allow_any_cert", &ssl_options::m_ssl_allow_any_cert)); t.py_monero_ssl_options - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(ssl_options::deserialize(json)); }, py::arg("json")) diff --git a/src/cpp/daemon/py_monero_daemon_bindings.cpp b/src/cpp/daemon/py_monero_daemon_bindings.cpp index 7b0f25f..88d2f6f 100644 --- a/src/cpp/daemon/py_monero_daemon_bindings.cpp +++ b/src/cpp/daemon/py_monero_daemon_bindings.cpp @@ -55,8 +55,12 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { // monero_fee_estimate - py::class_>(m, "MoneroFeeEstimate") - .def(py::init<>()) + py::class_> py_monero_fee_estimate(m, "MoneroFeeEstimate"); + def_keyword_init(py_monero_fee_estimate, + keyword("fee", &monero_fee_estimate::m_fee), + keyword("fees", &monero_fee_estimate::m_fees), + keyword("quantization_mask", &monero_fee_estimate::m_quantization_mask)); + py_monero_fee_estimate .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_fee_estimate::deserialize(json)); }, py::arg("json")) @@ -69,8 +73,10 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def(py::init<>()); // monero_version + def_keyword_init(t.py_monero_version, + keyword("number", &monero_version::m_number), + keyword("is_release", &monero_version::m_is_release)); t.py_monero_version - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_version::deserialize(json)); }, py::arg("json")) @@ -78,8 +84,8 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("is_release", &monero_version::m_is_release); // monero_block_header + def_keyword_init(t.py_monero_block_header, monero_block_header_keywords()); t.py_monero_block_header - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_block_header::deserialize(json)); }, py::arg("json")) @@ -113,8 +119,12 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { }, py::arg("other")); // monero_block (needs: monero_tx) + def_keyword_init(t.py_monero_block, std::tuple_cat(monero_block_header_keywords(), std::make_tuple( + keyword("hex", &monero_block::m_hex), + keyword("miner_tx", &monero_block::m_miner_tx), + keyword("txs", &monero_block::m_txs), + keyword("tx_hashes", &monero_block::m_tx_hashes)))); t.py_monero_block - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_block::deserialize(json)); }, py::arg("json")) @@ -132,8 +142,20 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { }, py::arg("other")); // monero_block_template - py::class_>(m, "MoneroBlockTemplate") - .def(py::init<>()) + py::class_> py_monero_block_template(m, "MoneroBlockTemplate"); + def_keyword_init(py_monero_block_template, + keyword("block_template_blob", &monero_block_template::m_block_template_blob), + keyword("block_hashing_blob", &monero_block_template::m_block_hashing_blob), + keyword("difficulty_low", &monero_block_template::m_difficulty_low), + keyword("difficulty_high", &monero_block_template::m_difficulty_high), + keyword("expected_reward", &monero_block_template::m_expected_reward), + keyword("height", &monero_block_template::m_height), + keyword("prev_hash", &monero_block_template::m_prev_hash), + keyword("reserved_offset", &monero_block_template::m_reserved_offset), + keyword("seed_height", &monero_block_template::m_seed_height), + keyword("seed_hash", &monero_block_template::m_seed_hash), + keyword("next_seed_hash", &monero_block_template::m_next_seed_hash)); + py_monero_block_template .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_block_template::deserialize(json)); }, py::arg("json")) @@ -150,8 +172,16 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("next_seed_hash", &monero_block_template::m_next_seed_hash); // monero_connection_span - py::class_>(m, "MoneroConnectionSpan") - .def(py::init<>()) + py::class_> py_monero_connection_span(m, "MoneroConnectionSpan"); + def_keyword_init(py_monero_connection_span, + keyword("connection_id", &monero_connection_span::m_connection_id), + keyword("num_blocks", &monero_connection_span::m_num_blocks), + keyword("remote_address", &monero_connection_span::m_remote_address), + keyword("rate", &monero_connection_span::m_rate), + keyword("speed", &monero_connection_span::m_speed), + keyword("size", &monero_connection_span::m_size), + keyword("start_height", &monero_connection_span::m_start_height)); + py_monero_connection_span .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_connection_span::deserialize(json)); }, py::arg("json")) @@ -164,8 +194,35 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("start_height", &monero_connection_span::m_start_height); // monero_peer - py::class_>(m, "MoneroPeer") - .def(py::init<>()) + py::class_> py_monero_peer(m, "MoneroPeer"); + def_keyword_init(py_monero_peer, + keyword("id", &monero_peer::m_id), + keyword("address", &monero_peer::m_address), + keyword("host", &monero_peer::m_host), + keyword("port", &monero_peer::m_port), + keyword("is_online", &monero_peer::m_is_online), + keyword("last_seen_timestamp", &monero_peer::m_last_seen_timestamp), + keyword("pruning_seed", &monero_peer::m_pruning_seed), + keyword("rpc_port", &monero_peer::m_rpc_port), + keyword("rpc_credits_per_hash", &monero_peer::m_rpc_credits_per_hash), + keyword("hash", &monero_peer::m_hash), + keyword("avg_download", &monero_peer::m_avg_download), + keyword("avg_upload", &monero_peer::m_avg_upload), + keyword("current_download", &monero_peer::m_current_download), + keyword("current_upload", &monero_peer::m_current_upload), + keyword("height", &monero_peer::m_height), + keyword("is_incoming", &monero_peer::m_is_incoming), + keyword("live_time", &monero_peer::m_live_time), + keyword("is_local_ip", &monero_peer::m_is_local_ip), + keyword("is_local_host", &monero_peer::m_is_local_host), + keyword("num_receives", &monero_peer::m_num_receives), + keyword("num_sends", &monero_peer::m_num_sends), + keyword("receive_idle_time", &monero_peer::m_receive_idle_time), + keyword("send_idle_time", &monero_peer::m_send_idle_time), + keyword("state", &monero_peer::m_state), + keyword("num_support_flags", &monero_peer::m_num_support_flags), + keyword("connection_type", &monero_peer::m_connection_type)); + py_monero_peer .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_peer::deserialize(json)); }, py::arg("json")) @@ -197,8 +254,15 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("connection_type", &monero_peer::m_connection_type); // monero_alt_chain - py::class_>(m, "MoneroAltChain") - .def(py::init<>()) + py::class_> py_monero_alt_chain(m, "MoneroAltChain"); + def_keyword_init(py_monero_alt_chain, + keyword("block_hashes", &monero_alt_chain::m_block_hashes), + keyword("difficulty_low", &monero_alt_chain::m_difficulty_low), + keyword("difficulty_high", &monero_alt_chain::m_difficulty_high), + keyword("height", &monero_alt_chain::m_height), + keyword("length", &monero_alt_chain::m_length), + keyword("main_chain_parent_block_hash", &monero_alt_chain::m_main_chain_parent_block_hash)); + py_monero_alt_chain .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_alt_chain::deserialize(json)); }, py::arg("json")) @@ -210,8 +274,13 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("main_chain_parent_block_hash", &monero_alt_chain::m_main_chain_parent_block_hash); // monero_ban - py::class_>(m, "MoneroBan") - .def(py::init<>()) + py::class_> py_monero_ban(m, "MoneroBan"); + def_keyword_init(py_monero_ban, + keyword("host", &monero_ban::m_host), + keyword("ip", &monero_ban::m_ip), + keyword("is_banned", &monero_ban::m_is_banned), + keyword("seconds", &monero_ban::m_seconds)); + py_monero_ban .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_ban::deserialize(json)); }, py::arg("json")) @@ -221,8 +290,13 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("seconds", &monero_ban::m_seconds); // monero_output_distribution_entry - py::class_>(m, "MoneroOutputDistributionEntry") - .def(py::init<>()) + py::class_> py_monero_output_distribution_entry(m, "MoneroOutputDistributionEntry"); + def_keyword_init(py_monero_output_distribution_entry, + keyword("amount", &monero_output_distribution_entry::m_amount), + keyword("base", &monero_output_distribution_entry::m_base), + keyword("distribution", &monero_output_distribution_entry::m_distribution), + keyword("start_height", &monero_output_distribution_entry::m_start_height)); + py_monero_output_distribution_entry .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_output_distribution_entry::deserialize(json)); }, py::arg("json")) @@ -232,8 +306,13 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("start_height", &monero_output_distribution_entry::m_start_height); // monero_output_histogram_entry - py::class_>(m, "MoneroOutputHistogramEntry") - .def(py::init<>()) + py::class_> py_monero_output_histogram_entry(m, "MoneroOutputHistogramEntry"); + def_keyword_init(py_monero_output_histogram_entry, + keyword("amount", &monero_output_histogram_entry::m_amount), + keyword("num_instances", &monero_output_histogram_entry::m_num_instances), + keyword("unlocked_instances", &monero_output_histogram_entry::m_unlocked_instances), + keyword("recent_instances", &monero_output_histogram_entry::m_recent_instances)); + py_monero_output_histogram_entry .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_output_histogram_entry::deserialize(json)); }, py::arg("json")) @@ -243,8 +322,17 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("recent_instances", &monero_output_histogram_entry::m_recent_instances); // monero_hard_fork_info - py::class_>(m, "MoneroHardForkInfo") - .def(py::init<>()) + py::class_> py_monero_hard_fork_info(m, "MoneroHardForkInfo"); + def_keyword_init(py_monero_hard_fork_info, std::tuple_cat(monero_rpc_payment_info_keywords(), std::make_tuple( + keyword("earliest_height", &monero_hard_fork_info::m_earliest_height), + keyword("is_enabled", &monero_hard_fork_info::m_is_enabled), + keyword("state", &monero_hard_fork_info::m_state), + keyword("threshold", &monero_hard_fork_info::m_threshold), + keyword("version", &monero_hard_fork_info::m_version), + keyword("num_votes", &monero_hard_fork_info::m_num_votes), + keyword("window", &monero_hard_fork_info::m_window), + keyword("voting", &monero_hard_fork_info::m_voting)))); + py_monero_hard_fork_info .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_hard_fork_info::deserialize(json)); }, py::arg("json")) @@ -258,8 +346,14 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("voting", &monero_hard_fork_info::m_voting); // monero_daemon_network_stats - py::class_>(m, "MoneroDaemonNetworkStats") - .def(py::init<>()) + py::class_> py_monero_daemon_network_stats(m, "MoneroDaemonNetworkStats"); + def_keyword_init(py_monero_daemon_network_stats, std::tuple_cat(monero_rpc_payment_info_keywords(), std::make_tuple( + keyword("start_time", &monero_daemon_network_stats::m_start_time), + keyword("total_packets_in", &monero_daemon_network_stats::m_total_packets_in), + keyword("total_bytes_in", &monero_daemon_network_stats::m_total_bytes_in), + keyword("total_packets_out", &monero_daemon_network_stats::m_total_packets_out), + keyword("total_bytes_out", &monero_daemon_network_stats::m_total_bytes_out)))); + py_monero_daemon_network_stats .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_daemon_network_stats::deserialize(json)); }, py::arg("json")) @@ -280,8 +374,14 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("hash", &monero_auxiliary_pow::m_hash); // monero_add_auxiliary_pow_result - py::class_>(m, "MoneroAddAuxiliaryPowResult") - .def(py::init<>()) + py::class_> py_monero_add_auxiliary_pow_result(m, "MoneroAddAuxiliaryPowResult"); + def_keyword_init(py_monero_add_auxiliary_pow_result, std::tuple_cat(monero_rpc_payment_info_keywords(), std::make_tuple( + keyword("block_template_blob", &monero_add_auxiliary_pow_result::m_block_template_blob), + keyword("block_hashing_blob", &monero_add_auxiliary_pow_result::m_block_hashing_blob), + keyword("merkle_root", &monero_add_auxiliary_pow_result::m_merkle_root), + keyword("merkle_tree_depth", &monero_add_auxiliary_pow_result::m_merkle_tree_depth), + keyword("aux_pow", &monero_add_auxiliary_pow_result::m_aux_pow)))); + py_monero_add_auxiliary_pow_result .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_add_auxiliary_pow_result::deserialize(json)); }, py::arg("json")) @@ -292,8 +392,17 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("aux_pow", &monero_add_auxiliary_pow_result::m_aux_pow); // monero_miner_data - py::class_>(m, "MoneroMinerData") - .def(py::init<>()) + py::class_> py_monero_miner_data(m, "MoneroMinerData"); + def_keyword_init(py_monero_miner_data, std::tuple_cat(monero_rpc_payment_info_keywords(), std::make_tuple( + keyword("major_version", &monero_miner_data::m_major_version), + keyword("height", &monero_miner_data::m_height), + keyword("prev_hash", &monero_miner_data::m_prev_hash), + keyword("seed_hash", &monero_miner_data::m_seed_hash), + keyword("difficulty", &monero_miner_data::m_difficulty), + keyword("median_weight", &monero_miner_data::m_median_weight), + keyword("already_generated_coins", &monero_miner_data::m_already_generated_coins), + keyword("tx_pool_backlog", &monero_miner_data::m_tx_pool_backlog)))); + py_monero_miner_data .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_miner_data::deserialize(json)); }, py::arg("json")) @@ -307,8 +416,11 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("tx_pool_backlog", &monero_miner_data::m_tx_pool_backlog); // monero_get_blocks_by_hash_result - py::class_>(m, "MoneroGetBlocksByHashResult") - .def(py::init<>()) + py::class_> py_monero_get_blocks_by_hash_result(m, "MoneroGetBlocksByHashResult"); + def_keyword_init(py_monero_get_blocks_by_hash_result, + keyword("blocks", &monero_get_blocks_by_hash_result::m_blocks), + keyword("current_height", &monero_get_blocks_by_hash_result::m_current_height)); + py_monero_get_blocks_by_hash_result .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_get_blocks_by_hash_result::deserialize(json)); }, py::arg("json")) @@ -316,8 +428,12 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("current_height", &monero_get_blocks_by_hash_result::m_current_height); // monero_get_block_hashes_result - py::class_>(m, "MoneroGetBlockHashesResult") - .def(py::init<>()) + py::class_> py_monero_get_block_hashes_result(m, "MoneroGetBlockHashesResult"); + def_keyword_init(py_monero_get_block_hashes_result, + keyword("hashes", &monero_get_block_hashes_result::m_hashes), + keyword("start_height", &monero_get_block_hashes_result::m_start_height), + keyword("current_height", &monero_get_block_hashes_result::m_current_height)); + py_monero_get_block_hashes_result .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_get_block_hashes_result::deserialize(json)); }, py::arg("json")) @@ -326,8 +442,11 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("current_height", &monero_get_block_hashes_result::m_current_height); // monero_prune_result - py::class_>(m, "MoneroPruneResult") - .def(py::init<>()) + py::class_> py_monero_prune_result(m, "MoneroPruneResult"); + def_keyword_init(py_monero_prune_result, + keyword("is_pruned", &monero_prune_result::m_is_pruned), + keyword("pruning_seed", &monero_prune_result::m_pruning_seed)); + py_monero_prune_result .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_prune_result::deserialize(json)); }, py::arg("json")) @@ -335,8 +454,15 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("pruning_seed", &monero_prune_result::m_pruning_seed); // monero_daemon_sync_info - py::class_>(m, "MoneroDaemonSyncInfo") - .def(py::init<>()) + py::class_> py_monero_daemon_sync_info(m, "MoneroDaemonSyncInfo"); + def_keyword_init(py_monero_daemon_sync_info, std::tuple_cat(monero_rpc_payment_info_keywords(), std::make_tuple( + keyword("height", &monero_daemon_sync_info::m_height), + keyword("peers", &monero_daemon_sync_info::m_peers), + keyword("spans", &monero_daemon_sync_info::m_spans), + keyword("target_height", &monero_daemon_sync_info::m_target_height), + keyword("next_needed_pruning_seed", &monero_daemon_sync_info::m_next_needed_pruning_seed), + keyword("overview", &monero_daemon_sync_info::m_overview)))); + py_monero_daemon_sync_info .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_daemon_sync_info::deserialize(json)); }, py::arg("json")) @@ -348,8 +474,43 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("overview", &monero_daemon_sync_info::m_overview); // monero_daemon_info - py::class_>(m, "MoneroDaemonInfo") - .def(py::init<>()) + py::class_> py_monero_daemon_info(m, "MoneroDaemonInfo"); + def_keyword_init(py_monero_daemon_info, std::tuple_cat(monero_rpc_payment_info_keywords(), std::make_tuple( + keyword("version", &monero_daemon_info::m_version), + keyword("num_alt_blocks", &monero_daemon_info::m_num_alt_blocks), + keyword("block_size_limit", &monero_daemon_info::m_block_size_limit), + keyword("block_size_median", &monero_daemon_info::m_block_size_median), + keyword("block_weight_limit", &monero_daemon_info::m_block_weight_limit), + keyword("block_weight_median", &monero_daemon_info::m_block_weight_median), + keyword("bootstrap_daemon_address", &monero_daemon_info::m_bootstrap_daemon_address), + keyword("difficulty_low", &monero_daemon_info::m_difficulty_low), + keyword("difficulty_high", &monero_daemon_info::m_difficulty_high), + keyword("cumulative_difficulty_low", &monero_daemon_info::m_cumulative_difficulty_low), + keyword("cumulative_difficulty_high", &monero_daemon_info::m_cumulative_difficulty_high), + keyword("free_space", &monero_daemon_info::m_free_space), + keyword("num_offline_peers", &monero_daemon_info::m_num_offline_peers), + keyword("num_online_peers", &monero_daemon_info::m_num_online_peers), + keyword("height", &monero_daemon_info::m_height), + keyword("height_without_bootstrap", &monero_daemon_info::m_height_without_bootstrap), + keyword("network_type", &monero_daemon_info::m_network_type), + keyword("is_offline", &monero_daemon_info::m_is_offline), + keyword("num_incoming_connections", &monero_daemon_info::m_num_incoming_connections), + keyword("num_outgoing_connections", &monero_daemon_info::m_num_outgoing_connections), + keyword("num_rpc_connections", &monero_daemon_info::m_num_rpc_connections), + keyword("start_timestamp", &monero_daemon_info::m_start_timestamp), + keyword("adjusted_timestamp", &monero_daemon_info::m_adjusted_timestamp), + keyword("target", &monero_daemon_info::m_target), + keyword("target_height", &monero_daemon_info::m_target_height), + keyword("num_txs", &monero_daemon_info::m_num_txs), + keyword("num_txs_pool", &monero_daemon_info::m_num_txs_pool), + keyword("was_bootstrap_ever_used", &monero_daemon_info::m_was_bootstrap_ever_used), + keyword("database_size", &monero_daemon_info::m_database_size), + keyword("update_available", &monero_daemon_info::m_update_available), + keyword("is_busy_syncing", &monero_daemon_info::m_is_busy_syncing), + keyword("is_synchronized", &monero_daemon_info::m_is_synchronized), + keyword("is_restricted", &monero_daemon_info::m_is_restricted), + keyword("is_regtest", &monero_daemon_info::m_is_regtest)))); + py_monero_daemon_info .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_daemon_info::deserialize(json)); }, py::arg("json")) @@ -389,8 +550,9 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("is_regtest", &monero_daemon_info::m_is_regtest); // monero_daemon_update_check_result - py::class_>(m, "MoneroDaemonUpdateCheckResult") - .def(py::init<>()) + py::class_> py_monero_daemon_update_check_result(m, "MoneroDaemonUpdateCheckResult"); + def_keyword_init(py_monero_daemon_update_check_result, monero_daemon_update_check_result_keywords()); + py_monero_daemon_update_check_result .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_daemon_update_check_result::deserialize(json)); }, py::arg("json")) @@ -401,16 +563,33 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("user_uri", &monero_daemon_update_check_result::m_user_uri); // monero_daemon_update_check_result - py::class_>(m, "MoneroDaemonUpdateDownloadResult") - .def(py::init<>()) + py::class_> py_monero_daemon_update_download_result(m, "MoneroDaemonUpdateDownloadResult"); + def_keyword_init(py_monero_daemon_update_download_result, std::tuple_cat(monero_daemon_update_check_result_keywords(), std::make_tuple( + keyword("download_path", &monero_daemon_update_download_result::m_download_path)))); + py_monero_daemon_update_download_result .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_daemon_update_download_result::deserialize(json)); }, py::arg("json")) .def_readwrite("download_path", &monero_daemon_update_download_result::m_download_path); // monero_submit_tx_result - py::class_>(m, "MoneroSubmitTxResult") - .def(py::init<>()) + py::class_> py_monero_submit_tx_result(m, "MoneroSubmitTxResult"); + def_keyword_init(py_monero_submit_tx_result, std::tuple_cat(monero_rpc_payment_info_keywords(), std::make_tuple( + keyword("is_good", &monero_submit_tx_result::m_is_good), + keyword("is_relayed", &monero_submit_tx_result::m_is_relayed), + keyword("is_double_spend", &monero_submit_tx_result::m_is_double_spend), + keyword("is_fee_too_low", &monero_submit_tx_result::m_is_fee_too_low), + keyword("is_mixin_too_low", &monero_submit_tx_result::m_is_mixin_too_low), + keyword("has_invalid_input", &monero_submit_tx_result::m_has_invalid_input), + keyword("has_invalid_output", &monero_submit_tx_result::m_has_invalid_output), + keyword("has_too_few_outputs", &monero_submit_tx_result::m_has_too_few_outputs), + keyword("is_overspend", &monero_submit_tx_result::m_is_overspend), + keyword("is_too_big", &monero_submit_tx_result::m_is_too_big), + keyword("sanity_check_failed", &monero_submit_tx_result::m_sanity_check_failed), + keyword("reason", &monero_submit_tx_result::m_reason), + keyword("is_tx_extra_too_big", &monero_submit_tx_result::m_is_tx_extra_too_big), + keyword("is_nonzero_unlock_time", &monero_submit_tx_result::m_is_nonzero_unlock_time)))); + py_monero_submit_tx_result .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_submit_tx_result::deserialize(json)); }, py::arg("json")) @@ -430,8 +609,11 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("is_nonzero_unlock_time", &monero_submit_tx_result::m_is_nonzero_unlock_time); // monero_generate_blocks_result - py::class_>(m, "MoneroGenerateBlocksResult") - .def(py::init<>()) + py::class_> py_monero_generate_blocks_result(m, "MoneroGenerateBlocksResult"); + def_keyword_init(py_monero_generate_blocks_result, + keyword("block_hashes", &monero_generate_blocks_result::m_block_hashes), + keyword("height", &monero_generate_blocks_result::m_height)); + py_monero_generate_blocks_result .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_generate_blocks_result::deserialize(json)); }, py::arg("json")) @@ -439,8 +621,22 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("height", &monero_generate_blocks_result::m_height); // monero_tx_pool_stats - py::class_>(m, "MoneroTxPoolStats") - .def(py::init<>()) + py::class_> py_monero_tx_pool_stats(m, "MoneroTxPoolStats"); + def_keyword_init(py_monero_tx_pool_stats, + keyword("num_txs", &monero_tx_pool_stats::m_num_txs), + keyword("num_not_relayed", &monero_tx_pool_stats::m_num_not_relayed), + keyword("num_failing", &monero_tx_pool_stats::m_num_failing), + keyword("num_double_spends", &monero_tx_pool_stats::m_num_double_spends), + keyword("num10m", &monero_tx_pool_stats::m_num10m), + keyword("fee_total", &monero_tx_pool_stats::m_fee_total), + keyword("bytes_max", &monero_tx_pool_stats::m_bytes_max), + keyword("bytes_med", &monero_tx_pool_stats::m_bytes_med), + keyword("bytes_min", &monero_tx_pool_stats::m_bytes_min), + keyword("bytes_total", &monero_tx_pool_stats::m_bytes_total), + keyword("histo98pc", &monero_tx_pool_stats::m_histo98pc), + keyword("oldest_timestamp", &monero_tx_pool_stats::m_oldest_timestamp), + keyword("histo", &monero_tx_pool_stats::m_histo)); + py_monero_tx_pool_stats .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_tx_pool_stats::deserialize(json)); }, py::arg("json")) @@ -459,8 +655,14 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("histo", &monero_tx_pool_stats::m_histo, py::return_value_policy::reference_internal); // monero_mining_status - py::class_>(m, "MoneroMiningStatus") - .def(py::init<>()) + py::class_> py_monero_mining_status(m, "MoneroMiningStatus"); + def_keyword_init(py_monero_mining_status, + keyword("is_active", &monero_mining_status::m_is_active), + keyword("is_background", &monero_mining_status::m_is_background), + keyword("address", &monero_mining_status::m_address), + keyword("speed", &monero_mining_status::m_speed), + keyword("num_threads", &monero_mining_status::m_num_threads)); + py_monero_mining_status .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_mining_status::deserialize(json)); }, py::arg("json")) @@ -471,8 +673,13 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("num_threads", &monero_mining_status::m_num_threads); // monero_miner_tx_sum - py::class_>(m, "MoneroMinerTxSum") - .def(py::init<>()) + py::class_> py_monero_miner_tx_sum(m, "MoneroMinerTxSum"); + def_keyword_init(py_monero_miner_tx_sum, + keyword("emission_sum_low", &monero_miner_tx_sum::m_emission_sum_low), + keyword("emission_sum_high", &monero_miner_tx_sum::m_emission_sum_high), + keyword("fee_sum_low", &monero_miner_tx_sum::m_fee_sum_low), + keyword("fee_sum_high", &monero_miner_tx_sum::m_fee_sum_high)); + py_monero_miner_tx_sum .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_miner_tx_sum::deserialize(json)); }, py::arg("json")) @@ -482,8 +689,8 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { .def_readwrite("fee_sum_high", &monero_miner_tx_sum::m_fee_sum_high); // monero_tx + def_keyword_init(t.py_monero_tx, monero_tx_keywords()); t.py_monero_tx - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_tx::deserialize(json)); }, py::arg("json")) @@ -543,8 +750,10 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { }); // monero_key_image + def_keyword_init(t.py_monero_key_image, + keyword("hex", &monero_key_image::m_hex), + keyword("signature", &monero_key_image::m_signature)); t.py_monero_key_image - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_key_image::deserialize(json)); }, py::arg("json")) @@ -562,8 +771,8 @@ void py_monero_bind_daemon(py::module_& m, PyMoneroTypes& t) { }, py::arg("other")); // monero_output + def_keyword_init(t.py_monero_output, monero_output_keywords()); t.py_monero_output - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_output::deserialize(json)); }, py::arg("json")) diff --git a/src/cpp/py_monero_types.h b/src/cpp/py_monero_types.h index 3f4c82f..1bb1596 100644 --- a/src/cpp/py_monero_types.h +++ b/src/cpp/py_monero_types.h @@ -119,6 +119,218 @@ using VectorMoneroSubaddress = std::vector; using VectorMoneroDestination = std::vector>; +// the argument of a keyword: when it is not given, the member keeps the value that the empty constructor gives it +template +struct keyword_value { + using type = boost::optional; + static void assign(Member& member, const type& value) { + if (value != boost::none) member = *value; + } +}; + +template +struct keyword_value> { + using type = boost::optional; + static void assign(boost::optional& member, const type& value) { + // a keyword that is not given keeps the value of the object that is copied + if (value != boost::none) member = value; + } +}; + +// a keyword of the constructor of a data class, and the member that it sets, which can be one of a base class +template +struct keyword_field { + using type = typename keyword_value::type; + const char* name; + Member Class::* member; + + template + void assign(const std::shared_ptr& object, const type& value) const { + keyword_value::assign((*object).*member, value); + } +}; + +// a keyword of an attribute that has a setter of its own, as the ones of the queries, which refer back to the query that has them +template +struct keyword_setter { + using type = boost::optional; + const char* name; + void (*set)(const std::shared_ptr&, const Value&); + + template + void assign(const std::shared_ptr& object, const type& value) const { + if (value != boost::none) set(object, *value); + } +}; + +template +keyword_field keyword(const char* name, Member Class::* member) { + return {name, member}; +} + +template +keyword_setter keyword(const char* name, void (*set)(const std::shared_ptr&, const Value&)) { + return {name, set}; +} + +// the constructor of a data class from keywords only, all of them optional, which also is the empty one. It has to be the only +// constructor of its class: among overloads, pybind11 converts the arguments of a call, as a list to a vector, only for the ones +// that have positional parameters (pybind11.h, the second pass of the dispatcher). Created is the class to make for an abstract one +template +void def_keyword_init(PyClass& cls, const Keywords&... keywords) { + using Class = typename PyClass::type; + using Object = std::conditional_t::value, Class, Created>; + cls.def(py::init([keywords...](const typename Keywords::type&... values) { + std::shared_ptr object = std::make_shared(); + (keywords.assign(object, values), ...); + return object; + }), py::kw_only(), (py::arg(keywords.name) = py::none())...); +} + +// the same, with the keywords in a tuple, as the ones that the classes that derive from another one share with it +template +void def_keyword_init(PyClass& cls, const std::tuple& keywords) { + std::apply([&cls](const Keywords&... keyword) { def_keyword_init(cls, keyword...); }, keywords); +} + +// as def_keyword_init, for a class that also copies another object of it, whose attributes the keywords replace +template +void def_copy_keyword_init(PyClass& cls, const keyword_field&... fields) { + cls.def(py::init([fields...](const boost::optional>& config, const typename keyword_value::type&... values) { + bool copy = config != boost::none && config.get() != nullptr; + auto object = copy ? std::make_shared(*config.get()) : std::make_shared(); + (keyword_value::assign((*object).*(fields.member), values), ...); + return object; + }), py::arg("config") = py::none(), py::kw_only(), (py::arg(fields.name) = py::none())..., py::keep_alive<1, 2>()); +} + +// the keywords of the classes that others derive from, each one declared once + +inline auto monero_rpc_payment_info_keywords() { + return std::make_tuple( + keyword("credits", &monero_rpc_payment_info::m_credits), + keyword("top_block_hash", &monero_rpc_payment_info::m_top_block_hash)); +} + +inline auto monero_tx_keywords() { + return std::make_tuple( + keyword("hash", &monero_tx::m_hash), + keyword("version", &monero_tx::m_version), + keyword("is_miner_tx", &monero_tx::m_is_miner_tx), + keyword("payment_id", &monero_tx::m_payment_id), + keyword("fee", &monero_tx::m_fee), + keyword("ring_size", &monero_tx::m_ring_size), + keyword("relay", &monero_tx::m_relay), + keyword("is_relayed", &monero_tx::m_is_relayed), + keyword("is_confirmed", &monero_tx::m_is_confirmed), + keyword("in_tx_pool", &monero_tx::m_in_tx_pool), + keyword("is_locked", &monero_tx::m_is_locked), + keyword("num_confirmations", &monero_tx::m_num_confirmations), + keyword("unlock_time", &monero_tx::m_unlock_time), + keyword("last_relayed_timestamp", &monero_tx::m_last_relayed_timestamp), + keyword("received_timestamp", &monero_tx::m_received_timestamp), + keyword("is_double_spend_seen", &monero_tx::m_is_double_spend_seen), + keyword("key", &monero_tx::m_key), + keyword("full_hex", &monero_tx::m_full_hex), + keyword("pruned_hex", &monero_tx::m_pruned_hex), + keyword("prunable_hex", &monero_tx::m_prunable_hex), + keyword("prunable_hash", &monero_tx::m_prunable_hash), + keyword("size", &monero_tx::m_size), + keyword("weight", &monero_tx::m_weight), + keyword("inputs", &monero_tx::m_inputs), + keyword("outputs", &monero_tx::m_outputs), + keyword("output_indices", &monero_tx::m_output_indices), + keyword("metadata", &monero_tx::m_metadata), + keyword("common_tx_sets", &monero_tx::m_common_tx_sets), + keyword("extra", &monero_tx::m_extra), + keyword("rct_signatures", &monero_tx::m_rct_signatures), + keyword("rct_sig_prunable", &monero_tx::m_rct_sig_prunable), + keyword("is_kept_by_block", &monero_tx::m_is_kept_by_block), + keyword("is_failed", &monero_tx::m_is_failed), + keyword("last_failed_height", &monero_tx::m_last_failed_height), + keyword("last_failed_hash", &monero_tx::m_last_failed_hash), + keyword("max_used_block_height", &monero_tx::m_max_used_block_height), + keyword("max_used_block_hash", &monero_tx::m_max_used_block_hash), + keyword("signatures", &monero_tx::m_signatures)); +} + +inline auto monero_daemon_update_check_result_keywords() { + return std::make_tuple( + keyword("is_update_available", &monero_daemon_update_check_result::m_is_update_available), + keyword("version", &monero_daemon_update_check_result::m_version), + keyword("hash", &monero_daemon_update_check_result::m_hash), + keyword("auto_uri", &monero_daemon_update_check_result::m_auto_uri), + keyword("user_uri", &monero_daemon_update_check_result::m_user_uri)); +} + +inline auto monero_block_header_keywords() { + return std::make_tuple( + keyword("hash", &monero_block_header::m_hash), + keyword("height", &monero_block_header::m_height), + keyword("timestamp", &monero_block_header::m_timestamp), + keyword("size", &monero_block_header::m_size), + keyword("weight", &monero_block_header::m_weight), + keyword("long_term_weight", &monero_block_header::m_long_term_weight), + keyword("depth", &monero_block_header::m_depth), + keyword("difficulty_high", &monero_block_header::m_difficulty_high), + keyword("difficulty_low", &monero_block_header::m_difficulty_low), + keyword("cumulative_difficulty_high", &monero_block_header::m_cumulative_difficulty_high), + keyword("cumulative_difficulty_low", &monero_block_header::m_cumulative_difficulty_low), + keyword("major_version", &monero_block_header::m_major_version), + keyword("minor_version", &monero_block_header::m_minor_version), + keyword("nonce", &monero_block_header::m_nonce), + keyword("miner_tx_hash", &monero_block_header::m_miner_tx_hash), + keyword("num_txs", &monero_block_header::m_num_txs), + keyword("orphan_status", &monero_block_header::m_orphan_status), + keyword("prev_hash", &monero_block_header::m_prev_hash), + keyword("reward", &monero_block_header::m_reward), + keyword("pow_hash", &monero_block_header::m_pow_hash)); +} + +inline auto monero_check_keywords() { + return std::make_tuple( + keyword("is_good", &monero_check::m_is_good)); +} + +inline auto monero_output_keywords() { + return std::make_tuple( + keyword("key_image", &monero_output::m_key_image), + keyword("amount", &monero_output::m_amount), + keyword("index", &monero_output::m_index), + keyword("stealth_public_key", &monero_output::m_stealth_public_key), + keyword("mask", &monero_output::m_mask), + keyword("ring_output_indices", &monero_output::m_ring_output_indices)); +} + +inline auto monero_transfer_keywords() { + return std::make_tuple( + keyword("account_index", &monero_transfer::m_account_index), + keyword("amount", &monero_transfer::m_amount)); +} + +inline auto monero_output_wallet_keywords() { + return std::tuple_cat(monero_output_keywords(), std::make_tuple( + keyword("account_index", &monero_output_wallet::m_account_index), + keyword("subaddress_index", &monero_output_wallet::m_subaddress_index), + keyword("is_spent", &monero_output_wallet::m_is_spent), + keyword("is_frozen", &monero_output_wallet::m_is_frozen))); +} + +inline auto monero_tx_wallet_keywords() { + return std::tuple_cat(monero_tx_keywords(), std::make_tuple( + keyword("is_incoming", &monero_tx_wallet::m_is_incoming), + keyword("is_outgoing", &monero_tx_wallet::m_is_outgoing), + keyword("incoming_transfers", &monero_tx_wallet::m_incoming_transfers), + keyword("outgoing_transfer", &monero_tx_wallet::m_outgoing_transfer), + keyword("note", &monero_tx_wallet::m_note), + keyword("input_sum", &monero_tx_wallet::m_input_sum), + keyword("output_sum", &monero_tx_wallet::m_output_sum), + keyword("change_address", &monero_tx_wallet::m_change_address), + keyword("change_amount", &monero_tx_wallet::m_change_amount), + keyword("num_dummy_outputs", &monero_tx_wallet::m_num_dummy_outputs), + keyword("extra_hex", &monero_tx_wallet::m_extra_hex))); +} + /** * Holds every pybind11 type handle that must be registered before any * method is bound, so classes can reference each other (as base classes diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp index 41efc51..2848e34 100644 --- a/src/cpp/wallet/py_monero_wallet_bindings.cpp +++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp @@ -130,11 +130,53 @@ static auto call_without_gil(const Call& call) -> decltype(call()) { return call(); } +// the setters of the keywords of the queries, which refer back to the query that has them as their properties do +static void set_transferquery_outgoing(const std::shared_ptr& query, const bool& outgoing) { + if (query->m_is_incoming != boost::none && query->m_is_incoming.get() == outgoing) throw monero_error("Transfer query contradicts itself: incoming and outgoing"); + query->m_is_incoming = !outgoing; +} + +static void set_transferquery_tx_query(const std::shared_ptr& query, const std::shared_ptr& tx_query) { + query->m_tx_query = tx_query; + tx_query->m_transfer_query = query; +} + +static void set_txquery_transfer_query(const std::shared_ptr& query, const std::shared_ptr& transfer_query) { + query->m_transfer_query = transfer_query; + transfer_query->m_tx_query = query; +} + +static void set_txquery_input_query(const std::shared_ptr& query, const std::shared_ptr& input_query) { + query->m_input_query = input_query; + input_query->m_tx_query = query; +} + +static void set_txquery_output_query(const std::shared_ptr& query, const std::shared_ptr& output_query) { + query->m_output_query = output_query; + output_query->m_tx_query = query; +} + void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { // monero_wallet_config + def_copy_keyword_init(t.py_monero_wallet_config, + keyword("path", &monero_wallet_config::m_path), + keyword("password", &monero_wallet_config::m_password), + keyword("network_type", &monero_wallet_config::m_network_type), + keyword("server", &monero_wallet_config::m_server), + keyword("is_trusted_daemon", &monero_wallet_config::m_is_trusted_daemon), + keyword("seed", &monero_wallet_config::m_seed), + keyword("seed_offset", &monero_wallet_config::m_seed_offset), + keyword("primary_address", &monero_wallet_config::m_primary_address), + keyword("private_view_key", &monero_wallet_config::m_private_view_key), + keyword("private_spend_key", &monero_wallet_config::m_private_spend_key), + keyword("restore_height", &monero_wallet_config::m_restore_height), + keyword("language", &monero_wallet_config::m_language), + keyword("save_current", &monero_wallet_config::m_save_current), + keyword("account_lookahead", &monero_wallet_config::m_account_lookahead), + keyword("subaddress_lookahead", &monero_wallet_config::m_subaddress_lookahead), + keyword("is_multisig", &monero_wallet_config::m_is_multisig), + keyword("regtest", &monero_wallet_config::m_regtest)); t.py_monero_wallet_config - .def(py::init<>()) - .def(py::init(), py::arg("config"), py::keep_alive<1, 2>()) .def_static("deserialize", [](const std::string& config_json) { MONERO_CATCH_AND_RETHROW(monero_wallet_config::deserialize(config_json)); }, py::arg("config_json")) @@ -163,8 +205,17 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }); // monero_subaddress + def_keyword_init(t.py_monero_subaddress, + keyword("account_index", &monero_subaddress::m_account_index), + keyword("index", &monero_subaddress::m_index), + keyword("address", &monero_subaddress::m_address), + keyword("label", &monero_subaddress::m_label), + keyword("balance", &monero_subaddress::m_balance), + keyword("unlocked_balance", &monero_subaddress::m_unlocked_balance), + keyword("num_unspent_outputs", &monero_subaddress::m_num_unspent_outputs), + keyword("is_used", &monero_subaddress::m_is_used), + keyword("num_blocks_to_unlock", &monero_subaddress::m_num_blocks_to_unlock)); t.py_monero_subaddress - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_subaddress::deserialize(json)); }, py::arg("json")) @@ -189,8 +240,14 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("received_money", &monero_sync_result::m_received_money); // monero_account + def_keyword_init(t.py_monero_account, + keyword("index", &monero_account::m_index), + keyword("primary_address", &monero_account::m_primary_address), + keyword("balance", &monero_account::m_balance), + keyword("unlocked_balance", &monero_account::m_unlocked_balance), + keyword("tag", &monero_account::m_tag), + keyword("subaddresses", &monero_account::m_subaddresses)); t.py_monero_account - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_account::deserialize(json)); }, py::arg("json")) @@ -229,8 +286,8 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }); // monero_transfer + def_keyword_init(t.py_monero_transfer, monero_transfer_keywords()); t.py_monero_transfer - .def(py::init<>()) .def_readwrite("tx", &monero_transfer::m_tx) .def_readwrite("account_index", &monero_transfer::m_account_index) .def_readwrite("amount", &monero_transfer::m_amount) @@ -249,8 +306,11 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }); // monero_incoming_transfer + def_keyword_init(t.py_monero_incoming_transfer, std::tuple_cat(monero_transfer_keywords(), std::make_tuple( + keyword("address", &monero_incoming_transfer::m_address), + keyword("subaddress_index", &monero_incoming_transfer::m_subaddress_index), + keyword("num_suggested_confirmations", &monero_incoming_transfer::m_num_suggested_confirmations)))); t.py_monero_incoming_transfer - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_incoming_transfer::deserialize(json)); }, py::arg("json")) @@ -270,8 +330,11 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }); // monero_outgoing_transfer + def_keyword_init(t.py_monero_outgoing_transfer, std::tuple_cat(monero_transfer_keywords(), std::make_tuple( + keyword("subaddress_indices", &monero_outgoing_transfer::m_subaddress_indices), + keyword("addresses", &monero_outgoing_transfer::m_addresses), + keyword("destinations", &monero_outgoing_transfer::m_destinations)))); t.py_monero_outgoing_transfer - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_outgoing_transfer::deserialize(json)); }, py::arg("json")) @@ -287,8 +350,17 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }); // monero_transfer_query + def_keyword_init(t.py_monero_transfer_query, std::tuple_cat(monero_transfer_keywords(), std::make_tuple( + keyword("incoming", &monero_transfer_query::m_is_incoming), + keyword("address", &monero_transfer_query::m_address), + keyword("addresses", &monero_transfer_query::m_addresses), + keyword("subaddress_index", &monero_transfer_query::m_subaddress_index), + keyword("subaddress_indices", &monero_transfer_query::m_subaddress_indices), + keyword("destinations", &monero_transfer_query::m_destinations), + keyword("has_destinations", &monero_transfer_query::m_has_destinations), + keyword("outgoing", &set_transferquery_outgoing), + keyword("tx_query", &set_transferquery_tx_query)))); t.py_monero_transfer_query - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_transfer_query::deserialize(json)); }, py::arg("json")) @@ -332,8 +404,8 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }, py::arg("transfer"), py::arg("query_parent") = true); // monero_output_wallet + def_keyword_init(t.py_monero_output_wallet, monero_output_wallet_keywords()); t.py_monero_output_wallet - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_output_wallet::deserialize(json)); }, py::arg("json")) @@ -354,8 +426,11 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }); // monero_output_query + def_keyword_init(t.py_monero_output_query, std::tuple_cat(monero_output_wallet_keywords(), std::make_tuple( + keyword("subaddress_indices", &monero_output_query::m_subaddress_indices), + keyword("min_amount", &monero_output_query::m_min_amount), + keyword("max_amount", &monero_output_query::m_max_amount)))); t.py_monero_output_query - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_output_query::deserialize(json)); }, py::arg("json")) @@ -390,8 +465,8 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }, py::arg("output"), py::arg("query_parent") = true); // monero_tx_wallet + def_keyword_init(t.py_monero_tx_wallet, monero_tx_wallet_keywords()); t.py_monero_tx_wallet - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_tx_wallet::deserialize(json)); }, py::arg("json")) @@ -449,8 +524,18 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }, py::arg("tgt")); // monero_tx_query + def_keyword_init(t.py_monero_tx_query, std::tuple_cat(monero_tx_wallet_keywords(), std::make_tuple( + keyword("hashes", &monero_tx_query::m_hashes), + keyword("has_payment_id", &monero_tx_query::m_has_payment_id), + keyword("payment_ids", &monero_tx_query::m_payment_ids), + keyword("height", &monero_tx_query::m_height), + keyword("min_height", &monero_tx_query::m_min_height), + keyword("max_height", &monero_tx_query::m_max_height), + keyword("include_outputs", &monero_tx_query::m_include_outputs), + keyword("transfer_query", &set_txquery_transfer_query), + keyword("input_query", &set_txquery_input_query), + keyword("output_query", &set_txquery_output_query)))); t.py_monero_tx_query - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_tx_query::deserialize(json)); }, py::arg("json")) @@ -493,8 +578,12 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }, py::arg("query")); // monero_tx_set + def_keyword_init(t.py_monero_tx_set, + keyword("txs", &monero_tx_set::m_txs), + keyword("signed_tx_hex", &monero_tx_set::m_signed_tx_hex), + keyword("unsigned_tx_hex", &monero_tx_set::m_unsigned_tx_hex), + keyword("multisig_tx_hex", &monero_tx_set::m_multisig_tx_hex)); t.py_monero_tx_set - .def(py::init<>()) .def_static("deserialize", [](const std::string& tx_set_json) { MONERO_CATCH_AND_RETHROW(monero_tx_set::deserialize(tx_set_json)); }, py::arg("tx_set_json")) @@ -504,8 +593,11 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("multisig_tx_hex", &monero_tx_set::m_multisig_tx_hex); // monero_integrated_address + def_keyword_init(t.py_monero_integrated_address, + keyword("standard_address", &monero_integrated_address::m_standard_address), + keyword("payment_id", &monero_integrated_address::m_payment_id), + keyword("integrated_address", &monero_integrated_address::m_integrated_address)); t.py_monero_integrated_address - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_integrated_address::deserialize(json)); }, py::arg("json")) @@ -525,9 +617,25 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("network_type", &monero_decoded_address::m_network_type); // monero_tx_config + def_copy_keyword_init(t.py_monero_tx_config, + keyword("address", &monero_tx_config::m_address), + keyword("amount", &monero_tx_config::m_amount), + keyword("destinations", &monero_tx_config::m_destinations), + keyword("subtract_fee_from", &monero_tx_config::m_subtract_fee_from), + keyword("payment_id", &monero_tx_config::m_payment_id), + keyword("priority", &monero_tx_config::m_priority), + keyword("ring_size", &monero_tx_config::m_ring_size), + keyword("fee", &monero_tx_config::m_fee), + keyword("account_index", &monero_tx_config::m_account_index), + keyword("subaddress_indices", &monero_tx_config::m_subaddress_indices), + keyword("can_split", &monero_tx_config::m_can_split), + keyword("relay", &monero_tx_config::m_relay), + keyword("note", &monero_tx_config::m_note), + keyword("recipient_name", &monero_tx_config::m_recipient_name), + keyword("below_amount", &monero_tx_config::m_below_amount), + keyword("sweep_each_subaddress", &monero_tx_config::m_sweep_each_subaddress), + keyword("key_image", &monero_tx_config::m_key_image)); t.py_monero_tx_config - .def(py::init<>()) - .def(py::init(), py::arg("config")) .def_static("deserialize", [](const std::string& config_json) { MONERO_CATCH_AND_RETHROW(monero_tx_config::deserialize(config_json)); }, py::arg("config_json")) @@ -565,8 +673,10 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }); // monero_key_image_export_result + def_keyword_init(t.py_monero_key_image_export_result, + keyword("offset", &monero_key_image_export_result::m_offset), + keyword("key_images", &monero_key_image_export_result::m_key_images)); t.py_monero_key_image_export_result - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_key_image_export_result::deserialize(json)); }, py::arg("json")) @@ -574,8 +684,11 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("key_images", &monero_key_image_export_result::m_key_images); // monero_key_image_import_result + def_keyword_init(t.py_monero_key_image_import_result, + keyword("height", &monero_key_image_import_result::m_height), + keyword("spent_amount", &monero_key_image_import_result::m_spent_amount), + keyword("unspent_amount", &monero_key_image_import_result::m_unspent_amount)); t.py_monero_key_image_import_result - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_key_image_import_result::deserialize(json)); }, py::arg("json")) @@ -584,8 +697,12 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("unspent_amount", &monero_key_image_import_result::m_unspent_amount); // monero_message_signature_result + def_keyword_init(t.py_monero_message_signature_result, + keyword("is_good", &monero_message_signature_result::m_is_good), + keyword("version", &monero_message_signature_result::m_version), + keyword("is_old", &monero_message_signature_result::m_is_old), + keyword("signature_type", &monero_message_signature_result::m_signature_type)); t.py_monero_message_signature_result - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_message_signature_result::deserialize(json)); }, py::arg("json")) @@ -595,16 +712,19 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("signature_type", &monero_message_signature_result::m_signature_type); // monero_check + def_keyword_init(t.py_monero_check, monero_check_keywords()); t.py_monero_check - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_check::deserialize(json)); }, py::arg("json")) .def_readwrite("is_good", &monero_check::m_is_good); // monero_check_tx + def_keyword_init(t.py_monero_check_tx, std::tuple_cat(monero_check_keywords(), std::make_tuple( + keyword("in_tx_pool", &monero_check_tx::m_in_tx_pool), + keyword("num_confirmations", &monero_check_tx::m_num_confirmations), + keyword("received_amount", &monero_check_tx::m_received_amount)))); t.py_monero_check_tx - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_check_tx::deserialize(json)); }, py::arg("json")) @@ -613,8 +733,10 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("received_amount", &monero_check_tx::m_received_amount); // monero_check_reserve + def_keyword_init(t.py_monero_check_reserve, std::tuple_cat(monero_check_keywords(), std::make_tuple( + keyword("total_amount", &monero_check_reserve::m_total_amount), + keyword("unconfirmed_spent_amount", &monero_check_reserve::m_unconfirmed_spent_amount)))); t.py_monero_check_reserve - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_check_reserve::deserialize(json)); }, py::arg("json")) @@ -622,8 +744,12 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("unconfirmed_spent_amount", &monero_check_reserve::m_unconfirmed_spent_amount); // monero_multisig_info + def_keyword_init(t.py_monero_multisig_info, + keyword("is_multisig", &monero_multisig_info::m_is_multisig), + keyword("is_ready", &monero_multisig_info::m_is_ready), + keyword("threshold", &monero_multisig_info::m_threshold), + keyword("num_participants", &monero_multisig_info::m_num_participants)); t.py_monero_multisig_info - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_multisig_info::deserialize(json)); }, py::arg("json")) @@ -633,8 +759,10 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("num_participants", &monero_multisig_info::m_num_participants); // monero_multisig_init_result + def_keyword_init(t.py_monero_multisig_init_result, + keyword("address", &monero_multisig_init_result::m_address), + keyword("multisig_hex", &monero_multisig_init_result::m_multisig_hex)); t.py_monero_multisig_init_result - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_multisig_init_result::deserialize(json)); }, py::arg("json")) @@ -642,8 +770,10 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_readwrite("multisig_hex", &monero_multisig_init_result::m_multisig_hex); // monero_multisig_sign_result + def_keyword_init(t.py_monero_multisig_sign_result, + keyword("signed_multisig_tx_hex", &monero_multisig_sign_result::m_signed_multisig_tx_hex), + keyword("tx_hashes", &monero_multisig_sign_result::m_tx_hashes)); t.py_monero_multisig_sign_result - .def(py::init<>()) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_multisig_sign_result::deserialize(json)); }, py::arg("json")) diff --git a/src/monero/monero_account.pyi b/src/monero/monero_account.pyi index 455a619..25a312c 100644 --- a/src/monero/monero_account.pyi +++ b/src/monero/monero_account.pyi @@ -28,6 +28,23 @@ class MoneroAccount(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero account.""" + def __init__( + self, *, + index: int | None = None, + primary_address: str | None = None, + balance: int | None = None, + unlocked_balance: int | None = None, + tag: str | None = None, + subaddresses: list[MoneroSubaddress] | None = None + ) -> None: + """ + Initialize a Monero account. The attributes that are not given keep the values of an empty one. + + :param int|None index: the account index. + :param str|None primary_address: the account primary address. + :param int|None balance: the account balance. + :param int|None unlocked_balance: the account unlocked balance. + :param str|None tag: the account tag. + :param list[MoneroSubaddress]|None subaddresses: list of account subaddresses. + """ ... diff --git a/src/monero/monero_add_auxiliary_pow_result.pyi b/src/monero/monero_add_auxiliary_pow_result.pyi index 3151573..188553b 100644 --- a/src/monero/monero_add_auxiliary_pow_result.pyi +++ b/src/monero/monero_add_auxiliary_pow_result.pyi @@ -29,6 +29,25 @@ class MoneroAddAuxiliaryPowResult(MoneroRpcPaymentInfo): """ ... - def __init__(self) -> None: - """Initialize a Monero add auxiliary proof-of-work result.""" + def __init__( + self, *, + credits: int | None = None, + top_block_hash: str | None = None, + block_template_blob: str | None = None, + block_hashing_blob: str | None = None, + merkle_root: str | None = None, + merkle_tree_depth: int | None = None, + aux_pow: list[MoneroAuxiliaryPow] | None = None + ) -> None: + """ + Initialize a Monero add auxiliary pow result. The attributes that are not given keep the values of an empty one. + + :param int|None credits: if payment for RPC is enabled, the number of credits available to the requesting client. Otherwise, 0. + :param str|None top_block_hash: if payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`. + :param str|None block_template_blob: the updated block template blob. + :param str|None block_hashing_blob: the updated block hashing blob. + :param str|None merkle_root: the Merkle root committing to the auxiliary blocks. + :param int|None merkle_tree_depth: the depth of the auxiliary Merkle tree. + :param list[MoneroAuxiliaryPow]|None aux_pow: the (possibly reordered) auxiliary proof-of-work entries. + """ ... diff --git a/src/monero/monero_alt_chain.pyi b/src/monero/monero_alt_chain.pyi index 5cc651e..58e7b56 100644 --- a/src/monero/monero_alt_chain.pyi +++ b/src/monero/monero_alt_chain.pyi @@ -27,6 +27,23 @@ class MoneroAltChain(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero alt chain info.""" + def __init__( + self, *, + block_hashes: list[str] | None = None, + difficulty_low: int | None = None, + difficulty_high: int | None = None, + height: int | None = None, + length: int | None = None, + main_chain_parent_block_hash: str | None = None + ) -> None: + """ + Initialize a Monero alt chain. The attributes that are not given keep the values of an empty one. + + :param list[str]|None block_hashes: list of all block hashes in the alternative chain that are not in the main chain. + :param int|None difficulty_low: cumulative difficulty of all blocks in the alternative chain (Least-significant 64 bits of 128-bit integer). + :param int|None difficulty_high: cumulative difficulty of all blocks in the alternative chain (Most-significant 64 bits of the 128-bit integer). + :param int|None height: the block height of the first diverging block of this alternative chain. + :param int|None length: the length in blocks of this alternative chain, after divergence. + :param str|None main_chain_parent_block_hash: the hash of the greatest height block that is shared between the alternative chain and the main chain. + """ ... diff --git a/src/monero/monero_ban.pyi b/src/monero/monero_ban.pyi index 71afa93..8fc2b5f 100644 --- a/src/monero/monero_ban.pyi +++ b/src/monero/monero_ban.pyi @@ -23,6 +23,13 @@ class MoneroBan(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero banhammer.""" + def __init__(self, *, host: str | None = None, ip: int | None = None, is_banned: bool | None = None, seconds: int | None = None) -> None: + """ + Initialize a Monero ban. The attributes that are not given keep the values of an empty one. + + :param str|None host: host ban. + :param int|None ip: IP ban. + :param bool|None is_banned: indicates if ban on the `host` is active (`True`) or not (`False`). + :param int|None seconds: indicates the duration of the ban in seconds. + """ ... diff --git a/src/monero/monero_block.pyi b/src/monero/monero_block.pyi index d2c2cbe..16a1998 100644 --- a/src/monero/monero_block.pyi +++ b/src/monero/monero_block.pyi @@ -27,8 +27,61 @@ class MoneroBlock(MoneroBlockHeader): """ ... - def __init__(self) -> None: - """Initialize a Monero block.""" + def __init__( + self, *, + hash: str | None = None, + height: int | None = None, + timestamp: int | None = None, + size: int | None = None, + weight: int | None = None, + long_term_weight: int | None = None, + depth: int | None = None, + difficulty_high: int | None = None, + difficulty_low: int | None = None, + cumulative_difficulty_high: int | None = None, + cumulative_difficulty_low: int | None = None, + major_version: int | None = None, + minor_version: int | None = None, + nonce: int | None = None, + miner_tx_hash: str | None = None, + num_txs: int | None = None, + orphan_status: bool | None = None, + prev_hash: str | None = None, + reward: int | None = None, + pow_hash: str | None = None, + hex: str | None = None, + miner_tx: MoneroTx | None = None, + txs: list[MoneroTx] | None = None, + tx_hashes: list[str] | None = None + ) -> None: + """ + Initialize a Monero block. The attributes that are not given keep the values of an empty one. + + :param str|None hash: the hash of this block. + :param int|None height: the number of blocks preceding this block on the blockchain. + :param int|None timestamp: the unix time at which the block was recorded into the blockchain. + :param int|None size: backward compatibility, same as `weight`, use that instead. + :param int|None weight: the adjusted block size, in bytes. This is the raw size, plus a positive adjustment for any Bulletproof transactions with more than 2 outputs. + :param int|None long_term_weight: the long term block weight, based on the median weight of the preceding 100000 blocks. + :param int|None depth: the number of blocks succeeding this block on the blockchain. A larger number means an older block. + :param int|None difficulty_high: the strength of the Monero network based on mining power. + :param int|None difficulty_low: the strength of the Monero network based on mining power. + :param int|None cumulative_difficulty_high: cumulative difficulty of all blocks up to the block in the reply. + :param int|None cumulative_difficulty_low: cumulative difficulty of all blocks up to the block in the reply. + :param int|None major_version: the major version of the monero protocol at this block height. + :param int|None minor_version: the minor version of the monero protocol at this block height. + :param int|None nonce: A cryptographic random one-time number used in mining a Monero block. + :param str|None miner_tx_hash: the hash of this block's coinbase transaction. + :param int|None num_txs: number of transactions included in this block. + :param bool|None orphan_status: if `True`, this block is not part of the longest chain. + :param str|None prev_hash: the hash of the block immediately preceding this block in the chain. + :param int|None reward: the amount of atomic-units rewarded to the miner. The reward is the sum of new coins created (the emission) and fees paid by transactions in this block. Note: 1 XMR = 1e12 atomic-units. + :param str|None pow_hash: the hash, as a hexadecimal string, calculated from the block as proof-of-work. + :param str|None hex: hexadecimal blob of block information. + :param MoneroTx|None miner_tx: miner transaction information. + :param list[MoneroTx]|None txs: list of non-coinbase transactions in the block. + :param list[str]|None tx_hashes: list of hashes of non-coinbase transactions in the block. + """ ... @typing.override diff --git a/src/monero/monero_block_header.pyi b/src/monero/monero_block_header.pyi index 7cca5a6..69ec0b4 100644 --- a/src/monero/monero_block_header.pyi +++ b/src/monero/monero_block_header.pyi @@ -60,8 +60,53 @@ class MoneroBlockHeader(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero block header.""" + def __init__( + self, *, + hash: str | None = None, + height: int | None = None, + timestamp: int | None = None, + size: int | None = None, + weight: int | None = None, + long_term_weight: int | None = None, + depth: int | None = None, + difficulty_high: int | None = None, + difficulty_low: int | None = None, + cumulative_difficulty_high: int | None = None, + cumulative_difficulty_low: int | None = None, + major_version: int | None = None, + minor_version: int | None = None, + nonce: int | None = None, + miner_tx_hash: str | None = None, + num_txs: int | None = None, + orphan_status: bool | None = None, + prev_hash: str | None = None, + reward: int | None = None, + pow_hash: str | None = None + ) -> None: + """ + Initialize a Monero block header. The attributes that are not given keep the values of an empty one. + + :param str|None hash: the hash of this block. + :param int|None height: the number of blocks preceding this block on the blockchain. + :param int|None timestamp: the unix time at which the block was recorded into the blockchain. + :param int|None size: backward compatibility, same as `weight`, use that instead. + :param int|None weight: the adjusted block size, in bytes. This is the raw size, plus a positive adjustment for any Bulletproof transactions with more than 2 outputs. + :param int|None long_term_weight: the long term block weight, based on the median weight of the preceding 100000 blocks. + :param int|None depth: the number of blocks succeeding this block on the blockchain. A larger number means an older block. + :param int|None difficulty_high: the strength of the Monero network based on mining power. + :param int|None difficulty_low: the strength of the Monero network based on mining power. + :param int|None cumulative_difficulty_high: cumulative difficulty of all blocks up to the block in the reply. + :param int|None cumulative_difficulty_low: cumulative difficulty of all blocks up to the block in the reply. + :param int|None major_version: the major version of the monero protocol at this block height. + :param int|None minor_version: the minor version of the monero protocol at this block height. + :param int|None nonce: A cryptographic random one-time number used in mining a Monero block. + :param str|None miner_tx_hash: the hash of this block's coinbase transaction. + :param int|None num_txs: number of transactions included in this block. + :param bool|None orphan_status: if `True`, this block is not part of the longest chain. + :param str|None prev_hash: the hash of the block immediately preceding this block in the chain. + :param int|None reward: the amount of atomic-units rewarded to the miner. The reward is the sum of new coins created (the emission) and fees paid by transactions in this block. Note: 1 XMR = 1e12 atomic-units. + :param str|None pow_hash: the hash, as a hexadecimal string, calculated from the block as proof-of-work. + """ ... def copy(self) -> MoneroBlockHeader: diff --git a/src/monero/monero_block_template.pyi b/src/monero/monero_block_template.pyi index ef361b1..a2b377e 100644 --- a/src/monero/monero_block_template.pyi +++ b/src/monero/monero_block_template.pyi @@ -41,6 +41,33 @@ class MoneroBlockTemplate(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero block template.""" + def __init__( + self, *, + block_template_blob: str | None = None, + block_hashing_blob: str | None = None, + difficulty_low: int | None = None, + difficulty_high: int | None = None, + expected_reward: int | None = None, + height: int | None = None, + prev_hash: str | None = None, + reserved_offset: int | None = None, + seed_height: int | None = None, + seed_hash: str | None = None, + next_seed_hash: str | None = None + ) -> None: + """ + Initialize a Monero block template. The attributes that are not given keep the values of an empty one. + + :param str|None block_template_blob: blob on which to try to mine a new block. + :param str|None block_hashing_blob: blob on which to try to find a valid nonce. + :param int|None difficulty_low: network difficulty (Least-significant 64 bits of 128-bit integer). + :param int|None difficulty_high: network difficulty (Most-significant 64 bits of 128-bit integer). + :param int|None expected_reward: coinbase reward expected to be received if block is successfully mined. + :param int|None height: height on which to mine. + :param str|None prev_hash: hash of the most recent block on which to mine the next block. + :param int|None reserved_offset: byte offset into `block_template_blob` of the `reserve_size` scratch bytes the daemon left free in the coinbase transaction's extra field, where a pool writes its own data (e.g. an extra-nonce it varies to search the nonce space). + :param int|None seed_height: height of block to use as seed for Random-X proof-of-work. + :param str|None seed_hash: hash of block to use as seed for Random-X proof-of-work. + :param str|None next_seed_hash: hash of the next block to use as seed for Random-X proof-of-work. + """ ... diff --git a/src/monero/monero_check.pyi b/src/monero/monero_check.pyi index fa246b9..14e58ec 100644 --- a/src/monero/monero_check.pyi +++ b/src/monero/monero_check.pyi @@ -17,6 +17,10 @@ class MoneroCheck(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero check.""" + def __init__(self, *, is_good: bool | None = None) -> None: + """ + Initialize a Monero check. The attributes that are not given keep the values of an empty one. + + :param bool|None is_good: indicates if check was successful. + """ ... diff --git a/src/monero/monero_check_reserve.pyi b/src/monero/monero_check_reserve.pyi index 0d4e6ae..f4c50bf 100644 --- a/src/monero/monero_check_reserve.pyi +++ b/src/monero/monero_check_reserve.pyi @@ -22,6 +22,12 @@ class MoneroCheckReserve(MoneroCheck): """ ... - def __init__(self) -> None: - """Initialize a Monero reserve check.""" + def __init__(self, *, is_good: bool | None = None, total_amount: int | None = None, unconfirmed_spent_amount: int | None = None) -> None: + """ + Initialize a Monero check reserve. The attributes that are not given keep the values of an empty one. + + :param bool|None is_good: indicates if check was successful. + :param int|None total_amount: the reserve total amount. + :param int|None unconfirmed_spent_amount: the reserve unconfirmed spent amount. + """ ... diff --git a/src/monero/monero_check_tx.pyi b/src/monero/monero_check_tx.pyi index 937a5f2..e351269 100644 --- a/src/monero/monero_check_tx.pyi +++ b/src/monero/monero_check_tx.pyi @@ -24,6 +24,19 @@ class MoneroCheckTx(MoneroCheck): """ ... - def __init__(self) -> None: - """Initialize a Monero transaction check.""" + def __init__( + self, *, + is_good: bool | None = None, + in_tx_pool: bool | None = None, + num_confirmations: int | None = None, + received_amount: int | None = None + ) -> None: + """ + Initialize a Monero check transaction. The attributes that are not given keep the values of an empty one. + + :param bool|None is_good: indicates if check was successful. + :param bool|None in_tx_pool: states if the transaction is in pool (`True`) or included in a block (`False`) + :param int|None num_confirmations: transaction network confirmations. + :param int|None received_amount: amount received in the transaction. + """ ... diff --git a/src/monero/monero_connection_span.pyi b/src/monero/monero_connection_span.pyi index 7ffa9dd..f85ed16 100644 --- a/src/monero/monero_connection_span.pyi +++ b/src/monero/monero_connection_span.pyi @@ -29,6 +29,25 @@ class MoneroConnectionSpan(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero connection span.""" + def __init__( + self, *, + connection_id: str | None = None, + num_blocks: int | None = None, + remote_address: str | None = None, + rate: int | None = None, + speed: int | None = None, + size: int | None = None, + start_height: int | None = None + ) -> None: + """ + Initialize a Monero connection span. The attributes that are not given keep the values of an empty one. + + :param str|None connection_id: id of the P2P connection this span of blocks was (or is being) downloaded over. + :param int|None num_blocks: number of blocks in this span. + :param str|None remote_address: peer address the node is downloading (or has downloaded) than span from. + :param int|None rate: download rate for this span, in bytes per second. + :param int|None speed: relative speed of this connection as a percentage (0-100) of the fastest peer currently downloading blocks. + :param int|None size: total number of bytes in that span's blocks (including txes). + :param int|None start_height: block height of the first block in that span. + """ ... diff --git a/src/monero/monero_daemon_info.pyi b/src/monero/monero_daemon_info.pyi index 5c8c944..1471a70 100644 --- a/src/monero/monero_daemon_info.pyi +++ b/src/monero/monero_daemon_info.pyi @@ -87,6 +87,83 @@ class MoneroDaemonInfo(MoneroRpcPaymentInfo): """ ... - def __init__(self) -> None: - """Initialize a Monero daemon info.""" + def __init__( + self, *, + credits: int | None = None, + top_block_hash: str | None = None, + version: str | None = None, + num_alt_blocks: int | None = None, + block_size_limit: int | None = None, + block_size_median: int | None = None, + block_weight_limit: int | None = None, + block_weight_median: int | None = None, + bootstrap_daemon_address: str | None = None, + difficulty_low: int | None = None, + difficulty_high: int | None = None, + cumulative_difficulty_low: int | None = None, + cumulative_difficulty_high: int | None = None, + free_space: int | None = None, + num_offline_peers: int | None = None, + num_online_peers: int | None = None, + height: int | None = None, + height_without_bootstrap: int | None = None, + network_type: MoneroNetworkType | None = None, + is_offline: bool | None = None, + num_incoming_connections: int | None = None, + num_outgoing_connections: int | None = None, + num_rpc_connections: int | None = None, + start_timestamp: int | None = None, + adjusted_timestamp: int | None = None, + target: int | None = None, + target_height: int | None = None, + num_txs: int | None = None, + num_txs_pool: int | None = None, + was_bootstrap_ever_used: bool | None = None, + database_size: int | None = None, + update_available: bool | None = None, + is_busy_syncing: bool | None = None, + is_synchronized: bool | None = None, + is_restricted: bool | None = None, + is_regtest: bool | None = None + ) -> None: + """ + Initialize a Monero daemon info. The attributes that are not given keep the values of an empty one. + + :param int|None credits: if payment for RPC is enabled, the number of credits available to the requesting client. Otherwise, 0. + :param str|None top_block_hash: if payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`. + :param str|None version: the version of the Monero software the node is running. + :param int|None num_alt_blocks: number of alternative blocks to main chain. + :param int|None block_size_limit: backward compatibility, same as `block_weight_limit`, use that instead. + :param int|None block_size_median: backward compatibility, same as `block_weight_median`, use that instead. + :param int|None block_weight_limit: maximum allowed adjusted block size based on latest `100000` blocks. + :param int|None block_weight_median: median adjusted block size of latest `100000` blocks. + :param str|None bootstrap_daemon_address: bootstrap-node to give immediate usability to wallets while syncing by proxying RPC to it. + :param int|None difficulty_low: the least-significant 64 bits of the 128-bit network difficulty. + :param int|None difficulty_high: the most-significant 64 bits of the 128-bit network difficulty. + :param int|None cumulative_difficulty_low: least-significant 64 bits of the 128-bit cumulative difficulty. + :param int|None cumulative_difficulty_high: most-significant 64 bits of the 128-bit cumulative difficulty. + :param int|None free_space: available disk space on the node. + :param int|None num_offline_peers: number of peers that are marked as not reachable on the network. + :param int|None num_online_peers: number of peers that are marked as reachable on the network. + :param int|None height: current length of longest chain known to daemon. + :param int|None height_without_bootstrap: current length of the local chain of the daemon. + :param MoneroNetworkType|None network_type: network type (`MAINNET`, `TESTNET`, or `STAGENET`). + :param bool|None is_offline: states if the node is offline (`True`) or online (`False`). + :param int|None num_incoming_connections: number of peers connected to and pulling from your node. + :param int|None num_outgoing_connections: number of peers that you are connected to and getting information from. + :param int|None num_rpc_connections: number of RPC client connected to the daemon (Including this RPC request). + :param int|None start_timestamp: start time of the daemon, as UNIX time. + :param int|None adjusted_timestamp: current time approximated from chain data, as Unix time. + :param int|None target: current target for next proof of work. + :param int|None target_height: the height of the next block in the chain. + :param int|None num_txs: total number of non-coinbase transactions in the chain. + :param int|None num_txs_pool: number of transactions that have been broadcast but not included in a block. + :param bool|None was_bootstrap_ever_used: states if a bootstrap node has ever been used since the daemon started. + :param int|None database_size: the size of the blockchain database, in bytes. + :param bool|None update_available: states if a newer Monero software version is available. + :param bool|None is_busy_syncing: states if new blocks are being added (`True`) or not (`False`). + :param bool|None is_synchronized: states if the node is synchronized (`True`) or not (`False`). + :param bool|None is_restricted: indicates that the node RPC interface is restricted (`True`) or not (`False`). + :param bool|None is_regtest: states if the node is running in regtest mode (`True`) or not (`False`). + """ ... diff --git a/src/monero/monero_daemon_network_stats.pyi b/src/monero/monero_daemon_network_stats.pyi index 0b46f7d..d48306a 100644 --- a/src/monero/monero_daemon_network_stats.pyi +++ b/src/monero/monero_daemon_network_stats.pyi @@ -28,6 +28,25 @@ class MoneroDaemonNetworkStats(MoneroRpcPaymentInfo): """ ... - def __init__(self) -> None: - """Initialize a Monero daemon network stats.""" + def __init__( + self, *, + credits: int | None = None, + top_block_hash: str | None = None, + start_time: int | None = None, + total_packets_in: int | None = None, + total_bytes_in: int | None = None, + total_packets_out: int | None = None, + total_bytes_out: int | None = None + ) -> None: + """ + Initialize a Monero daemon network stats. The attributes that are not given keep the values of an empty one. + + :param int|None credits: if payment for RPC is enabled, the number of credits available to the requesting client. Otherwise, 0. + :param str|None top_block_hash: if payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`. + :param int|None start_time: unix timestamp when the statistics window started. + :param int|None total_packets_in: total number of packets received. + :param int|None total_bytes_in: total number of bytes received. + :param int|None total_packets_out: total number of packets sent. + :param int|None total_bytes_out: total number of bytes sent. + """ ... diff --git a/src/monero/monero_daemon_sync_info.pyi b/src/monero/monero_daemon_sync_info.pyi index 6a58f45..4d89d05 100644 --- a/src/monero/monero_daemon_sync_info.pyi +++ b/src/monero/monero_daemon_sync_info.pyi @@ -35,6 +35,27 @@ class MoneroDaemonSyncInfo(MoneroRpcPaymentInfo): """ ... - def __init__(self) -> None: - """Initialize a Monero daemon sync info.""" + def __init__( + self, *, + credits: int | None = None, + top_block_hash: str | None = None, + height: int | None = None, + peers: list[MoneroPeer] | None = None, + spans: list[MoneroConnectionSpan] | None = None, + target_height: int | None = None, + next_needed_pruning_seed: int | None = None, + overview: str | None = None + ) -> None: + """ + Initialize a Monero daemon sync info. The attributes that are not given keep the values of an empty one. + + :param int|None credits: if payment for RPC is enabled, the number of credits available to the requesting client. Otherwise, 0. + :param str|None top_block_hash: if payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`. + :param int|None height: daemon blockchain height. + :param list[MoneroPeer]|None peers: list of peers connected to the node + :param list[MoneroConnectionSpan]|None spans: currently connected peers to download blocks from. + :param int|None target_height: target height the node is syncing from (will be 0 if node is fully synced). + :param int|None next_needed_pruning_seed: the next pruning seed needed for pruned sync. + :param str|None overview: overview of current block queue where each character in the string represents a block set in the queue. `'.' = requested but not received, 'o' = set received, 'm' = received set that matches the next blocks needed` + """ ... diff --git a/src/monero/monero_daemon_update_check_result.pyi b/src/monero/monero_daemon_update_check_result.pyi index bcba511..b95d3ca 100644 --- a/src/monero/monero_daemon_update_check_result.pyi +++ b/src/monero/monero_daemon_update_check_result.pyi @@ -25,6 +25,21 @@ class MoneroDaemonUpdateCheckResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero update check result.""" + def __init__( + self, *, + is_update_available: bool | None = None, + version: str | None = None, + hash: str | None = None, + auto_uri: str | None = None, + user_uri: str | None = None + ) -> None: + """ + Initialize a Monero daemon update check result. The attributes that are not given keep the values of an empty one. + + :param bool|None is_update_available: indicates if an update is available to download. + :param str|None version: version available for download. + :param str|None hash: integrity check hash. + :param str|None auto_uri: URL automatically generated by the daemon to download the update. + :param str|None user_uri: alternative user URI. + """ ... diff --git a/src/monero/monero_daemon_update_download_result.pyi b/src/monero/monero_daemon_update_download_result.pyi index 6ed5b14..e0752a1 100644 --- a/src/monero/monero_daemon_update_download_result.pyi +++ b/src/monero/monero_daemon_update_download_result.pyi @@ -20,6 +20,23 @@ class MoneroDaemonUpdateDownloadResult(MoneroDaemonUpdateCheckResult): """ ... - def __init__(self) -> None: - """Initialize a Monero update download result.""" + def __init__( + self, *, + is_update_available: bool | None = None, + version: str | None = None, + hash: str | None = None, + auto_uri: str | None = None, + user_uri: str | None = None, + download_path: str | None = None + ) -> None: + """ + Initialize a Monero daemon update download result. The attributes that are not given keep the values of an empty one. + + :param bool|None is_update_available: indicates if an update is available to download. + :param str|None version: version available for download. + :param str|None hash: integrity check hash. + :param str|None auto_uri: URL automatically generated by the daemon to download the update. + :param str|None user_uri: alternative user URI. + :param str|None download_path: path to download the update. + """ ... diff --git a/src/monero/monero_fee_estimate.pyi b/src/monero/monero_fee_estimate.pyi index 45b6bff..63f11a3 100644 --- a/src/monero/monero_fee_estimate.pyi +++ b/src/monero/monero_fee_estimate.pyi @@ -21,6 +21,12 @@ class MoneroFeeEstimate(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero fee estimate.""" + def __init__(self, *, fee: int | None = None, fees: list[int] | None = None, quantization_mask: int | None = None) -> None: + """ + Initialize a Monero fee estimate. The attributes that are not given keep the values of an empty one. + + :param int|None fee: amount of fees estimated per byte in atomic-units. + :param list[int]|None fees: represents the base fees at different priorities `[slow, normal, fast, fastest]`. + :param int|None quantization_mask: final fee should be rounded up to an even multiple of this value. + """ ... diff --git a/src/monero/monero_generate_blocks_result.pyi b/src/monero/monero_generate_blocks_result.pyi index 9a40c0e..39f8f42 100644 --- a/src/monero/monero_generate_blocks_result.pyi +++ b/src/monero/monero_generate_blocks_result.pyi @@ -9,8 +9,13 @@ class MoneroGenerateBlocksResult(SerializableStruct): height: int | None """New chain height.""" - def __init__(self) -> None: - """Initialize a Monero generate blocks result.""" + def __init__(self, *, block_hashes: list[str] | None = None, height: int | None = None) -> None: + """ + Initialize a Monero generate blocks result. The attributes that are not given keep the values of an empty one. + + :param list[str]|None block_hashes: generated block hashes. + :param int|None height: new chain height. + """ ... @staticmethod diff --git a/src/monero/monero_get_block_hashes_result.pyi b/src/monero/monero_get_block_hashes_result.pyi index ae9dac6..5e53114 100644 --- a/src/monero/monero_get_block_hashes_result.pyi +++ b/src/monero/monero_get_block_hashes_result.pyi @@ -21,6 +21,12 @@ class MoneroGetBlockHashesResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero get block hashes result.""" + def __init__(self, *, hashes: list[str] | None = None, start_height: int | None = None, current_height: int | None = None) -> None: + """ + Initialize a Monero get block hashes result. The attributes that are not given keep the values of an empty one. + + :param list[str]|None hashes: the requested block hashes, starting at (and including) the last block in common with the request. + :param int|None start_height: the height of the first hash in `hashes`. + :param int|None current_height: the daemon's chain height at request time. + """ ... diff --git a/src/monero/monero_get_blocks_by_hash_result.pyi b/src/monero/monero_get_blocks_by_hash_result.pyi index 03cfefa..95a9633 100644 --- a/src/monero/monero_get_blocks_by_hash_result.pyi +++ b/src/monero/monero_get_blocks_by_hash_result.pyi @@ -20,6 +20,11 @@ class MoneroGetBlocksByHashResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero get blocks by hash result.""" + def __init__(self, *, blocks: list[MoneroBlock] | None = None, current_height: int | None = None) -> None: + """ + Initialize a Monero get blocks by hash result. The attributes that are not given keep the values of an empty one. + + :param list[MoneroBlock]|None blocks: the retrieved blocks. + :param int|None current_height: the daemon's chain height at request time. + """ ... diff --git a/src/monero/monero_hard_fork_info.pyi b/src/monero/monero_hard_fork_info.pyi index b52627e..87bba94 100644 --- a/src/monero/monero_hard_fork_info.pyi +++ b/src/monero/monero_hard_fork_info.pyi @@ -37,6 +37,31 @@ class MoneroHardForkInfo(MoneroRpcPaymentInfo): """ ... - def __init__(self) -> None: - """Initialize a Monero hard fork info.""" + def __init__( + self, *, + credits: int | None = None, + top_block_hash: str | None = None, + earliest_height: int | None = None, + is_enabled: bool | None = None, + state: int | None = None, + threshold: int | None = None, + version: int | None = None, + num_votes: int | None = None, + window: int | None = None, + voting: int | None = None + ) -> None: + """ + Initialize a Monero hard fork info. The attributes that are not given keep the values of an empty one. + + :param int|None credits: if payment for RPC is enabled, the number of credits available to the requesting client. Otherwise, 0. + :param str|None top_block_hash: if payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`. + :param int|None earliest_height: block height at which hard fork would be enabled if voted in. + :param bool|None is_enabled: tells if hard fork is enforced. + :param int|None state: current hard fork state. `0` (There is likely a hard fork), `1` (An update is needed to fork properly), or `2` (Everything looks good). + :param int|None threshold: minimum percent of votes to trigger hard fork. Default is 80. + :param int|None version: the major block version for the fork. + :param int|None num_votes: number of votes towards hard fork. + :param int|None window: number of blocks over which current votes are cast. Default is `10080` blocks. + :param int|None voting: hard fork voting status. + """ ... diff --git a/src/monero/monero_incoming_transfer.pyi b/src/monero/monero_incoming_transfer.pyi index c1eeccd..ada97f6 100644 --- a/src/monero/monero_incoming_transfer.pyi +++ b/src/monero/monero_incoming_transfer.pyi @@ -23,8 +23,23 @@ class MoneroIncomingTransfer(MoneroTransfer): """ ... - def __init__(self) -> None: - """Initialize a Monero incoming transfer.""" + def __init__( + self, *, + account_index: int | None = None, + amount: int | None = None, + address: str | None = None, + subaddress_index: int | None = None, + num_suggested_confirmations: int | None = None + ) -> None: + """ + Initialize a Monero incoming transfer. The attributes that are not given keep the values of an empty one. + + :param int|None account_index: index of the account related to this transfer. + :param int|None amount: transfer amount in atomic-units. + :param str|None address: the address that received funds within this transfer. + :param int|None subaddress_index: the subaddress index that received funds within this transfer. + :param int|None num_suggested_confirmations: the number of suggested confirmations before moving funds. + """ ... @typing.override diff --git a/src/monero/monero_integrated_address.pyi b/src/monero/monero_integrated_address.pyi index e248d08..7056086 100644 --- a/src/monero/monero_integrated_address.pyi +++ b/src/monero/monero_integrated_address.pyi @@ -21,6 +21,12 @@ class MoneroIntegratedAddress(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero integrated address.""" + def __init__(self, *, standard_address: str | None = None, payment_id: str | None = None, integrated_address: str | None = None) -> None: + """ + Initialize a Monero integrated address. The attributes that are not given keep the values of an empty one. + + :param str|None standard_address: the standard address related to this integrated address. + :param str|None payment_id: the payment id related to this integrated address. + :param str|None integrated_address: the integrated address. + """ ... diff --git a/src/monero/monero_key_image.pyi b/src/monero/monero_key_image.pyi index 9c2d881..06af6fe 100644 --- a/src/monero/monero_key_image.pyi +++ b/src/monero/monero_key_image.pyi @@ -29,8 +29,13 @@ class MoneroKeyImage(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero key image.""" + def __init__(self, *, hex: str | None = None, signature: str | None = None) -> None: + """ + Initialize a Monero key image. The attributes that are not given keep the values of an empty one. + + :param str|None hex: the key image in hexadecimal format. + :param str|None signature: the key image signature. `None` if not known. + """ ... def copy(self) -> MoneroKeyImage: diff --git a/src/monero/monero_key_image_export_result.pyi b/src/monero/monero_key_image_export_result.pyi index 3e18eed..a1eb121 100644 --- a/src/monero/monero_key_image_export_result.pyi +++ b/src/monero/monero_key_image_export_result.pyi @@ -27,6 +27,11 @@ class MoneroKeyImageExportResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero key image export result.""" + def __init__(self, *, offset: int | None = None, key_images: list[MoneroKeyImage] | None = None) -> None: + """ + Initialize a Monero key image export result. The attributes that are not given keep the values of an empty one. + + :param int|None offset: index of the first exported key image within the wallet's list of owned outputs. On an incremental export (`all=False`) the wallet skips outputs whose key images were already exported, so this offset tells the importing wallet where in its own output list the returned key images begin. Pass it back as the `offset` argument of `MoneroWallet.import_key_images()`. + :param list[MoneroKeyImage]|None key_images: the exported key images, one per owned output starting at `offset`. + """ ... diff --git a/src/monero/monero_key_image_import_result.pyi b/src/monero/monero_key_image_import_result.pyi index 498da10..63ca540 100644 --- a/src/monero/monero_key_image_import_result.pyi +++ b/src/monero/monero_key_image_import_result.pyi @@ -21,6 +21,12 @@ class MoneroKeyImageImportResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero key image import result.""" + def __init__(self, *, height: int | None = None, spent_amount: int | None = None, unspent_amount: int | None = None) -> None: + """ + Initialize a Monero key image import result. The attributes that are not given keep the values of an empty one. + + :param int|None height: height at which the last key image was imported. Can be `0` if blockchain height is not known. + :param int|None spent_amount: amount (in atomic-units) spent from those key images. + :param int|None unspent_amount: amount (in atomic-units) still available from those key images. + """ ... diff --git a/src/monero/monero_message_signature_result.pyi b/src/monero/monero_message_signature_result.pyi index a4028bf..e1a1c3f 100644 --- a/src/monero/monero_message_signature_result.pyi +++ b/src/monero/monero_message_signature_result.pyi @@ -24,6 +24,19 @@ class MoneroMessageSignatureResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero message signature result.""" + def __init__( + self, *, + is_good: bool | None = None, + version: int | None = None, + is_old: bool | None = None, + signature_type: MoneroMessageSignatureType | None = None + ) -> None: + """ + Initialize a Monero message signature result. The attributes that are not given keep the values of an empty one. + + :param bool|None is_good: indicates if the message verification was successful. + :param int|None version: message signature version. + :param bool|None is_old: indicates if the message verification used old monero software. + :param MoneroMessageSignatureType|None signature_type: signature type used in the message verification. + """ ... diff --git a/src/monero/monero_miner_data.pyi b/src/monero/monero_miner_data.pyi index f70ff23..9e25b46 100644 --- a/src/monero/monero_miner_data.pyi +++ b/src/monero/monero_miner_data.pyi @@ -35,6 +35,31 @@ class MoneroMinerData(MoneroRpcPaymentInfo): """ ... - def __init__(self) -> None: - """Initialize a Monero miner data.""" + def __init__( + self, *, + credits: int | None = None, + top_block_hash: str | None = None, + major_version: int | None = None, + height: int | None = None, + prev_hash: str | None = None, + seed_hash: str | None = None, + difficulty: str | None = None, + median_weight: int | None = None, + already_generated_coins: int | None = None, + tx_pool_backlog: list[MoneroTx] | None = None + ) -> None: + """ + Initialize a Monero miner data. The attributes that are not given keep the values of an empty one. + + :param int|None credits: if payment for RPC is enabled, the number of credits available to the requesting client. Otherwise, 0. + :param str|None top_block_hash: if payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`. + :param int|None major_version: the next block's major version. + :param int|None height: the height of the next block to mine. + :param str|None prev_hash: the hash of the previous (current top) block. + :param str|None seed_hash: the seed hash used to select the RandomX dataset/cache. + :param str|None difficulty: the next block's difficulty as a hex string, e.g. "0x1f4". + :param int|None median_weight: the median block weight used for penalty calculations. + :param int|None already_generated_coins: the total coins emitted so far, in atomic-units. + :param list[MoneroTx]|None tx_pool_backlog: the transactions currently in the pool eligible for the next block. + """ ... diff --git a/src/monero/monero_miner_tx_sum.pyi b/src/monero/monero_miner_tx_sum.pyi index de2fcaa..a6ee85a 100644 --- a/src/monero/monero_miner_tx_sum.pyi +++ b/src/monero/monero_miner_tx_sum.pyi @@ -23,6 +23,19 @@ class MoneroMinerTxSum(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero miner transaction sum.""" + def __init__( + self, *, + emission_sum_low: int | None = None, + emission_sum_high: int | None = None, + fee_sum_low: int | None = None, + fee_sum_high: int | None = None + ) -> None: + """ + Initialize a Monero miner transaction sum. The attributes that are not given keep the values of an empty one. + + :param int|None emission_sum_low: the new coins emitted in atomic-units. (Least significant 64 bits for 128 bit integer) + :param int|None emission_sum_high: the new coins emitted in atomic-units. (Most significant 64 bits for 128 bit integer) + :param int|None fee_sum_low: the sum of fees in atomic-units. (Least significant 64 bits for 128 bit integer) + :param int|None fee_sum_high: the sum of fees in atomic-units. (Most significant 64 bits for 128 bit integer) + """ ... diff --git a/src/monero/monero_mining_status.pyi b/src/monero/monero_mining_status.pyi index a295f2c..0575c72 100644 --- a/src/monero/monero_mining_status.pyi +++ b/src/monero/monero_mining_status.pyi @@ -25,6 +25,21 @@ class MoneroMiningStatus(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero daemon mining status.""" + def __init__( + self, *, + is_active: bool | None = None, + is_background: bool | None = None, + address: str | None = None, + speed: int | None = None, + num_threads: int | None = None + ) -> None: + """ + Initialize a Monero mining status. The attributes that are not given keep the values of an empty one. + + :param bool|None is_active: indicates if mining is enabled. + :param bool|None is_background: indicates if mining is running in background. + :param str|None address: account address daemon is mining to. `None` if not mining. + :param int|None speed: mining power in hashes per seconds. + :param int|None num_threads: number of running mining threads. + """ ... diff --git a/src/monero/monero_multisig_info.pyi b/src/monero/monero_multisig_info.pyi index 012a269..cb39e51 100644 --- a/src/monero/monero_multisig_info.pyi +++ b/src/monero/monero_multisig_info.pyi @@ -23,6 +23,19 @@ class MoneroMultisigInfo(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero multisignature info.""" + def __init__( + self, *, + is_multisig: bool | None = None, + is_ready: bool | None = None, + threshold: int | None = None, + num_participants: int | None = None + ) -> None: + """ + Initialize a Monero multisig info. The attributes that are not given keep the values of an empty one. + + :param bool|None is_multisig: indicates if the wallet is multisignature (`True`), or not (`False`). + :param bool|None is_ready: indicates if the wallet is ready to support multisignature operations (`True`) or not (`False`). + :param int|None threshold: number of participants need in order to sign a transaction. + :param int|None num_participants: number of participants of the multisignature wallet. + """ ... diff --git a/src/monero/monero_multisig_init_result.pyi b/src/monero/monero_multisig_init_result.pyi index 7f7febf..73536d7 100644 --- a/src/monero/monero_multisig_init_result.pyi +++ b/src/monero/monero_multisig_init_result.pyi @@ -23,6 +23,11 @@ class MoneroMultisigInitResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero multisignature initializing result.""" + def __init__(self, *, address: str | None = None, multisig_hex: str | None = None) -> None: + """ + Initialize a Monero multisig init result. The attributes that are not given keep the values of an empty one. + + :param str|None address: the multisignature wallet address. + :param str|None multisig_hex: the multisignature hex to share with other participants. + """ ... diff --git a/src/monero/monero_multisig_sign_result.pyi b/src/monero/monero_multisig_sign_result.pyi index 0868c31..3850f49 100644 --- a/src/monero/monero_multisig_sign_result.pyi +++ b/src/monero/monero_multisig_sign_result.pyi @@ -19,6 +19,11 @@ class MoneroMultisigSignResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero multisignature signature result.""" + def __init__(self, *, signed_multisig_tx_hex: str | None = None, tx_hashes: list[str] | None = None) -> None: + """ + Initialize a Monero multisig sign result. The attributes that are not given keep the values of an empty one. + + :param str|None signed_multisig_tx_hex: multisig transaction in hex format. + :param list[str]|None tx_hashes: list of transaction hash. + """ ... diff --git a/src/monero/monero_outgoing_transfer.pyi b/src/monero/monero_outgoing_transfer.pyi index 657bbaf..cb44a68 100644 --- a/src/monero/monero_outgoing_transfer.pyi +++ b/src/monero/monero_outgoing_transfer.pyi @@ -24,8 +24,23 @@ class MoneroOutgoingTransfer(MoneroTransfer): """ ... - def __init__(self) -> None: - """Initialize a Monero outgoing transfer.""" + def __init__( + self, *, + account_index: int | None = None, + amount: int | None = None, + subaddress_indices: list[int] | None = None, + addresses: list[str] | None = None, + destinations: list[MoneroDestination] | None = None + ) -> None: + """ + Initialize a Monero outgoing transfer. The attributes that are not given keep the values of an empty one. + + :param int|None account_index: index of the account related to this transfer. + :param int|None amount: transfer amount in atomic-units. + :param list[int]|None subaddress_indices: subaddresses from which the transfer originated. + :param list[str]|None addresses: addresses from which the transfer originated. + :param list[MoneroDestination]|None destinations: outgoing transfer destinations. + """ ... @typing.override diff --git a/src/monero/monero_output.pyi b/src/monero/monero_output.pyi index 381393a..45a2542 100644 --- a/src/monero/monero_output.pyi +++ b/src/monero/monero_output.pyi @@ -36,8 +36,17 @@ class MoneroOutput(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero output.""" + def __init__(self, *, key_image: MoneroKeyImage | None = None, amount: int | None = None, index: int | None = None, stealth_public_key: str | None = None, mask: str | None = None, ring_output_indices: list[int] | None = None) -> None: + """ + Initialize a Monero output. The attributes that are not given keep the values of an empty one. + + :param MoneroKeyImage|None key_image: the key image of the output. + :param int|None amount: output amount in atomic-units. + :param int|None index: output index. + :param str|None stealth_public_key: the public key of the output. + :param str|None mask: the output commitment mask (pseudo-out blinding factor) as a hex string. + :param list[int]|None ring_output_indices: indices of ring outputs. + """ ... def copy(self) -> MoneroOutput: diff --git a/src/monero/monero_output_distribution_entry.pyi b/src/monero/monero_output_distribution_entry.pyi index 2329976..d2fc23f 100644 --- a/src/monero/monero_output_distribution_entry.pyi +++ b/src/monero/monero_output_distribution_entry.pyi @@ -30,6 +30,13 @@ class MoneroOutputDistributionEntry(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero output distribution entry.""" + def __init__(self, *, amount: int | None = None, base: int | None = None, distribution: list[int] | None = None, start_height: int | None = None) -> None: + """ + Initialize a Monero output distribution entry. The attributes that are not given keep the values of an empty one. + + :param int|None amount: output amount in atomic-units. + :param int|None base: the total number of outputs of `amount` in the chain before, not including, the block at `start_height`. + :param list[int]|None distribution: per-block counts of outputs of `amount` starting at `start_height`: element `i` is the number created in block `start_height + i`, or the running total up to that block when the distribution was requested as cumulative. Wallets use this to weight decoy selection by output age. + :param int|None start_height: not necessarily equal to the `start_height` parameter, especially for `amount = 0` where it will be no less than the height of the v4 hard fork. + """ ... diff --git a/src/monero/monero_output_histogram_entry.pyi b/src/monero/monero_output_histogram_entry.pyi index a08a3db..11d1e32 100644 --- a/src/monero/monero_output_histogram_entry.pyi +++ b/src/monero/monero_output_histogram_entry.pyi @@ -23,6 +23,19 @@ class MoneroOutputHistogramEntry(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero output histogram entry.""" + def __init__( + self, *, + amount: int | None = None, + num_instances: int | None = None, + unlocked_instances: int | None = None, + recent_instances: int | None = None + ) -> None: + """ + Initialize a Monero output histogram entry. The attributes that are not given keep the values of an empty one. + + :param int|None amount: output amount in atomic-units. + :param int|None num_instances: number of outputs. + :param int|None unlocked_instances: number of unlocked outputs. + :param int|None recent_instances: number of recent outputs. + """ ... diff --git a/src/monero/monero_output_query.pyi b/src/monero/monero_output_query.pyi index 4410f09..7573da9 100644 --- a/src/monero/monero_output_query.pyi +++ b/src/monero/monero_output_query.pyi @@ -2,6 +2,7 @@ import typing from .monero_output_wallet import MoneroOutputWallet from .monero_tx_query import MoneroTxQuery +from .monero_key_image import MoneroKeyImage class MoneroOutputQuery(MoneroOutputWallet): @@ -45,8 +46,39 @@ class MoneroOutputQuery(MoneroOutputWallet): """ ... - def __init__(self) -> None: - """Initialize a Monero output query.""" + def __init__( + self, *, + key_image: MoneroKeyImage | None = None, + amount: int | None = None, + index: int | None = None, + stealth_public_key: str | None = None, + mask: str | None = None, + ring_output_indices: list[int] | None = None, + account_index: int | None = None, + subaddress_index: int | None = None, + is_spent: bool | None = None, + is_frozen: bool | None = None, + subaddress_indices: list[int] | None = None, + min_amount: int | None = None, + max_amount: int | None = None + ) -> None: + """ + Initialize a Monero output query. The attributes that are not given keep the values of an empty one. + + :param MoneroKeyImage|None key_image: the key image of the output. + :param int|None amount: output amount in atomic-units. + :param int|None index: output index. + :param str|None stealth_public_key: the public key of the output. + :param str|None mask: the output commitment mask (pseudo-out blinding factor) as a hex string. + :param list[int]|None ring_output_indices: indices of ring outputs. + :param int|None account_index: the index of the account that owns this output. + :param int|None subaddress_index: the index of the subaddress that owns this output. + :param bool|None is_spent: indicates if the output is spent (`True`) or not (`False`). + :param bool|None is_frozen: indicates if the output is frozen (`True`) or not (`False`). + :param list[int]|None subaddress_indices: subaddress indices to select (empty for all). + :param int|None min_amount: filter outputs below this amount. + :param int|None max_amount: filter outputs above this amount. + """ ... @typing.override diff --git a/src/monero/monero_output_wallet.pyi b/src/monero/monero_output_wallet.pyi index 2fdf929..7d61e14 100644 --- a/src/monero/monero_output_wallet.pyi +++ b/src/monero/monero_output_wallet.pyi @@ -1,6 +1,7 @@ import typing from .monero_output import MoneroOutput +from .monero_key_image import MoneroKeyImage class MoneroOutputWallet(MoneroOutput): @@ -26,8 +27,33 @@ class MoneroOutputWallet(MoneroOutput): """ ... - def __init__(self) -> None: - """Initialize a Monero wallet output.""" + def __init__( + self, *, + key_image: MoneroKeyImage | None = None, + amount: int | None = None, + index: int | None = None, + stealth_public_key: str | None = None, + mask: str | None = None, + ring_output_indices: list[int] | None = None, + account_index: int | None = None, + subaddress_index: int | None = None, + is_spent: bool | None = None, + is_frozen: bool | None = None + ) -> None: + """ + Initialize a Monero output wallet. The attributes that are not given keep the values of an empty one. + + :param MoneroKeyImage|None key_image: the key image of the output. + :param int|None amount: output amount in atomic-units. + :param int|None index: output index. + :param str|None stealth_public_key: the public key of the output. + :param str|None mask: the output commitment mask (pseudo-out blinding factor) as a hex string. + :param list[int]|None ring_output_indices: indices of ring outputs. + :param int|None account_index: the index of the account that owns this output. + :param int|None subaddress_index: the index of the subaddress that owns this output. + :param bool|None is_spent: indicates if the output is spent (`True`) or not (`False`). + :param bool|None is_frozen: indicates if the output is frozen (`True`) or not (`False`). + """ ... @typing.override diff --git a/src/monero/monero_peer.pyi b/src/monero/monero_peer.pyi index bf213ea..184e980 100644 --- a/src/monero/monero_peer.pyi +++ b/src/monero/monero_peer.pyi @@ -68,6 +68,63 @@ class MoneroPeer(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a new Monero peer.""" + def __init__( + self, *, + id: str | None = None, + address: str | None = None, + host: str | None = None, + port: int | None = None, + is_online: bool | None = None, + last_seen_timestamp: int | None = None, + pruning_seed: int | None = None, + rpc_port: int | None = None, + rpc_credits_per_hash: int | None = None, + hash: str | None = None, + avg_download: int | None = None, + avg_upload: int | None = None, + current_download: int | None = None, + current_upload: int | None = None, + height: int | None = None, + is_incoming: bool | None = None, + live_time: int | None = None, + is_local_ip: bool | None = None, + is_local_host: bool | None = None, + num_receives: int | None = None, + num_sends: int | None = None, + receive_idle_time: int | None = None, + send_idle_time: int | None = None, + state: str | None = None, + num_support_flags: int | None = None, + connection_type: MoneroConnectionType | None = None + ) -> None: + """ + Initialize a Monero peer. The attributes that are not given keep the values of an empty one. + + :param str|None id: the node's ID on the network. + :param str|None address: the peer's address, actually IPv4 & port. + :param str|None host: the peer host. + :param int|None port: the port that the node is using to connect to the network. + :param bool|None is_online: indicates if the peer is online. + :param int|None last_seen_timestamp: last activity timestamp of this peer. + :param int|None pruning_seed: block height at which pruning began. + :param int|None rpc_port: peer RPC port. + :param int|None rpc_credits_per_hash: credits for every hash calculated by client. + :param str|None hash: peer hash. + :param int|None avg_download: average bytes of data downloaded by node. + :param int|None avg_upload: average bytes of data uploaded by node. + :param int|None current_download: current bytes downloaded by node. + :param int|None current_upload: current bytes uploaded by node. + :param int|None height: the peer blockchain height. + :param bool|None is_incoming: indicates if peer is pulling blocks from node. + :param int|None live_time: length of time the peer has been online. + :param bool|None is_local_ip: indicates if peer has a local ip address. + :param bool|None is_local_host: indicates if peer is localhost. + :param int|None num_receives: total number of messages received from this peer. + :param int|None num_sends: total number of messages sent to this peer. + :param int|None receive_idle_time: seconds since last data was received from this peer. + :param int|None send_idle_time: seconds since the last data sent to this peer. + :param str|None state: peer state. + :param int|None num_support_flags: support flags number. + :param MoneroConnectionType|None connection_type: type of peer connection. + """ ... diff --git a/src/monero/monero_prune_result.pyi b/src/monero/monero_prune_result.pyi index 549e075..2bad9b1 100644 --- a/src/monero/monero_prune_result.pyi +++ b/src/monero/monero_prune_result.pyi @@ -19,6 +19,11 @@ class MoneroPruneResult(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero prune result.""" + def __init__(self, *, is_pruned: bool | None = None, pruning_seed: int | None = None) -> None: + """ + Initialize a Monero prune result. The attributes that are not given keep the values of an empty one. + + :param bool|None is_pruned: indicates if blockchain is pruned. + :param int|None pruning_seed: block height at which pruning began. + """ ... diff --git a/src/monero/monero_rpc_payment_info.pyi b/src/monero/monero_rpc_payment_info.pyi index 6cc964e..82ab709 100644 --- a/src/monero/monero_rpc_payment_info.pyi +++ b/src/monero/monero_rpc_payment_info.pyi @@ -10,8 +10,13 @@ class MoneroRpcPaymentInfo(SerializableStruct): top_block_hash: str | None """If payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`.""" - def __init__(self) -> None: - """Initialize a Monero RPC payment information.""" + def __init__(self, *, credits: int | None = None, top_block_hash: str | None = None) -> None: + """ + Initialize a Monero RPC payment info. The attributes that are not given keep the values of an empty one. + + :param int|None credits: if payment for RPC is enabled, the number of credits available to the requesting client. Otherwise, 0. + :param str|None top_block_hash: if payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`. + """ ... @staticmethod diff --git a/src/monero/monero_subaddress.pyi b/src/monero/monero_subaddress.pyi index a666e16..7ec837b 100644 --- a/src/monero/monero_subaddress.pyi +++ b/src/monero/monero_subaddress.pyi @@ -33,6 +33,18 @@ class MoneroSubaddress(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero subaddress.""" + def __init__(self, *, account_index: int | None = None, index: int | None = None, address: str | None = None, label: str | None = None, balance: int | None = None, unlocked_balance: int | None = None, num_unspent_outputs: int | None = None, is_used: bool | None = None, num_blocks_to_unlock: int | None = None) -> None: + """ + Initialize a Monero subaddress. The attributes that are not given keep the values of an empty one. + + :param int|None account_index: the subaddress account index. + :param int|None index: the subaddress index. + :param str|None address: public address. + :param str|None label: the subaddress label. + :param int|None balance: the subaddress balance. + :param int|None unlocked_balance: the subaddress unlocked balance. + :param int|None num_unspent_outputs: the number of unspent outputs in this subaddress. + :param bool|None is_used: indicates if subaddress has been used in receiving funds. + :param int|None num_blocks_to_unlock: number of blocks to unlock received outputs. + """ ... diff --git a/src/monero/monero_submit_tx_result.pyi b/src/monero/monero_submit_tx_result.pyi index 6f08c81..471c021 100644 --- a/src/monero/monero_submit_tx_result.pyi +++ b/src/monero/monero_submit_tx_result.pyi @@ -46,6 +46,43 @@ class MoneroSubmitTxResult(MoneroRpcPaymentInfo): """ ... - def __init__(self) -> None: - """Initialize a new submit transaction result.""" + def __init__( + self, *, + credits: int | None = None, + top_block_hash: str | None = None, + is_good: bool | None = None, + is_relayed: bool | None = None, + is_double_spend: bool | None = None, + is_fee_too_low: bool | None = None, + is_mixin_too_low: bool | None = None, + has_invalid_input: bool | None = None, + has_invalid_output: bool | None = None, + has_too_few_outputs: bool | None = None, + is_overspend: bool | None = None, + is_too_big: bool | None = None, + sanity_check_failed: bool | None = None, + reason: str | None = None, + is_tx_extra_too_big: bool | None = None, + is_nonzero_unlock_time: bool | None = None + ) -> None: + """ + Initialize a Monero submit transaction result. The attributes that are not given keep the values of an empty one. + + :param int|None credits: if payment for RPC is enabled, the number of credits available to the requesting client. Otherwise, 0. + :param str|None top_block_hash: if payment for RPC is enabled, the hash of the highest block in the chain. Otherwise, `None`. + :param bool|None is_good: indicates if the submission of the transaction was successful. + :param bool|None is_relayed: indicates if the transaction has been relayed. + :param bool|None is_double_spend: indicates if the transaction is double spend. + :param bool|None is_fee_too_low: indicates if the transaction fee is too low. + :param bool|None is_mixin_too_low: indicates if the transaction mixin count is too low. + :param bool|None has_invalid_input: indicates if the transaction has an invalid input. + :param bool|None has_invalid_output: indicates if the transaction has an invalid output. + :param bool|None has_too_few_outputs: indicates if the transaction has too few outputs. + :param bool|None is_overspend: indicates if the transaction uses more money than available + :param bool|None is_too_big: indicates if the transaction size is too big. + :param bool|None sanity_check_failed: indicates if the transaction sanity check has failed. + :param str|None reason: additional information. Currently empty or `Not relayed` if transaction was accepted but not relayed. + :param bool|None is_tx_extra_too_big: indicates if the transaction extra size is too big. + :param bool|None is_nonzero_unlock_time: indicates if the transaction was rejected for carrying a non-zero per-transaction unlock time, which the daemon no longer accepts into the pool. + """ ... diff --git a/src/monero/monero_transfer.pyi b/src/monero/monero_transfer.pyi index 3642660..bf411c7 100644 --- a/src/monero/monero_transfer.pyi +++ b/src/monero/monero_transfer.pyi @@ -12,8 +12,13 @@ class MoneroTransfer(SerializableStruct): tx: MoneroTxWallet | None """Related wallet transaction.""" - def __init__(self) -> None: - """Initialize a Monero transfer.""" + def __init__(self, *, account_index: int | None = None, amount: int | None = None) -> None: + """ + Initialize a Monero transfer. The attributes that are not given keep the values of an empty one. + + :param int|None account_index: index of the account related to this transfer. + :param int|None amount: transfer amount in atomic-units. + """ ... def copy(self) -> MoneroTransfer: diff --git a/src/monero/monero_transfer_query.pyi b/src/monero/monero_transfer_query.pyi index a5b5fa6..6e984a4 100644 --- a/src/monero/monero_transfer_query.pyi +++ b/src/monero/monero_transfer_query.pyi @@ -51,8 +51,35 @@ class MoneroTransferQuery(MoneroTransfer): """ ... - def __init__(self) -> None: - """Initialize a Monero transfer query.""" + def __init__( + self, *, + account_index: int | None = None, + amount: int | None = None, + incoming: bool | None = None, + address: str | None = None, + addresses: list[str] | None = None, + subaddress_index: int | None = None, + subaddress_indices: list[int] | None = None, + destinations: list[MoneroDestination] | None = None, + has_destinations: bool | None = None, + outgoing: bool | None = None, + tx_query: MoneroTxQuery | None = None + ) -> None: + """ + Initialize a Monero transfer query. The attributes that are not given keep the values of an empty one. + + :param int|None account_index: index of the account related to this transfer. + :param int|None amount: transfer amount in atomic-units. + :param bool|None incoming: filter incoming or outgoing transfers. `None` for all. + :param str|None address: select transfers involving particular address. Empty for all. + :param list[str]|None addresses: select transfers involving particular addresses. Empty for all. + :param int|None subaddress_index: filter by subaddress index. `None` for all. + :param list[int]|None subaddress_indices: select transfers involving particular subaddresses. Empty for all. + :param list[MoneroDestination]|None destinations: select transfers involving particular destinations. Empty for all. + :param bool|None has_destinations: filter transfers with or without destinations. `None` for all. + :param bool|None outgoing: filter incoming or outgoing transfers. `None` for all. + :param MoneroTxQuery|None tx_query: related transaction query. + """ ... @typing.override diff --git a/src/monero/monero_tx.pyi b/src/monero/monero_tx.pyi index 5a57840..cea9717 100644 --- a/src/monero/monero_tx.pyi +++ b/src/monero/monero_tx.pyi @@ -97,8 +97,89 @@ class MoneroTx(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a new Monero transaction.""" + def __init__( + self, *, + hash: str | None = None, + version: int | None = None, + is_miner_tx: bool | None = None, + payment_id: str | None = None, + fee: int | None = None, + ring_size: int | None = None, + relay: bool | None = None, + is_relayed: bool | None = None, + is_confirmed: bool | None = None, + in_tx_pool: bool | None = None, + is_locked: bool | None = None, + num_confirmations: int | None = None, + unlock_time: int | None = None, + last_relayed_timestamp: int | None = None, + received_timestamp: int | None = None, + is_double_spend_seen: bool | None = None, + key: str | None = None, + full_hex: str | None = None, + pruned_hex: str | None = None, + prunable_hex: str | None = None, + prunable_hash: str | None = None, + size: int | None = None, + weight: int | None = None, + inputs: list[MoneroOutput] | None = None, + outputs: list[MoneroOutput] | None = None, + output_indices: list[int] | None = None, + metadata: str | None = None, + common_tx_sets: str | None = None, + extra: list[int] | None = None, + rct_signatures: str | None = None, + rct_sig_prunable: str | None = None, + is_kept_by_block: bool | None = None, + is_failed: bool | None = None, + last_failed_height: int | None = None, + last_failed_hash: str | None = None, + max_used_block_height: int | None = None, + max_used_block_hash: str | None = None, + signatures: list[str] | None = None + ) -> None: + """ + Initialize a Monero transaction. The attributes that are not given keep the values of an empty one. + + :param str|None hash: the transaction hash. + :param int|None version: transaction version. + :param bool|None is_miner_tx: states if the transaction is a coinbase-transaction (`True`) or not (`False`). + :param str|None payment_id: payment ID for this transaction. + :param int|None fee: the amount of the mining fee included in the transaction, in atomic-units. + :param int|None ring_size: the ring size of this transaction. + :param bool|None relay: states if this transaction should be relayed (`True`) or not (`False`). + :param bool|None is_relayed: states if the transaction was relayed (`True`) or not (`False`). + :param bool|None is_confirmed: states if the transaction included in a block (`True`) or is in pool (`False`). + :param bool|None in_tx_pool: states if the transaction is in pool (`True`) or included in a block (`False`). + :param bool|None is_locked: indicates if the transaction is locked. + :param int|None num_confirmations: number of network confirmations. + :param int|None unlock_time: if not `0`, this tells when the transaction outputs are spendable. + :param int|None last_relayed_timestamp: last unix time at which the transaction has been relayed. + :param int|None received_timestamp: unix time at which the transaction has been received. + :param bool|None is_double_spend_seen: states if the transaction is a double-spend (`True`) or not (`False`). + :param str|None key: the transaction key. + :param str|None full_hex: full transaction information as a hex string. + :param str|None pruned_hex: pruned block encoded as hex string. + :param str|None prunable_hex: prunable block encoded as a hex string. + :param str|None prunable_hash: keccak-256 hash of the prunable portion of the block. + :param int|None size: backward compatibility, same as `weight`, use that instead. + :param int|None weight: the weight of this transaction in bytes. + :param list[MoneroOutput]|None inputs: list of inputs into transaction. + :param list[MoneroOutput]|None outputs: transaction outputs. + :param list[int]|None output_indices: global (on-chain) output index of each of this transaction's outputs, in order; the indices by which the outputs are referenced as ring members. + :param str|None metadata: transaction metadata. + :param str|None common_tx_sets: A hexadecimal string representing a set of unsigned transactions, or a set of signing keys used in a multisig transaction. + :param list[int]|None extra: usually called the `payment ID` but can be used to include any random 32 bytes. + :param str|None rct_signatures: signatures used in ring signature to hide the true origin of the transaction. + :param str|None rct_sig_prunable: prunable ring signature. + :param bool|None is_kept_by_block: states if the transaction was included in a block at least once (`True`) or not (`False`). + :param bool|None is_failed: indicates if the transaction validation has previously failed. + :param int|None last_failed_height: if the transaction validation has previously failed, this tells at what height that occurred. + :param str|None last_failed_hash: if the transaction validation has previously failed, this tells the previous transaction hash. + :param int|None max_used_block_height: tells the height of the most recent block with an output used in this transaction. + :param str|None max_used_block_hash: tells the hash of the most recent block with an output used in this transaction. + :param list[str]|None signatures: list of signatures used in ring signature to hide the true origin of the transaction. + """ ... def copy(self) -> MoneroTx: diff --git a/src/monero/monero_tx_config.pyi b/src/monero/monero_tx_config.pyi index 777b16c..8ca9258 100644 --- a/src/monero/monero_tx_config.pyi +++ b/src/monero/monero_tx_config.pyi @@ -1,5 +1,3 @@ -import typing - from .serializable_struct import SerializableStruct from .monero_destination import MoneroDestination from .monero_tx_priority import MoneroTxPriority @@ -53,17 +51,28 @@ class MoneroTxConfig(SerializableStruct): """ ... - @typing.overload - def __init__(self) -> None: - """Initialize a new tx config.""" - ... - - @typing.overload - def __init__(self, config: MoneroTxConfig) -> None: + def __init__(self, config: MoneroTxConfig | None = None, *, address: str | None = None, amount: int | None = None, destinations: list[MoneroDestination] | None = None, subtract_fee_from: list[int] | None = None, payment_id: str | None = None, priority: MoneroTxPriority | None = None, ring_size: int | None = None, fee: int | None = None, account_index: int | None = None, subaddress_indices: list[int] | None = None, can_split: bool | None = None, relay: bool | None = None, note: str | None = None, recipient_name: str | None = None, below_amount: int | None = None, sweep_each_subaddress: bool | None = None, key_image: str | None = None) -> None: """ - Initialize a new tx config. + Initialize a transaction configuration, empty or as a copy of another one. The attributes that are given replace those values. - :param MoneroTxConfig config: tx config to copy. + :param MoneroTxConfig|None config: the configuration to copy. + :param str|None address: transaction address destination. + :param int|None amount: transaction amount. + :param list[MoneroDestination]|None destinations: transaction outgoing destinations. + :param list[int]|None subtract_fee_from: subtract fee from outputs. + :param str|None payment_id: transaction payment id. + :param MoneroTxPriority|None priority: transaction priority. + :param int|None ring_size: transaction ring size + :param int|None fee: transaction fee. + :param int|None account_index: account index to send funds from. + :param list[int]|None subaddress_indices: account subaddresses indices to send funds from. + :param bool|None can_split: indicates if transaction can be split in multiple transactions. + :param bool|None relay: indicates if transaction should be relayed (`True`) or not (`False`). + :param str|None note: transaction note. + :param str|None recipient_name: recipient name. + :param int|None below_amount: ignore output amount below. + :param bool|None sweep_each_subaddress: sweep each wallet subaddress. + :param str|None key_image: use a particular key image as input for transaction. """ ... diff --git a/src/monero/monero_tx_pool_stats.pyi b/src/monero/monero_tx_pool_stats.pyi index a65848d..8f3de8b 100644 --- a/src/monero/monero_tx_pool_stats.pyi +++ b/src/monero/monero_tx_pool_stats.pyi @@ -41,6 +41,37 @@ class MoneroTxPoolStats(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero transaction pool statistics.""" + def __init__( + self, *, + num_txs: int | None = None, + num_not_relayed: int | None = None, + num_failing: int | None = None, + num_double_spends: int | None = None, + num10m: int | None = None, + fee_total: int | None = None, + bytes_max: int | None = None, + bytes_med: int | None = None, + bytes_min: int | None = None, + bytes_total: int | None = None, + histo98pc: int | None = None, + oldest_timestamp: int | None = None, + histo: dict[int, int] | None = None + ) -> None: + """ + Initialize a Monero transaction pool stats. The attributes that are not given keep the values of an empty one. + + :param int|None num_txs: total number of transactions. + :param int|None num_not_relayed: number of non-relayed transactions. + :param int|None num_failing: number of failing transactions. + :param int|None num_double_spends: number of double spend transactions. + :param int|None num10m: number of transactions in pool for more than 10 minutes. + :param int|None fee_total: the sum of the fees for all transactions currently in the transaction pool atomic-units. + :param int|None bytes_max: max transaction size in pool. + :param int|None bytes_med: median transaction size in pool. + :param int|None bytes_min: min transaction size in pool. + :param int|None bytes_total: total size of all transactions in pool. + :param int|None histo98pc: the time 98% of txes are `younger` than. + :param int|None oldest_timestamp: unix time of the oldest transaction in the pool. + :param dict[int,int]|None histo: txs histogram (key for bytes, value for txs). + """ ... diff --git a/src/monero/monero_tx_query.pyi b/src/monero/monero_tx_query.pyi index 785a5fe..e08eed0 100644 --- a/src/monero/monero_tx_query.pyi +++ b/src/monero/monero_tx_query.pyi @@ -3,6 +3,9 @@ import typing from .monero_tx_wallet import MoneroTxWallet from .monero_output_query import MoneroOutputQuery from .monero_transfer_query import MoneroTransferQuery +from .monero_incoming_transfer import MoneroIncomingTransfer +from .monero_outgoing_transfer import MoneroOutgoingTransfer +from .monero_output import MoneroOutput class MoneroTxQuery(MoneroTxWallet): @@ -71,8 +74,131 @@ class MoneroTxQuery(MoneroTxWallet): """ ... - def __init__(self) -> None: - """Initialize a new Monero transaction query.""" + def __init__( + self, *, + hash: str | None = None, + version: int | None = None, + is_miner_tx: bool | None = None, + payment_id: str | None = None, + fee: int | None = None, + ring_size: int | None = None, + relay: bool | None = None, + is_relayed: bool | None = None, + is_confirmed: bool | None = None, + in_tx_pool: bool | None = None, + is_locked: bool | None = None, + num_confirmations: int | None = None, + unlock_time: int | None = None, + last_relayed_timestamp: int | None = None, + received_timestamp: int | None = None, + is_double_spend_seen: bool | None = None, + key: str | None = None, + full_hex: str | None = None, + pruned_hex: str | None = None, + prunable_hex: str | None = None, + prunable_hash: str | None = None, + size: int | None = None, + weight: int | None = None, + inputs: list[MoneroOutput] | None = None, + outputs: list[MoneroOutput] | None = None, + output_indices: list[int] | None = None, + metadata: str | None = None, + common_tx_sets: str | None = None, + extra: list[int] | None = None, + rct_signatures: str | None = None, + rct_sig_prunable: str | None = None, + is_kept_by_block: bool | None = None, + is_failed: bool | None = None, + last_failed_height: int | None = None, + last_failed_hash: str | None = None, + max_used_block_height: int | None = None, + max_used_block_hash: str | None = None, + signatures: list[str] | None = None, + is_incoming: bool | None = None, + is_outgoing: bool | None = None, + incoming_transfers: list[MoneroIncomingTransfer] | None = None, + outgoing_transfer: MoneroOutgoingTransfer | None = None, + note: str | None = None, + input_sum: int | None = None, + output_sum: int | None = None, + change_address: str | None = None, + change_amount: int | None = None, + num_dummy_outputs: int | None = None, + extra_hex: str | None = None, + hashes: list[str] | None = None, + has_payment_id: bool | None = None, + payment_ids: list[str] | None = None, + height: int | None = None, + min_height: int | None = None, + max_height: int | None = None, + include_outputs: bool | None = None, + transfer_query: MoneroTransferQuery | None = None, + input_query: MoneroOutputQuery | None = None, + output_query: MoneroOutputQuery | None = None + ) -> None: + """ + Initialize a Monero transaction query. The attributes that are not given keep the values of an empty one. + + :param str|None hash: the transaction hash. + :param int|None version: transaction version. + :param bool|None is_miner_tx: states if the transaction is a coinbase-transaction (`True`) or not (`False`). + :param str|None payment_id: payment ID for this transaction. + :param int|None fee: the amount of the mining fee included in the transaction, in atomic-units. + :param int|None ring_size: the ring size of this transaction. + :param bool|None relay: states if this transaction should be relayed (`True`) or not (`False`). + :param bool|None is_relayed: states if the transaction was relayed (`True`) or not (`False`). + :param bool|None is_confirmed: states if the transaction included in a block (`True`) or is in pool (`False`). + :param bool|None in_tx_pool: states if the transaction is in pool (`True`) or included in a block (`False`). + :param bool|None is_locked: indicates if the transaction is locked. + :param int|None num_confirmations: number of network confirmations. + :param int|None unlock_time: if not `0`, this tells when the transaction outputs are spendable. + :param int|None last_relayed_timestamp: last unix time at which the transaction has been relayed. + :param int|None received_timestamp: unix time at which the transaction has been received. + :param bool|None is_double_spend_seen: states if the transaction is a double-spend (`True`) or not (`False`). + :param str|None key: the transaction key. + :param str|None full_hex: full transaction information as a hex string. + :param str|None pruned_hex: pruned block encoded as hex string. + :param str|None prunable_hex: prunable block encoded as a hex string. + :param str|None prunable_hash: keccak-256 hash of the prunable portion of the block. + :param int|None size: backward compatibility, same as `weight`, use that instead. + :param int|None weight: the weight of this transaction in bytes. + :param list[MoneroOutput]|None inputs: list of inputs into transaction. + :param list[MoneroOutput]|None outputs: transaction outputs. + :param list[int]|None output_indices: global (on-chain) output index of each of this transaction's outputs, in order; the indices by which the outputs are referenced as ring members. + :param str|None metadata: transaction metadata. + :param str|None common_tx_sets: A hexadecimal string representing a set of unsigned transactions, or a set of signing keys used in a multisig transaction. + :param list[int]|None extra: usually called the `payment ID` but can be used to include any random 32 bytes. + :param str|None rct_signatures: signatures used in ring signature to hide the true origin of the transaction. + :param str|None rct_sig_prunable: prunable ring signature. + :param bool|None is_kept_by_block: states if the transaction was included in a block at least once (`True`) or not (`False`). + :param bool|None is_failed: indicates if the transaction validation has previously failed. + :param int|None last_failed_height: if the transaction validation has previously failed, this tells at what height that occurred. + :param str|None last_failed_hash: if the transaction validation has previously failed, this tells the previous transaction hash. + :param int|None max_used_block_height: tells the height of the most recent block with an output used in this transaction. + :param str|None max_used_block_hash: tells the hash of the most recent block with an output used in this transaction. + :param list[str]|None signatures: list of signatures used in ring signature to hide the true origin of the transaction. + :param bool|None is_incoming: include incoming transactions. + :param bool|None is_outgoing: include outgoing transactions. + :param list[MoneroIncomingTransfer]|None incoming_transfers: list of incoming transfer. + :param MoneroOutgoingTransfer|None outgoing_transfer: the outgoing transfer related to this transaction. + :param str|None note: transaction note. + :param int|None input_sum: total input sum. + :param int|None output_sum: the total output amount sum originated from this transaction. + :param str|None change_address: address to which the change amount of the transaction was sent. + :param int|None change_amount: change amount of the transaction. + :param int|None num_dummy_outputs: number of decoys of the transactions. + :param str|None extra_hex: extra information about the transaction in hexadecimal format. + :param list[str]|None hashes: get transactions by hashes. + :param bool|None has_payment_id: get transactions that have a payment id. + :param list[str]|None payment_ids: get transactions with specific payment ids. + :param int|None height: get transactions by height. + :param int|None min_height: get transactions above max height. + :param int|None max_height: get transactions below max height. + :param bool|None include_outputs: include outputs in transaction data. + :param MoneroTransferQuery|None transfer_query: query to apply on transaction wallet transfer. + :param MoneroOutputQuery|None input_query: query to apply on transaction inputs. + :param MoneroOutputQuery|None output_query: query to apply on transaction outputs. + """ ... @typing.override diff --git a/src/monero/monero_tx_set.pyi b/src/monero/monero_tx_set.pyi index 6298890..b5553ac 100644 --- a/src/monero/monero_tx_set.pyi +++ b/src/monero/monero_tx_set.pyi @@ -41,6 +41,19 @@ class MoneroTxSet(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a Monero transaction set.""" + def __init__( + self, *, + txs: list[MoneroTxWallet] | None = None, + signed_tx_hex: str | None = None, + unsigned_tx_hex: str | None = None, + multisig_tx_hex: str | None = None + ) -> None: + """ + Initialize a Monero transaction set. The attributes that are not given keep the values of an empty one. + + :param list[MoneroTxWallet]|None txs: the structured transactions in this set (populated when the set is created locally or by `describe_tx_set()`). + :param str|None signed_tx_hex: serialized fully-signed transaction data returned by `MoneroWallet.sign_txs()` on the offline spend wallet; pass it to `submit_txs()` on an online wallet to broadcast. + :param str|None unsigned_tx_hex: serialized unsigned transaction data produced by a view-only wallet's `create_tx()` / `create_txs()`; transfer it to the offline spend wallet and call `MoneroWallet.sign_txs()`. + :param str|None multisig_tx_hex: serialized multisig transaction data produced when a multisig wallet creates transactions; passed to the other cosigners' `MoneroWallet.sign_multisig_tx_hex()` and finally to `submit_multisig_tx_hex()` once enough signatures are collected. + """ ... diff --git a/src/monero/monero_tx_wallet.pyi b/src/monero/monero_tx_wallet.pyi index 70eed72..fe348f7 100644 --- a/src/monero/monero_tx_wallet.pyi +++ b/src/monero/monero_tx_wallet.pyi @@ -8,6 +8,7 @@ from .monero_output_query import MoneroOutputQuery from .monero_output_wallet import MoneroOutputWallet from .monero_transfer import MoneroTransfer from .monero_transfer_query import MoneroTransferQuery +from .monero_output import MoneroOutput class MoneroTxWallet(MoneroTx): @@ -49,8 +50,111 @@ class MoneroTxWallet(MoneroTx): """ ... - def __init__(self) -> None: - """Initialize a new Monero tx wallet.""" + def __init__( + self, *, + hash: str | None = None, + version: int | None = None, + is_miner_tx: bool | None = None, + payment_id: str | None = None, + fee: int | None = None, + ring_size: int | None = None, + relay: bool | None = None, + is_relayed: bool | None = None, + is_confirmed: bool | None = None, + in_tx_pool: bool | None = None, + is_locked: bool | None = None, + num_confirmations: int | None = None, + unlock_time: int | None = None, + last_relayed_timestamp: int | None = None, + received_timestamp: int | None = None, + is_double_spend_seen: bool | None = None, + key: str | None = None, + full_hex: str | None = None, + pruned_hex: str | None = None, + prunable_hex: str | None = None, + prunable_hash: str | None = None, + size: int | None = None, + weight: int | None = None, + inputs: list[MoneroOutput] | None = None, + outputs: list[MoneroOutput] | None = None, + output_indices: list[int] | None = None, + metadata: str | None = None, + common_tx_sets: str | None = None, + extra: list[int] | None = None, + rct_signatures: str | None = None, + rct_sig_prunable: str | None = None, + is_kept_by_block: bool | None = None, + is_failed: bool | None = None, + last_failed_height: int | None = None, + last_failed_hash: str | None = None, + max_used_block_height: int | None = None, + max_used_block_hash: str | None = None, + signatures: list[str] | None = None, + is_incoming: bool | None = None, + is_outgoing: bool | None = None, + incoming_transfers: list[MoneroIncomingTransfer] | None = None, + outgoing_transfer: MoneroOutgoingTransfer | None = None, + note: str | None = None, + input_sum: int | None = None, + output_sum: int | None = None, + change_address: str | None = None, + change_amount: int | None = None, + num_dummy_outputs: int | None = None, + extra_hex: str | None = None + ) -> None: + """ + Initialize a Monero transaction wallet. The attributes that are not given keep the values of an empty one. + + :param str|None hash: the transaction hash. + :param int|None version: transaction version. + :param bool|None is_miner_tx: states if the transaction is a coinbase-transaction (`True`) or not (`False`). + :param str|None payment_id: payment ID for this transaction. + :param int|None fee: the amount of the mining fee included in the transaction, in atomic-units. + :param int|None ring_size: the ring size of this transaction. + :param bool|None relay: states if this transaction should be relayed (`True`) or not (`False`). + :param bool|None is_relayed: states if the transaction was relayed (`True`) or not (`False`). + :param bool|None is_confirmed: states if the transaction included in a block (`True`) or is in pool (`False`). + :param bool|None in_tx_pool: states if the transaction is in pool (`True`) or included in a block (`False`). + :param bool|None is_locked: indicates if the transaction is locked. + :param int|None num_confirmations: number of network confirmations. + :param int|None unlock_time: if not `0`, this tells when the transaction outputs are spendable. + :param int|None last_relayed_timestamp: last unix time at which the transaction has been relayed. + :param int|None received_timestamp: unix time at which the transaction has been received. + :param bool|None is_double_spend_seen: states if the transaction is a double-spend (`True`) or not (`False`). + :param str|None key: the transaction key. + :param str|None full_hex: full transaction information as a hex string. + :param str|None pruned_hex: pruned block encoded as hex string. + :param str|None prunable_hex: prunable block encoded as a hex string. + :param str|None prunable_hash: keccak-256 hash of the prunable portion of the block. + :param int|None size: backward compatibility, same as `weight`, use that instead. + :param int|None weight: the weight of this transaction in bytes. + :param list[MoneroOutput]|None inputs: list of inputs into transaction. + :param list[MoneroOutput]|None outputs: transaction outputs. + :param list[int]|None output_indices: global (on-chain) output index of each of this transaction's outputs, in order; the indices by which the outputs are referenced as ring members. + :param str|None metadata: transaction metadata. + :param str|None common_tx_sets: A hexadecimal string representing a set of unsigned transactions, or a set of signing keys used in a multisig transaction. + :param list[int]|None extra: usually called the `payment ID` but can be used to include any random 32 bytes. + :param str|None rct_signatures: signatures used in ring signature to hide the true origin of the transaction. + :param str|None rct_sig_prunable: prunable ring signature. + :param bool|None is_kept_by_block: states if the transaction was included in a block at least once (`True`) or not (`False`). + :param bool|None is_failed: indicates if the transaction validation has previously failed. + :param int|None last_failed_height: if the transaction validation has previously failed, this tells at what height that occurred. + :param str|None last_failed_hash: if the transaction validation has previously failed, this tells the previous transaction hash. + :param int|None max_used_block_height: tells the height of the most recent block with an output used in this transaction. + :param str|None max_used_block_hash: tells the hash of the most recent block with an output used in this transaction. + :param list[str]|None signatures: list of signatures used in ring signature to hide the true origin of the transaction. + :param bool|None is_incoming: indicates if the transaction has incoming transfers. + :param bool|None is_outgoing: indicated if the transaction has outgoing transfer. + :param list[MoneroIncomingTransfer]|None incoming_transfers: list of incoming transfer. + :param MoneroOutgoingTransfer|None outgoing_transfer: the outgoing transfer related to this transaction. + :param str|None note: transaction note. + :param int|None input_sum: total input sum. + :param int|None output_sum: the total output amount sum originated from this transaction. + :param str|None change_address: address to which the change amount of the transaction was sent. + :param int|None change_amount: change amount of the transaction. + :param int|None num_dummy_outputs: number of decoys of the transactions. + :param str|None extra_hex: extra information about the transaction in hexadecimal format. + """ ... @typing.override diff --git a/src/monero/monero_version.pyi b/src/monero/monero_version.pyi index 6375a1c..2ba00cd 100644 --- a/src/monero/monero_version.pyi +++ b/src/monero/monero_version.pyi @@ -19,6 +19,11 @@ class MoneroVersion(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a new Monero version.""" + def __init__(self, *, number: int | None = None, is_release: bool | None = None) -> None: + """ + Initialize a Monero version. The attributes that are not given keep the values of an empty one. + + :param int|None number: number of the monero software version. + :param bool|None is_release: states if the monero software version corresponds to an official tagged release (`True`), or not (`False`). + """ ... diff --git a/src/monero/monero_wallet_config.pyi b/src/monero/monero_wallet_config.pyi index fefb056..1dd7ab5 100644 --- a/src/monero/monero_wallet_config.pyi +++ b/src/monero/monero_wallet_config.pyi @@ -53,19 +53,28 @@ class MoneroWalletConfig(SerializableStruct): """ ... - @typing.overload - def __init__(self) -> None: + def __init__(self, config: MoneroWalletConfig | None = None, *, path: str | None = None, password: str | None = None, network_type: MoneroNetworkType | None = None, server: MoneroRpcConnection | None = None, is_trusted_daemon: bool | None = None, seed: str | None = None, seed_offset: str | None = None, primary_address: str | None = None, private_view_key: str | None = None, private_spend_key: str | None = None, restore_height: int | None = None, language: str | None = None, save_current: bool | None = None, account_lookahead: int | None = None, subaddress_lookahead: int | None = None, is_multisig: bool | None = None, regtest: bool | None = None) -> None: """ - Initialize an empty Monero wallet config. - """ - ... - - @typing.overload - def __init__(self, config: MoneroWalletConfig) -> None: - """ - Initialize a Monero wallet config. + Initialize a wallet configuration, empty or as a copy of another one. The attributes that are given replace those values. - :param MoneroWalletConfig config: Config to copy. + :param MoneroWalletConfig|None config: the configuration to copy. + :param str|None path: the wallet path on file system. + :param str|None password: the wallet password. + :param MoneroNetworkType|None network_type: the wallet network type. + :param MoneroRpcConnection|None server: the wallet RPC connection. + :param bool|None is_trusted_daemon: indicates whether the configured daemon connection should be treated as trusted. + :param str|None seed: the wallet mnemonic. + :param str|None seed_offset: the wallet custom seed offset. + :param str|None primary_address: the wallet standard address. + :param str|None private_view_key: the wallet private view key. + :param str|None private_spend_key: the wallet private spend key. + :param int|None restore_height: the wallet restore height. + :param str|None language: the wallet language. + :param bool|None save_current: save the wallet. + :param int|None account_lookahead: account index look ahead. + :param int|None subaddress_lookahead: subaddress index look ahead. + :param bool|None is_multisig: indicates if the wallet is a multisignature wallet. + :param bool|None regtest: indicates if wallet is regtest. """ ... diff --git a/src/monero/ssl_options.pyi b/src/monero/ssl_options.pyi index 0ddd2be..404b5da 100644 --- a/src/monero/ssl_options.pyi +++ b/src/monero/ssl_options.pyi @@ -25,6 +25,14 @@ class SslOptions(SerializableStruct): """ ... - def __init__(self) -> None: - """Initialize a new rpc connection ssl options.""" + def __init__(self, *, ssl_private_key_path: str | None = None, ssl_certificate_path: str | None = None, ssl_ca_file: str | None = None, ssl_allowed_fingerprints: list[str] | None = None, ssl_allow_any_cert: bool | None = None) -> None: + """ + Initialize a SSL options. The attributes that are not given keep the values of an empty one. + + :param str|None ssl_private_key_path: path to private ssl key. + :param str|None ssl_certificate_path: path to private ssl certificate. + :param str|None ssl_ca_file: path to ssl CA file. + :param list[str]|None ssl_allowed_fingerprints: allowed ssl fingerprints. + :param bool|None ssl_allow_any_cert: allow any certificate. + """ ... diff --git a/tests/common/test_constructors.py b/tests/common/test_constructors.py new file mode 100644 index 0000000..45e4f59 --- /dev/null +++ b/tests/common/test_constructors.py @@ -0,0 +1,148 @@ +import pytest +import logging + +from monero import ( + MoneroBan, MoneroDestination, MoneroIntegratedAddress, MoneroKeyImage, MoneroNetworkType, MoneroOutput, MoneroRpcConnection, + MoneroSubaddress, MoneroTxConfig, MoneroTxPriority, MoneroVersion, MoneroWalletConfig, SslOptions +) + +from utils import BaseTestClass + +logger: logging.Logger = logging.getLogger("TestConstructors") + + +@pytest.mark.unit +class TestConstructors(BaseTestClass): + """Constructors from keywords of the data classes unit tests.""" + + # A struct built from keywords equals one whose attributes are set one by one + def test_key_image(self) -> None: + expected: MoneroKeyImage = MoneroKeyImage() + expected.hex = "hex" + expected.signature = "signature" + + assert MoneroKeyImage(hex="hex", signature="signature") == expected + + def test_version(self) -> None: + version: MoneroVersion = MoneroVersion(number=65562, is_release=False) + + assert version.number == 65562 + assert version.is_release is False + + def test_ban(self) -> None: + ban: MoneroBan = MoneroBan(host="192.168.1.1", ip=16885952, is_banned=True, seconds=600) + + assert (ban.host, ban.ip, ban.is_banned, ban.seconds) == ("192.168.1.1", 16885952, True, 600) + + def test_ssl_options(self) -> None: + options: SslOptions = SslOptions( + ssl_private_key_path="key", ssl_certificate_path="certificate", ssl_ca_file="ca", + ssl_allowed_fingerprints=["fingerprint"], ssl_allow_any_cert=True + ) + + assert (options.ssl_private_key_path, options.ssl_certificate_path, options.ssl_ca_file) == ("key", "certificate", "ca") + assert list(options.ssl_allowed_fingerprints) == ["fingerprint"] + assert options.ssl_allow_any_cert is True + + def test_output(self) -> None: + key_image: MoneroKeyImage = MoneroKeyImage(hex="hex") + output: MoneroOutput = MoneroOutput( + key_image=key_image, amount=1000, index=2, stealth_public_key="key", mask="mask", ring_output_indices=[1, 2] + ) + + assert output.key_image is key_image + assert (output.amount, output.index, output.stealth_public_key, output.mask) == (1000, 2, "key", "mask") + assert list(output.ring_output_indices) == [1, 2] + assert output.tx is None + + def test_subaddress(self) -> None: + subaddress: MoneroSubaddress = MoneroSubaddress( + account_index=1, index=2, address="address", label="label", balance=10, unlocked_balance=5, num_unspent_outputs=3, + is_used=True, num_blocks_to_unlock=4 + ) + + assert (subaddress.account_index, subaddress.index, subaddress.address, subaddress.label) == (1, 2, "address", "label") + assert (subaddress.balance, subaddress.unlocked_balance, subaddress.num_unspent_outputs) == (10, 5, 3) + assert (subaddress.is_used, subaddress.num_blocks_to_unlock) == (True, 4) + + def test_integrated_address(self) -> None: + address: MoneroIntegratedAddress = MoneroIntegratedAddress( + standard_address="standard", payment_id="payment id", integrated_address="integrated" + ) + + assert (address.standard_address, address.payment_id, address.integrated_address) == ("standard", "payment id", "integrated") + + def test_wallet_config(self) -> None: + server: MoneroRpcConnection = MoneroRpcConnection("http://localhost:28081") + config: MoneroWalletConfig = MoneroWalletConfig( + path="path", password="password", network_type=MoneroNetworkType.TESTNET, server=server, is_trusted_daemon=True, + seed="seed", seed_offset="offset", primary_address="address", private_view_key="view", private_spend_key="spend", + restore_height=100, language="English", save_current=False, account_lookahead=2, subaddress_lookahead=3, + is_multisig=True, regtest=True + ) + + assert config.server is server + assert (config.path, config.password, config.network_type, config.is_trusted_daemon) == ( + "path", "password", MoneroNetworkType.TESTNET, True) + assert (config.seed, config.seed_offset, config.primary_address) == ("seed", "offset", "address") + assert (config.private_view_key, config.private_spend_key) == ("view", "spend") + assert (config.restore_height, config.language, config.save_current) == (100, "English", False) + assert (config.account_lookahead, config.subaddress_lookahead, config.is_multisig, config.regtest) == (2, 3, True, True) + # a copy of a config, also by name, and with the attributes that the keywords replace + assert MoneroWalletConfig(config) == config + assert MoneroWalletConfig(config=config) == config + copy: MoneroWalletConfig = MoneroWalletConfig(config, path="other path") + assert (copy.path, copy.password, config.path) == ("other path", "password", "path") + + def test_tx_config(self) -> None: + destination: MoneroDestination = MoneroDestination("address", 1000) + config: MoneroTxConfig = MoneroTxConfig( + destinations=[destination], subtract_fee_from=[0], payment_id="payment id", priority=MoneroTxPriority.NORMAL, + ring_size=16, fee=10, account_index=1, subaddress_indices=[0, 1], can_split=False, relay=True, note="note", + recipient_name="name", below_amount=5, sweep_each_subaddress=True, key_image="key image" + ) + + assert config.destinations[0] is destination + assert (list(config.subtract_fee_from), list(config.subaddress_indices)) == ([0], [0, 1]) + assert (config.payment_id, config.priority, config.ring_size, config.fee) == ("payment id", MoneroTxPriority.NORMAL, 16, 10) + assert (config.account_index, config.can_split, config.relay, config.note) == (1, False, True, "note") + assert (config.recipient_name, config.below_amount, config.sweep_each_subaddress) == ("name", 5, True) + assert config.key_image == "key image" + # a copy of a config, with the attributes that the keywords replace + assert MoneroTxConfig(config) == config + copy: MoneroTxConfig = MoneroTxConfig(config, relay=False, subaddress_indices=[2]) + assert (copy.relay, list(copy.subaddress_indices), copy.note) == (False, [2], "note") + assert (config.relay, list(config.subaddress_indices)) == (True, [0, 1]) + + # The address and the amount of a tx config are its attributes, as when they are set one by one + def test_tx_config_address_and_amount(self) -> None: + expected: MoneroTxConfig = MoneroTxConfig() + expected.address = "address" + expected.amount = 1000 + + config: MoneroTxConfig = MoneroTxConfig(address="address", amount=1000) + + assert config == expected + assert (config.address, config.amount, len(config.destinations)) == ("address", 1000, 0) + + # A keyword that is not given, or is None, leaves the attribute as the empty constructor sets it + def test_keywords_are_optional(self) -> None: + assert MoneroKeyImage(hex="hex").signature is None + assert MoneroSubaddress(label=None) == MoneroSubaddress() + # these attributes are not optional + assert MoneroIntegratedAddress(payment_id=None).payment_id == "" + assert list(SslOptions(ssl_allowed_fingerprints=None).ssl_allowed_fingerprints) == [] + + # The constructor takes keywords only + def test_positional_arguments_raise(self) -> None: + with pytest.raises(TypeError): + MoneroKeyImage("hex") # pyright: ignore[reportCallIssue] + + # A list of a struct that is given to another one stays in the first + def test_lists_are_copied(self) -> None: + source: MoneroOutput = MoneroOutput(ring_output_indices=[1, 2]) + output: MoneroOutput = MoneroOutput(ring_output_indices=source.ring_output_indices) + output.ring_output_indices.append(3) + + assert list(source.ring_output_indices) == [1, 2] + assert list(output.ring_output_indices) == [1, 2, 3] diff --git a/tests/common/test_constructors_completeness.py b/tests/common/test_constructors_completeness.py new file mode 100644 index 0000000..6c91368 --- /dev/null +++ b/tests/common/test_constructors_completeness.py @@ -0,0 +1,119 @@ +"""Every data class of the module has a constructor that takes its attributes, also the ones that are added later.""" +import logging +import re +from typing import Any, Callable, cast + +import monero +import pytest +from monero import ( + MoneroAccountTag, MoneroAddressBookEntry, MoneroAuxiliaryPow, MoneroDecodedAddress, MoneroDestination, MoneroError, + MoneroOutputQuery, MoneroRpcConnection, MoneroSyncResult, MoneroTransferQuery, MoneroTxQuery, SerializableStruct +) + +from utils import BaseTestClass + +logger: logging.Logger = logging.getLogger("TestConstructorsCompleteness") + +# the classes whose constructors take the arguments that make one, which is not made of any of its attributes +POSITIONAL: tuple[type, ...] = ( + MoneroAccountTag, MoneroAddressBookEntry, MoneroAuxiliaryPow, MoneroDecodedAddress, MoneroDestination, MoneroRpcConnection, + MoneroSyncResult +) +# the attributes that refer to the object that contains a struct, which sets them +PARENTS: set[str] = {"tx", "block", "tx_set"} + + +def _data_classes() -> list[type]: + values: list[Any] = list(vars(monero).values()) + classes: list[type] = [v for v in values if isinstance(v, type) and issubclass(v, SerializableStruct) and v is not SerializableStruct] + return sorted((c for c in classes if c not in POSITIONAL), key=lambda c: c.__name__) + + +def _attributes(cls: type) -> set[str]: + names: set[str] = set() + for base in cls.__mro__: + for name, member in vars(base).items(): + if isinstance(member, property) and member.fset is not None: + names.add(name) + return names - PARENTS + + +def _keywords(cls: type) -> dict[str, str]: + """The keywords of the constructor and their types, from the signature that pybind11 writes in its docstring.""" + doc: str = str(cls.__init__.__doc__) + keywords: dict[str, str] = dict(re.findall(r"(\w+): Optional\[(.*?)\] = None(?=, |\))", doc)) + # the config that a config copies is not an attribute + keywords.pop("config", None) + return keywords + + +def _sample(type_name: str) -> Any: + """A value of a type of a signature, other than the one of an empty struct.""" + name: str = type_name.removeprefix("monero.") + simple: dict[str, Any] = {"int": 1, "str": "a", "bool": True, "float": 1.5} + if name in simple: + return simple[name] + # a list or a map that pybind11 converts, which is not one that the module binds: pybind11 2.11 writes List and Dict, + # the later versions list and dict + outer, _, inner = name.removesuffix("]").partition("[") + if outer.lower() == "list": + return [_sample(inner)] + if outer.lower() == "dict": + key, value = inner.split(", ") + return {_sample(key): _sample(value)} + if name.startswith("Vector"): + element: str = name.removeprefix("Vector").removesuffix("Ptr") + if element in ("String", "Int", "Uint8", "Uint32", "Uint64"): + return [_sample("str" if element == "String" else "int")] + return [_sample(element if element.startswith("Monero") else f"Monero{element}")] + cls: Any = getattr(monero, name) + if hasattr(cls, "__members__"): + return list(cast("dict[str, Any]", cls.__members__).values())[-1] + return cls() + + +@pytest.mark.unit +class TestConstructorsCompleteness(BaseTestClass): + """Completeness of the constructors of the data classes unit tests.""" + + # The keywords of a constructor are the attributes that can be set + @pytest.mark.parametrize("cls", _data_classes(), ids=lambda c: str(c.__name__)) + def test_keywords_are_the_attributes(self, cls: type) -> None: + assert set(_keywords(cls)) == _attributes(cls) + + # Each keyword sets its attribute + @pytest.mark.parametrize("cls", _data_classes(), ids=lambda c: str(c.__name__)) + def test_each_keyword_sets_its_attribute(self, cls: type) -> None: + factory: Callable[..., Any] = cls + for name, type_name in _keywords(cls).items(): + value: Any = _sample(type_name) + result: Any = getattr(factory(**{name: value}), name) + if isinstance(value, list): + items: list[Any] = cast("list[Any]", value) + assert len(result) == 1 and result[0] == items[0], name + elif isinstance(value, dict): + assert dict(result.items()) == value, name + else: + assert result == value, name + + # The queries that a query is given refer back to it, as when they are set one by one + def test_queries_refer_back(self) -> None: + transfer_query: MoneroTransferQuery = MoneroTransferQuery() + input_query: MoneroOutputQuery = MoneroOutputQuery() + output_query: MoneroOutputQuery = MoneroOutputQuery() + query: MoneroTxQuery = MoneroTxQuery(transfer_query=transfer_query, input_query=input_query, output_query=output_query) + + assert query.transfer_query is transfer_query and transfer_query.tx_query is query + assert query.input_query is input_query and input_query.tx_query is query + assert query.output_query is output_query and output_query.tx_query is query + + tx_query: MoneroTxQuery = MoneroTxQuery() + child: MoneroTransferQuery = MoneroTransferQuery(tx_query=tx_query) + assert child.tx_query is tx_query and tx_query.transfer_query is child + + # A transfer query is incoming or outgoing + def test_transfer_query_direction(self) -> None: + assert MoneroTransferQuery(outgoing=True).incoming is False + assert MoneroTransferQuery(incoming=True, outgoing=False).incoming is True + with pytest.raises(MoneroError, match="contradicts itself"): + MoneroTransferQuery(incoming=True, outgoing=True)