From 11cdb4bcf708ca1754cb9b7f399aa1ff733dfb9c Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 22:47:03 +0100 Subject: [PATCH 01/19] wallet: use get_subaddress() of monero-cpp --- src/cpp/wallet/py_monero_wallet_bindings.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp index 9612f6d..585ef9a 100644 --- a/src/cpp/wallet/py_monero_wallet_bindings.cpp +++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp @@ -796,20 +796,8 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def("create_account", [](PyMoneroWallet& self, const std::string& label) { MONERO_CATCH_AND_RETHROW(self.create_account(label)); }, py::arg("label") = "", py::call_guard()) - .def("get_subaddress", [](PyMoneroWallet& wallet, uint32_t account_idx, uint32_t subaddress_idx) { - // TODO move this to monero-cpp? - try { - std::vector subaddress_indices; - subaddress_indices.push_back(subaddress_idx); - auto subaddresses = wallet.get_subaddresses(account_idx, subaddress_indices); - if (subaddresses.empty()) throw std::runtime_error("Subaddress is not initialized"); - if (subaddresses.size() != 1) throw std::runtime_error("Only 1 subaddress should be returned"); - return subaddresses[0]; - } catch (const monero_rpc_error& e) { - throw; - } catch (const std::exception& e) { - throw monero_error(e.what()); - } + .def("get_subaddress", [](PyMoneroWallet& self, uint32_t account_idx, uint32_t subaddress_idx) { + MONERO_CATCH_AND_RETHROW(self.get_subaddress(account_idx, subaddress_idx)); }, py::arg("account_idx"), py::arg("subaddress_idx"), py::call_guard()) .def("get_subaddresses", [](PyMoneroWallet& self, uint32_t account_idx) { MONERO_CATCH_AND_RETHROW(self.get_subaddresses(account_idx)); @@ -1169,9 +1157,6 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def("set_poll_period_in_ms", [](monero_wallet_rpc& self, uint64_t period_ms) { MONERO_CATCH_AND_RETHROW(self.set_poll_period_in_ms(period_ms)); }, py::arg("period_ms"), py::call_guard()) - .def("get_subaddress", [](monero_wallet_rpc& self, uint32_t account_idx, uint32_t subaddress_idx) { - MONERO_CATCH_AND_RETHROW(self.get_subaddress(account_idx, subaddress_idx)); - }, py::arg("account_idx"), py::arg("subaddress_idx"), py::call_guard()) // this because of function hiding .def("set_daemon_connection", [](PyMoneroWallet& self, const std::shared_ptr& connection, const boost::optional& is_trusted) { MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(connection, is_trusted)); From fde2513263d00fc1c4875fe6ffdeb755e81d3a36 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 22:47:19 +0100 Subject: [PATCH 02/19] wallet: remove the tx sorting that monero-cpp already does --- src/cpp/utils/py_monero_utils.cpp | 38 -------------------- src/cpp/utils/py_monero_utils.h | 4 --- src/cpp/wallet/py_monero_wallet_bindings.cpp | 6 ++-- 3 files changed, 4 insertions(+), 44 deletions(-) diff --git a/src/cpp/utils/py_monero_utils.cpp b/src/cpp/utils/py_monero_utils.cpp index 555727f..4c32443 100644 --- a/src/cpp/utils/py_monero_utils.cpp +++ b/src/cpp/utils/py_monero_utils.cpp @@ -124,41 +124,3 @@ std::string PyMoneroUtils::binary_blocks_fast_to_json(const std::string &bin) { monero_utils::binary_blocks_fast_to_json(bin, json); return json; } - -void PyMoneroUtils::sort_txs_wallet(std::vector>& txs, const std::vector& hashes) { - bool empty = hashes.empty(); - std::vector tx_hashes; - std::unordered_map> tx_map; - - for (const auto& tx : txs) { - std::string tx_hash = tx->m_hash.get(); - tx_map.emplace(tx_hash, tx); - if (empty) tx_hashes.push_back(tx_hash); - } - - std::vector> sorted_txs; - sorted_txs.reserve(hashes.size()); - - const auto& v_hashes = empty ? tx_hashes : hashes; - - for (const auto& tx_hash : v_hashes) { - auto it = tx_map.find(tx_hash); - if (it != tx_map.end()) { - sorted_txs.push_back(it->second); - } - } - - txs = std::move(sorted_txs); -} - -std::vector> PyMoneroUtils::get_and_sort_txs(const monero_wallet& wallet, const monero_tx_query& tx_query) { - auto txs = wallet.get_txs(tx_query); - sort_txs_wallet(txs, tx_query.m_hashes); - return txs; -} - -std::vector> PyMoneroUtils::get_and_sort_txs(const monero_wallet& wallet, const std::vector& tx_hashes) { - monero_tx_query tx_query; - tx_query.m_hashes = tx_hashes; - return get_and_sort_txs(wallet, tx_query); -} diff --git a/src/cpp/utils/py_monero_utils.h b/src/cpp/utils/py_monero_utils.h index 717ceef..45d07d2 100644 --- a/src/cpp/utils/py_monero_utils.h +++ b/src/cpp/utils/py_monero_utils.h @@ -76,10 +76,6 @@ class PyMoneroUtils { static bool is_valid_payment_id_long(const std::string& payment_id_str); static bool is_valid_payment_id_short(const std::string& payment_id_str); - static void sort_txs_wallet(std::vector>& txs, const std::vector& hashes); - static std::vector> get_and_sort_txs(const monero_wallet& wallet, const std::vector& tx_hashes); - static std::vector> get_and_sort_txs(const monero_wallet& wallet, const monero_tx_query& tx_query); - template static void set_query(std::shared_ptr& self, std::shared_ptr& field, const boost::optional>& val) { const auto old = field; diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp index 585ef9a..5659128 100644 --- a/src/cpp/wallet/py_monero_wallet_bindings.cpp +++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp @@ -825,10 +825,12 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { MONERO_CATCH_AND_RETHROW(self.get_txs()); }, py::call_guard()) .def("get_txs", [](PyMoneroWallet& self, const monero_tx_query& query) { - MONERO_CATCH_AND_RETHROW(PyMoneroUtils::get_and_sort_txs(self, query)); + MONERO_CATCH_AND_RETHROW(self.get_txs(query)); }, py::arg("query"), py::call_guard()) .def("get_txs", [](PyMoneroWallet& self, const std::vector& tx_hashes) { - MONERO_CATCH_AND_RETHROW(PyMoneroUtils::get_and_sort_txs(self, tx_hashes)); + monero_tx_query query; + query.m_hashes = tx_hashes; + MONERO_CATCH_AND_RETHROW(self.get_txs(query)); }, py::arg("tx_hashes"), py::call_guard()) .def("get_transfers", [](PyMoneroWallet& self, const monero_transfer_query& query) { MONERO_CATCH_AND_RETHROW(self.get_transfers(query)); From 3270b1962ae3d0ed06855dfe574be698a046b349 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 22:47:19 +0100 Subject: [PATCH 03/19] wallet: bind the methods to monero_wallet instead of its trampoline --- src/cpp/wallet/py_monero_wallet_bindings.cpp | 280 +++++++++---------- 1 file changed, 140 insertions(+), 140 deletions(-) diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp index 5659128..6cd5dfa 100644 --- a/src/cpp/wallet/py_monero_wallet_bindings.cpp +++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp @@ -59,7 +59,7 @@ namespace monero { } // like monero-java's MoneroWalletDefault: the transfers of one direction, from a copy of the query with that direction -static std::vector> get_incoming_transfers(PyMoneroWallet& wallet, const monero_transfer_query& query) { +static std::vector> get_incoming_transfers(monero_wallet& wallet, const monero_transfer_query& query) { monero_transfer_query incoming_query = query; if (gen_utils::bool_equals(false, incoming_query.m_is_incoming)) throw monero_error("Transfer query contradicts getting incoming transfers"); incoming_query.m_is_incoming = true; @@ -70,7 +70,7 @@ static std::vector> get_incoming_trans return transfers; } -static std::vector> get_outgoing_transfers(PyMoneroWallet& wallet, const monero_transfer_query& query) { +static std::vector> get_outgoing_transfers(monero_wallet& wallet, const monero_transfer_query& query) { monero_transfer_query outgoing_query = query; if (gen_utils::bool_equals(false, outgoing_query.is_outgoing())) throw monero_error("Transfer query contradicts getting outgoing transfers"); outgoing_query.m_is_incoming = false; @@ -637,181 +637,181 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { t.py_monero_wallet .def(py::init<>()) .def_property_readonly_static("DEFAULT_LANGUAGE", [](py::object /* self */) { return std::string("English"); }) - .def("is_view_only", [](PyMoneroWallet& self) { + .def("is_view_only", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.is_view_only()); }, py::call_guard()) - .def("set_daemon_connection", [](PyMoneroWallet& self, const std::shared_ptr& connection, const boost::optional& is_trusted) { + .def("set_daemon_connection", [](monero_wallet& self, const std::shared_ptr& connection, const boost::optional& is_trusted) { MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(connection, is_trusted)); }, py::arg("connection"), py::arg("is_trusted") = py::none(), py::call_guard()) - .def("set_daemon_connection", [](PyMoneroWallet& self, const std::string& uri, const std::string& username, const std::string& password, const std::string& proxy, const boost::optional& is_trusted) { + .def("set_daemon_connection", [](monero_wallet& self, const std::string& uri, const std::string& username, const std::string& password, const std::string& proxy, const boost::optional& is_trusted) { MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(uri, username, password, proxy, is_trusted)); }, py::arg("uri"), py::arg("username") = "", py::arg("password") = "", py::arg("proxy") = "", py::arg("is_trusted") = py::none(), py::call_guard()) - .def("get_daemon_connection", [](PyMoneroWallet& self) { + .def("get_daemon_connection", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_daemon_connection()); }, py::call_guard()) - .def("is_connected_to_daemon", [](PyMoneroWallet& self) { + .def("is_connected_to_daemon", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.is_connected_to_daemon()); }, py::call_guard()) - .def("is_daemon_synced", [](PyMoneroWallet& self) { + .def("is_daemon_synced", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.is_daemon_synced()); }, py::call_guard()) - .def("is_daemon_trusted", [](PyMoneroWallet& self) { + .def("is_daemon_trusted", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.is_daemon_trusted()); }, py::call_guard()) - .def("is_synced", [](PyMoneroWallet& self) { + .def("is_synced", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.is_synced()); }, py::call_guard()) - .def("get_version", [](PyMoneroWallet& self) { + .def("get_version", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_version()); }, py::call_guard()) - .def("get_path", [](PyMoneroWallet& self) { + .def("get_path", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_path()); }, py::call_guard()) - .def("get_network_type", [](PyMoneroWallet& self) { + .def("get_network_type", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_network_type()); }, py::call_guard()) - .def("get_seed", [](PyMoneroWallet& self) { + .def("get_seed", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_seed()); }, py::call_guard()) - .def("get_seed_language", [](PyMoneroWallet& self) { + .def("get_seed_language", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_seed_language()); }, py::call_guard()) - .def("get_public_view_key", [](PyMoneroWallet& self) { + .def("get_public_view_key", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_public_view_key()); }, py::call_guard()) - .def("get_private_view_key", [](PyMoneroWallet& self) { + .def("get_private_view_key", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_private_view_key()); }, py::call_guard()) - .def("get_public_spend_key", [](PyMoneroWallet& self) { + .def("get_public_spend_key", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_public_spend_key()); }, py::call_guard()) - .def("get_private_spend_key", [](PyMoneroWallet& self) { + .def("get_private_spend_key", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_private_spend_key()); }, py::call_guard()) - .def("get_primary_address", [](PyMoneroWallet& self) { + .def("get_primary_address", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_primary_address()); }, py::call_guard()) - .def("get_address", [](PyMoneroWallet& self, uint32_t account_idx, uint32_t subaddress_idx) { + .def("get_address", [](monero_wallet& self, uint32_t account_idx, uint32_t subaddress_idx) { MONERO_CATCH_AND_RETHROW(self.get_address(account_idx, subaddress_idx)); }, py::arg("account_idx"), py::arg("subaddress_idx"), py::call_guard()) - .def("get_address_index", [](PyMoneroWallet& self, const std::string& address) { + .def("get_address_index", [](monero_wallet& self, const std::string& address) { MONERO_CATCH_AND_RETHROW(self.get_address_index(address)); }, py::arg("address"), py::call_guard()) - .def("get_integrated_address", [](PyMoneroWallet& self, const std::string& standard_address, const std::string& payment_id) { + .def("get_integrated_address", [](monero_wallet& self, const std::string& standard_address, const std::string& payment_id) { MONERO_CATCH_AND_RETHROW(self.get_integrated_address(standard_address, payment_id)); }, py::arg("standard_address") = "", py::arg("payment_id") = "", py::call_guard()) - .def("decode_integrated_address", [](PyMoneroWallet& self, const std::string& integrated_address) { + .def("decode_integrated_address", [](monero_wallet& self, const std::string& integrated_address) { MONERO_CATCH_AND_RETHROW(self.decode_integrated_address(integrated_address)); }, py::arg("integrated_address"), py::call_guard()) - .def("get_height", [](PyMoneroWallet& self) { + .def("get_height", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_height()); }, py::call_guard()) - .def("get_restore_height", [](PyMoneroWallet& self) { + .def("get_restore_height", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_restore_height()); }, py::call_guard()) - .def("set_restore_height", [](PyMoneroWallet& self, uint64_t restore_height) { + .def("set_restore_height", [](monero_wallet& self, uint64_t restore_height) { MONERO_CATCH_AND_RETHROW(self.set_restore_height(restore_height)); }, py::arg("restore_height"), py::call_guard()) - .def("get_daemon_height", [](PyMoneroWallet& self) { + .def("get_daemon_height", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_daemon_height()); }, py::call_guard()) - .def("get_daemon_max_peer_height", [](PyMoneroWallet& self) { + .def("get_daemon_max_peer_height", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_daemon_max_peer_height()); }, py::call_guard()) - .def("get_height_by_date", [](PyMoneroWallet& self, uint16_t year, uint8_t month, uint8_t day) { + .def("get_height_by_date", [](monero_wallet& self, uint16_t year, uint8_t month, uint8_t day) { MONERO_CATCH_AND_RETHROW(self.get_height_by_date(year, month, day)); }, py::arg("year"), py::arg("month"), py::arg("day"), py::call_guard()) - .def("add_listener", [](PyMoneroWallet& self, monero_wallet_listener& listener) { + .def("add_listener", [](monero_wallet& self, monero_wallet_listener& listener) { MONERO_CATCH_AND_RETHROW(self.add_listener(listener)); }, py::arg("listener"), py::keep_alive<1, 2>(), py::call_guard()) - .def("remove_listener", [](PyMoneroWallet& self, monero_wallet_listener& listener) { + .def("remove_listener", [](monero_wallet& self, monero_wallet_listener& listener) { MONERO_CATCH_AND_RETHROW(self.remove_listener(listener)); }, py::arg("listener"), py::call_guard()) - .def("get_listeners", [](PyMoneroWallet& self) { + .def("get_listeners", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_listeners()); }, py::call_guard()) - .def("sync", [](PyMoneroWallet& self) { + .def("sync", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.sync()); }, py::call_guard()) - .def("sync", [](PyMoneroWallet& self, monero_wallet_listener& listener) { + .def("sync", [](monero_wallet& self, monero_wallet_listener& listener) { MONERO_CATCH_AND_RETHROW(self.sync(listener)); }, py::arg("listener"), py::call_guard()) - .def("sync", [](PyMoneroWallet& self, uint64_t start_height) { + .def("sync", [](monero_wallet& self, uint64_t start_height) { MONERO_CATCH_AND_RETHROW(self.sync(start_height)); }, py::arg("start_height"), py::call_guard()) - .def("sync", [](PyMoneroWallet& self, uint64_t start_height, monero_wallet_listener& listener) { + .def("sync", [](monero_wallet& self, uint64_t start_height, monero_wallet_listener& listener) { MONERO_CATCH_AND_RETHROW(self.sync(start_height, listener)); }, py::arg("start_height"), py::arg("listener"), py::call_guard()) - .def("start_syncing", [](PyMoneroWallet& self, uint64_t sync_period_in_ms) { + .def("start_syncing", [](monero_wallet& self, uint64_t sync_period_in_ms) { MONERO_CATCH_AND_RETHROW(self.start_syncing(sync_period_in_ms)); }, py::arg("sync_period_in_ms") = 10000, py::call_guard()) - .def("stop_syncing", [](PyMoneroWallet& self) { + .def("stop_syncing", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.stop_syncing()); }, py::call_guard()) - .def("scan_txs", [](PyMoneroWallet& self, const std::vector& tx_hashes) { + .def("scan_txs", [](monero_wallet& self, const std::vector& tx_hashes) { MONERO_CATCH_AND_RETHROW(self.scan_txs(tx_hashes)); }, py::arg("tx_hashes"), py::call_guard()) - .def("rescan_spent", [](PyMoneroWallet& self) { + .def("rescan_spent", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.rescan_spent()); }, py::call_guard()) - .def("rescan_blockchain", [](PyMoneroWallet& self) { + .def("rescan_blockchain", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.rescan_blockchain()); }, py::call_guard()) - .def("get_balance", [](PyMoneroWallet& self) { + .def("get_balance", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_balance()); }, py::call_guard()) - .def("get_balance", [](PyMoneroWallet& self, uint32_t account_idx) { + .def("get_balance", [](monero_wallet& self, uint32_t account_idx) { MONERO_CATCH_AND_RETHROW(self.get_balance(account_idx)); }, py::arg("account_idx"), py::call_guard()) - .def("get_balance", [](PyMoneroWallet& self, uint32_t account_idx, uint32_t subaddress_idx) { + .def("get_balance", [](monero_wallet& self, uint32_t account_idx, uint32_t subaddress_idx) { MONERO_CATCH_AND_RETHROW(self.get_balance(account_idx, subaddress_idx)); }, py::arg("account_idx"), py::arg("subaddress_idx"), py::call_guard()) - .def("get_unlocked_balance", [](PyMoneroWallet& self) { + .def("get_unlocked_balance", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_unlocked_balance()); }, py::call_guard()) - .def("get_unlocked_balance", [](PyMoneroWallet& self, uint32_t account_idx) { + .def("get_unlocked_balance", [](monero_wallet& self, uint32_t account_idx) { MONERO_CATCH_AND_RETHROW(self.get_unlocked_balance(account_idx)); }, py::arg("account_idx"), py::call_guard()) - .def("get_unlocked_balance", [](PyMoneroWallet& self, uint32_t account_idx, uint32_t subaddress_idx) { + .def("get_unlocked_balance", [](monero_wallet& self, uint32_t account_idx, uint32_t subaddress_idx) { MONERO_CATCH_AND_RETHROW(self.get_unlocked_balance(account_idx, subaddress_idx)); }, py::arg("account_idx"), py::arg("subaddress_idx"), py::call_guard()) - .def("get_accounts", [](PyMoneroWallet& self) { + .def("get_accounts", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_accounts()); }, py::call_guard()) - .def("get_accounts", [](PyMoneroWallet& self, bool include_subaddresses) { + .def("get_accounts", [](monero_wallet& self, bool include_subaddresses) { MONERO_CATCH_AND_RETHROW(self.get_accounts(include_subaddresses)); }, py::arg("include_subaddresses"), py::call_guard()) - .def("get_accounts", [](PyMoneroWallet& self, const std::string& tag) { + .def("get_accounts", [](monero_wallet& self, const std::string& tag) { MONERO_CATCH_AND_RETHROW(self.get_accounts(tag)); }, py::arg("tag"), py::call_guard()) - .def("get_accounts", [](PyMoneroWallet& self, bool include_subaddresses, const std::string& tag) { + .def("get_accounts", [](monero_wallet& self, bool include_subaddresses, const std::string& tag) { MONERO_CATCH_AND_RETHROW(self.get_accounts(include_subaddresses, tag)); }, py::arg("include_subaddresses"), py::arg("tag"), py::call_guard()) - .def("get_account", [](PyMoneroWallet& self, uint32_t account_idx) { + .def("get_account", [](monero_wallet& self, uint32_t account_idx) { MONERO_CATCH_AND_RETHROW(self.get_account(account_idx)); }, py::arg("account_idx"), py::call_guard()) - .def("get_account", [](PyMoneroWallet& self, uint32_t account_idx, bool include_subaddresses) { + .def("get_account", [](monero_wallet& self, uint32_t account_idx, bool include_subaddresses) { MONERO_CATCH_AND_RETHROW(self.get_account(account_idx, include_subaddresses)); }, py::arg("account_idx"), py::arg("include_subaddresses"), py::call_guard()) - .def("create_account", [](PyMoneroWallet& self, const std::string& label) { + .def("create_account", [](monero_wallet& self, const std::string& label) { MONERO_CATCH_AND_RETHROW(self.create_account(label)); }, py::arg("label") = "", py::call_guard()) - .def("get_subaddress", [](PyMoneroWallet& self, uint32_t account_idx, uint32_t subaddress_idx) { + .def("get_subaddress", [](monero_wallet& self, uint32_t account_idx, uint32_t subaddress_idx) { MONERO_CATCH_AND_RETHROW(self.get_subaddress(account_idx, subaddress_idx)); }, py::arg("account_idx"), py::arg("subaddress_idx"), py::call_guard()) - .def("get_subaddresses", [](PyMoneroWallet& self, uint32_t account_idx) { + .def("get_subaddresses", [](monero_wallet& self, uint32_t account_idx) { MONERO_CATCH_AND_RETHROW(self.get_subaddresses(account_idx)); }, py::arg("account_idx"), py::call_guard()) - .def("get_subaddresses", [](PyMoneroWallet& self, uint32_t account_idx, const std::vector& subaddress_indices) { + .def("get_subaddresses", [](monero_wallet& self, uint32_t account_idx, const std::vector& subaddress_indices) { MONERO_CATCH_AND_RETHROW(self.get_subaddresses(account_idx, subaddress_indices)); }, py::arg("account_idx"), py::arg("subaddress_indices"), py::call_guard()) - .def("create_subaddress", [](PyMoneroWallet& self, uint32_t account_idx, const std::string& label) { + .def("create_subaddress", [](monero_wallet& self, uint32_t account_idx, const std::string& label) { MONERO_CATCH_AND_RETHROW(self.create_subaddress(account_idx, label)); }, py::arg("account_idx"), py::arg("label") = "", py::call_guard()) - .def("set_subaddress_label", [](PyMoneroWallet& self, uint32_t account_idx, uint32_t subaddress_idx, const std::string& label) { + .def("set_subaddress_label", [](monero_wallet& self, uint32_t account_idx, uint32_t subaddress_idx, const std::string& label) { MONERO_CATCH_AND_RETHROW(self.set_subaddress_label(account_idx, subaddress_idx, label)); }, py::arg("account_idx"), py::arg("subaddress_idx"), py::arg("label") = "", py::call_guard()) - .def("get_tx", [](PyMoneroWallet& self, const std::string& tx_hash) { + .def("get_tx", [](monero_wallet& self, const std::string& tx_hash) { std::shared_ptr result = nullptr; monero_tx_query query; query.m_hashes.push_back(tx_hash); @@ -821,131 +821,131 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { } return result; }, py::arg("tx_hash"), py::call_guard()) - .def("get_txs", [](PyMoneroWallet& self) { + .def("get_txs", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_txs()); }, py::call_guard()) - .def("get_txs", [](PyMoneroWallet& self, const monero_tx_query& query) { + .def("get_txs", [](monero_wallet& self, const monero_tx_query& query) { MONERO_CATCH_AND_RETHROW(self.get_txs(query)); }, py::arg("query"), py::call_guard()) - .def("get_txs", [](PyMoneroWallet& self, const std::vector& tx_hashes) { + .def("get_txs", [](monero_wallet& self, const std::vector& tx_hashes) { monero_tx_query query; query.m_hashes = tx_hashes; MONERO_CATCH_AND_RETHROW(self.get_txs(query)); }, py::arg("tx_hashes"), py::call_guard()) - .def("get_transfers", [](PyMoneroWallet& self, const monero_transfer_query& query) { + .def("get_transfers", [](monero_wallet& self, const monero_transfer_query& query) { MONERO_CATCH_AND_RETHROW(self.get_transfers(query)); }, py::arg("query"), py::call_guard()) - .def("get_transfers", [](PyMoneroWallet& self) { + .def("get_transfers", [](monero_wallet& self) { monero_transfer_query query; MONERO_CATCH_AND_RETHROW(self.get_transfers(query)); }, py::call_guard()) - .def("get_transfers", [](PyMoneroWallet& self, uint32_t account_index) { + .def("get_transfers", [](monero_wallet& self, uint32_t account_index) { monero_transfer_query query; query.m_account_index = account_index; MONERO_CATCH_AND_RETHROW(self.get_transfers(query)); }, py::arg("account_index"), py::call_guard()) - .def("get_transfers", [](PyMoneroWallet& self, uint32_t account_index, uint32_t subaddress_index) { + .def("get_transfers", [](monero_wallet& self, uint32_t account_index, uint32_t subaddress_index) { monero_transfer_query query; query.m_account_index = account_index; query.m_subaddress_index = subaddress_index; MONERO_CATCH_AND_RETHROW(self.get_transfers(query)); }, py::arg("account_index"), py::arg("subaddress_index"), py::call_guard()) - .def("get_incoming_transfers", [](PyMoneroWallet& self, const monero_transfer_query& query) { + .def("get_incoming_transfers", [](monero_wallet& self, const monero_transfer_query& query) { MONERO_CATCH_AND_RETHROW(get_incoming_transfers(self, query)); }, py::arg("query"), py::call_guard()) - .def("get_incoming_transfers", [](PyMoneroWallet& self) { + .def("get_incoming_transfers", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(get_incoming_transfers(self, monero_transfer_query())); }, py::call_guard()) - .def("get_outgoing_transfers", [](PyMoneroWallet& self, const monero_transfer_query& query) { + .def("get_outgoing_transfers", [](monero_wallet& self, const monero_transfer_query& query) { MONERO_CATCH_AND_RETHROW(get_outgoing_transfers(self, query)); }, py::arg("query"), py::call_guard()) - .def("get_outgoing_transfers", [](PyMoneroWallet& self) { + .def("get_outgoing_transfers", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(get_outgoing_transfers(self, monero_transfer_query())); }, py::call_guard()) - .def("get_outputs", [](PyMoneroWallet& self, const monero_output_query& query) { + .def("get_outputs", [](monero_wallet& self, const monero_output_query& query) { MONERO_CATCH_AND_RETHROW(self.get_outputs(query)); }, py::arg("query"), py::call_guard()) - .def("get_outputs", [](PyMoneroWallet& self) { + .def("get_outputs", [](monero_wallet& self) { monero_output_query query; MONERO_CATCH_AND_RETHROW(self.get_outputs(query)); }, py::call_guard()) - .def("export_outputs", [](PyMoneroWallet& self, bool all) { + .def("export_outputs", [](monero_wallet& self, bool all) { MONERO_CATCH_AND_RETHROW(self.export_outputs(all)); }, py::arg("all") = false, py::call_guard()) - .def("import_outputs", [](PyMoneroWallet& self, const std::string& outputs_hex) { + .def("import_outputs", [](monero_wallet& self, const std::string& outputs_hex) { MONERO_CATCH_AND_RETHROW(self.import_outputs(outputs_hex)); }, py::arg("outputs_hex"), py::call_guard()) - .def("export_key_images", [](PyMoneroWallet& self, bool all) { + .def("export_key_images", [](monero_wallet& self, bool all) { MONERO_CATCH_AND_RETHROW(self.export_key_images(all)); }, py::arg("all") = false, py::call_guard()) - .def("import_key_images", [](PyMoneroWallet& self, const std::vector>& key_images, uint64_t offset) { + .def("import_key_images", [](monero_wallet& self, const std::vector>& key_images, uint64_t offset) { MONERO_CATCH_AND_RETHROW(self.import_key_images(key_images, offset)); }, py::arg("key_images"), py::arg("offset") = 0, py::call_guard()) - .def("get_new_key_images_from_last_import", [](PyMoneroWallet& self) { + .def("get_new_key_images_from_last_import", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.export_key_images(false)); }, py::call_guard()) - .def("freeze_output", [](PyMoneroWallet& self, const std::string& key_image) { + .def("freeze_output", [](monero_wallet& self, const std::string& key_image) { MONERO_CATCH_AND_RETHROW(self.freeze_output(key_image)); }, py::arg("key_image"), py::call_guard()) - .def("thaw_output", [](PyMoneroWallet& self, const std::string& key_image) { + .def("thaw_output", [](monero_wallet& self, const std::string& key_image) { MONERO_CATCH_AND_RETHROW(self.thaw_output(key_image)); }, py::arg("key_image"), py::call_guard()) - .def("is_output_frozen", [](PyMoneroWallet& self, const std::string& key_image) { + .def("is_output_frozen", [](monero_wallet& self, const std::string& key_image) { MONERO_CATCH_AND_RETHROW(self.is_output_frozen(key_image)); }, py::arg("key_image"), py::call_guard()) - .def("get_default_fee_priority", [](PyMoneroWallet& self) { + .def("get_default_fee_priority", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_default_fee_priority()); }, py::call_guard()) - .def("create_tx", [](PyMoneroWallet& self, const monero_tx_config& config) { + .def("create_tx", [](monero_wallet& self, const monero_tx_config& config) { MONERO_CATCH_AND_RETHROW(self.create_tx(config)); }, py::arg("config"), py::call_guard()) - .def("create_txs", [](PyMoneroWallet& self, const monero_tx_config& config) { + .def("create_txs", [](monero_wallet& self, const monero_tx_config& config) { MONERO_CATCH_AND_RETHROW(self.create_txs(config)); }, py::arg("config"), py::call_guard()) - .def("sweep_unlocked", [](PyMoneroWallet& self, const monero_tx_config& config) { + .def("sweep_unlocked", [](monero_wallet& self, const monero_tx_config& config) { MONERO_CATCH_AND_RETHROW(self.sweep_unlocked(config)); }, py::arg("config"), py::call_guard()) - .def("sweep_output", [](PyMoneroWallet& self, const monero_tx_config& config) { + .def("sweep_output", [](monero_wallet& self, const monero_tx_config& config) { MONERO_CATCH_AND_RETHROW(self.sweep_output(config)); }, py::arg("config"), py::call_guard()) - .def("sweep_dust", [](PyMoneroWallet& self, bool relay) { + .def("sweep_dust", [](monero_wallet& self, bool relay) { MONERO_CATCH_AND_RETHROW(self.sweep_dust(relay)); }, py::arg("relay") = false, py::call_guard()) - .def("relay_tx", [](PyMoneroWallet& self, const std::string& tx_metadata) { + .def("relay_tx", [](monero_wallet& self, const std::string& tx_metadata) { MONERO_CATCH_AND_RETHROW(self.relay_tx(tx_metadata)); }, py::arg("tx_metadata"), py::call_guard()) - .def("relay_tx", [](PyMoneroWallet& self, const monero_tx_wallet& tx) { + .def("relay_tx", [](monero_wallet& self, const monero_tx_wallet& tx) { MONERO_CATCH_AND_RETHROW(self.relay_tx(tx)); }, py::arg("tx"), py::call_guard()) - .def("relay_txs", [](PyMoneroWallet& self, const std::vector>& txs) { + .def("relay_txs", [](monero_wallet& self, const std::vector>& txs) { MONERO_CATCH_AND_RETHROW(self.relay_txs(txs)); }, py::arg("txs"), py::call_guard()) - .def("relay_txs", [](PyMoneroWallet& self, const std::vector& tx_metadatas) { + .def("relay_txs", [](monero_wallet& self, const std::vector& tx_metadatas) { MONERO_CATCH_AND_RETHROW(self.relay_txs(tx_metadatas)); }, py::arg("tx_metadatas"), py::call_guard()) - .def("describe_tx_set", [](PyMoneroWallet& self, const monero_tx_set& tx_set) { + .def("describe_tx_set", [](monero_wallet& self, const monero_tx_set& tx_set) { MONERO_CATCH_AND_RETHROW(self.describe_tx_set(tx_set)); }, py::arg("tx_set"), py::call_guard()) - .def("describe_unsigned_tx_set", [](PyMoneroWallet& self, const std::string& unsigned_tx_hex) { + .def("describe_unsigned_tx_set", [](monero_wallet& self, const std::string& unsigned_tx_hex) { monero_tx_set tx_set; tx_set.m_unsigned_tx_hex = unsigned_tx_hex; MONERO_CATCH_AND_RETHROW(self.describe_tx_set(tx_set)); }, py::arg("unsigned_tx_hex"), py::call_guard()) - .def("describe_multisig_tx_set", [](PyMoneroWallet& self, const std::string& multisig_tx_hex) { + .def("describe_multisig_tx_set", [](monero_wallet& self, const std::string& multisig_tx_hex) { monero_tx_set tx_set; tx_set.m_multisig_tx_hex = multisig_tx_hex; MONERO_CATCH_AND_RETHROW(self.describe_tx_set(tx_set)); }, py::arg("multisig_tx_hex"), py::call_guard()) - .def("sign_txs", [](PyMoneroWallet& self, const std::string& unsigned_tx_hex) { + .def("sign_txs", [](monero_wallet& self, const std::string& unsigned_tx_hex) { MONERO_CATCH_AND_RETHROW(self.sign_txs(unsigned_tx_hex)); }, py::arg("unsigned_tx_hex"), py::call_guard()) - .def("submit_txs", [](PyMoneroWallet& self, const std::string& signed_tx_hex) { + .def("submit_txs", [](monero_wallet& self, const std::string& signed_tx_hex) { MONERO_CATCH_AND_RETHROW(self.submit_txs(signed_tx_hex)); }, py::arg("signed_tx_hex"), py::call_guard()) - .def("sign_message", [](PyMoneroWallet& self, const std::string& msg, monero_message_signature_type signature_type, uint32_t account_idx, uint32_t subaddress_idx) { + .def("sign_message", [](monero_wallet& self, const std::string& msg, monero_message_signature_type signature_type, uint32_t account_idx, uint32_t subaddress_idx) { MONERO_CATCH_AND_RETHROW(self.sign_message(msg, signature_type, account_idx, subaddress_idx)); }, py::arg("msg"), py::arg("signature_type"), py::arg("account_idx") = 0, py::arg("subaddress_idx") = 0, py::call_guard()) - .def("verify_message", [](PyMoneroWallet& self, const std::string& msg, const std::string& address, const std::string& signature) { + .def("verify_message", [](monero_wallet& self, const std::string& msg, const std::string& address, const std::string& signature) { try { return self.verify_message(msg, address, signature); } catch (...) { @@ -953,59 +953,59 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { return monero_message_signature_result(); } }, py::arg("msg"), py::arg("address"), py::arg("signature"), py::call_guard()) - .def("get_tx_key", [](PyMoneroWallet& self, const std::string& tx_hash) { + .def("get_tx_key", [](monero_wallet& self, const std::string& tx_hash) { MONERO_CATCH_AND_RETHROW(self.get_tx_key(tx_hash)); }, py::arg("tx_hash"), py::call_guard()) - .def("check_tx_key", [](PyMoneroWallet& self, const std::string& tx_hash, const std::string& tx_key, const std::string& address) { + .def("check_tx_key", [](monero_wallet& self, const std::string& tx_hash, const std::string& tx_key, const std::string& address) { MONERO_CATCH_AND_RETHROW(self.check_tx_key(tx_hash, tx_key, address)); }, py::arg("tx_hash"), py::arg("tx_key"), py::arg("address"), py::call_guard()) - .def("get_tx_proof", [](PyMoneroWallet& self, const std::string& tx_hash, const std::string& address, const std::string& message) { + .def("get_tx_proof", [](monero_wallet& self, const std::string& tx_hash, const std::string& address, const std::string& message) { MONERO_CATCH_AND_RETHROW(self.get_tx_proof(tx_hash, address, message)); }, py::arg("tx_hash"), py::arg("address"), py::arg("message") = "", py::call_guard()) - .def("check_tx_proof", [](PyMoneroWallet& self, const std::string& tx_hash, const std::string& address, const std::string& message, const std::string& signature) { + .def("check_tx_proof", [](monero_wallet& self, const std::string& tx_hash, const std::string& address, const std::string& message, const std::string& signature) { MONERO_CATCH_AND_RETHROW(self.check_tx_proof(tx_hash, address, message, signature)); }, py::arg("tx_hash"), py::arg("address"), py::arg("message"), py::arg("signature"), py::call_guard()) - .def("get_spend_proof", [](PyMoneroWallet& self, const std::string& tx_hash, const std::string& message) { + .def("get_spend_proof", [](monero_wallet& self, const std::string& tx_hash, const std::string& message) { MONERO_CATCH_AND_RETHROW(self.get_spend_proof(tx_hash, message)); }, py::arg("tx_hash"), py::arg("message") = "", py::call_guard()) - .def("check_spend_proof", [](PyMoneroWallet& self, const std::string& tx_hash, const std::string& message, const std::string& signature) { + .def("check_spend_proof", [](monero_wallet& self, const std::string& tx_hash, const std::string& message, const std::string& signature) { MONERO_CATCH_AND_RETHROW(self.check_spend_proof(tx_hash, message, signature)); }, py::arg("tx_hash"), py::arg("message"), py::arg("signature"), py::call_guard()) - .def("get_reserve_proof_wallet", [](PyMoneroWallet& self, const std::string& message) { + .def("get_reserve_proof_wallet", [](monero_wallet& self, const std::string& message) { MONERO_CATCH_AND_RETHROW(self.get_reserve_proof_wallet(message)); }, py::arg("message"), py::call_guard()) - .def("get_reserve_proof_account", [](PyMoneroWallet& self, uint32_t account_idx, uint64_t amount, const std::string& message) { + .def("get_reserve_proof_account", [](monero_wallet& self, uint32_t account_idx, uint64_t amount, const std::string& message) { MONERO_CATCH_AND_RETHROW(self.get_reserve_proof_account(account_idx, amount, message)); }, py::arg("account_idx"), py::arg("amount"), py::arg("message"), py::call_guard()) - .def("check_reserve_proof", [](PyMoneroWallet& self, const std::string& address, const std::string& message, const std::string& signature) { + .def("check_reserve_proof", [](monero_wallet& self, const std::string& address, const std::string& message, const std::string& signature) { MONERO_CATCH_AND_RETHROW(self.check_reserve_proof(address, message, signature)); }, py::arg("address"), py::arg("message"), py::arg("signature"), py::call_guard()) - .def("get_tx_note", [](PyMoneroWallet& self, const std::string& tx_hash) { + .def("get_tx_note", [](monero_wallet& self, const std::string& tx_hash) { MONERO_CATCH_AND_RETHROW(self.get_tx_note(tx_hash)); }, py::arg("tx_hash"), py::call_guard()) - .def("get_tx_notes", [](PyMoneroWallet& self, const std::vector& tx_hashes) { + .def("get_tx_notes", [](monero_wallet& self, const std::vector& tx_hashes) { MONERO_CATCH_AND_RETHROW(self.get_tx_notes(tx_hashes)); }, py::arg("tx_hashes"), py::call_guard()) - .def("set_tx_note", [](PyMoneroWallet& self, const std::string& tx_hash, const std::string& note) { + .def("set_tx_note", [](monero_wallet& self, const std::string& tx_hash, const std::string& note) { MONERO_CATCH_AND_RETHROW(self.set_tx_note(tx_hash, note)); }, py::arg("tx_hash"), py::arg("note"), py::call_guard()) - .def("set_tx_notes", [](PyMoneroWallet& self, const std::vector& tx_hashes, const std::vector& notes) { + .def("set_tx_notes", [](monero_wallet& self, const std::vector& tx_hashes, const std::vector& notes) { MONERO_CATCH_AND_RETHROW(self.set_tx_notes(tx_hashes, notes)); }, py::arg("tx_hashes"), py::arg("notes"), py::call_guard()) - .def("get_address_book_entries", [](PyMoneroWallet& self, const std::vector& indices) { + .def("get_address_book_entries", [](monero_wallet& self, const std::vector& indices) { MONERO_CATCH_AND_RETHROW(self.get_address_book_entries(indices)); }, py::arg("indices"), py::call_guard()) - .def("get_address_book_entries", [](PyMoneroWallet& self) { + .def("get_address_book_entries", [](monero_wallet& self) { std::vector indices; MONERO_CATCH_AND_RETHROW(self.get_address_book_entries(indices)); }, py::call_guard()) - .def("add_address_book_entry", [](PyMoneroWallet& self, const std::string& address, const std::string& description) { + .def("add_address_book_entry", [](monero_wallet& self, const std::string& address, const std::string& description) { MONERO_CATCH_AND_RETHROW(self.add_address_book_entry(address, description)); }, py::arg("address"), py::arg("description"), py::call_guard()) - .def("edit_address_book_entry", [](PyMoneroWallet& self, uint64_t index, bool set_address, const std::string& address, bool set_description, const std::string& description) { + .def("edit_address_book_entry", [](monero_wallet& self, uint64_t index, bool set_address, const std::string& address, bool set_description, const std::string& description) { MONERO_CATCH_AND_RETHROW(self.edit_address_book_entry(index, set_address, address, set_description, description)); }, py::arg("index"), py::arg("set_address"), py::arg("address"), py::arg("set_description"), py::arg("description"), py::call_guard()) - .def("delete_address_book_entry", [](PyMoneroWallet& self, uint64_t index) { + .def("delete_address_book_entry", [](monero_wallet& self, uint64_t index) { MONERO_CATCH_AND_RETHROW(self.delete_address_book_entry(index)); }, py::arg("index"), py::call_guard()) .def("tag_accounts", [](monero_wallet& self, const std::string& tag, const std::vector& account_indices) { @@ -1020,68 +1020,68 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def("set_account_tag_label", [](monero_wallet& self, const std::string& tag, const std::string& label) { MONERO_CATCH_AND_RETHROW(self.set_account_tag_label(tag, label)); }, py::arg("tag"), py::arg("label"), py::call_guard()) - .def("set_account_label", [](PyMoneroWallet& self, uint32_t account_idx, const std::string& label) { + .def("set_account_label", [](monero_wallet& self, uint32_t account_idx, const std::string& label) { MONERO_CATCH_AND_RETHROW(self.set_subaddress_label(account_idx, 0, label)); }, py::arg("account_idx"), py::arg("label"), py::call_guard()) - .def("get_payment_uri", [](PyMoneroWallet& self, const monero_tx_config& config) { + .def("get_payment_uri", [](monero_wallet& self, const monero_tx_config& config) { MONERO_CATCH_AND_RETHROW(self.get_payment_uri(config)); }, py::arg("config"), py::call_guard()) - .def("parse_payment_uri", [](PyMoneroWallet& self, const std::string& uri) { + .def("parse_payment_uri", [](monero_wallet& self, const std::string& uri) { MONERO_CATCH_AND_RETHROW(self.parse_payment_uri(uri)); }, py::arg("uri"), py::call_guard()) - .def("get_attribute", [](PyMoneroWallet& self, const std::string& key) -> std::string { + .def("get_attribute", [](monero_wallet& self, const std::string& key) -> std::string { std::string val; MONERO_CATCH_AND_RETHROW((self.get_attribute(key, val), val)); }, py::arg("key"), py::call_guard()) - .def("set_attribute", [](PyMoneroWallet& self, const std::string& key, const std::string& val) { + .def("set_attribute", [](monero_wallet& self, const std::string& key, const std::string& val) { MONERO_CATCH_AND_RETHROW(self.set_attribute(key, val)); }, py::arg("key"), py::arg("val"), py::call_guard()) - .def("start_mining", [](PyMoneroWallet& self, const boost::optional& num_threads, const boost::optional& background_mining, const boost::optional& ignore_battery) { + .def("start_mining", [](monero_wallet& self, const boost::optional& num_threads, const boost::optional& background_mining, const boost::optional& ignore_battery) { MONERO_CATCH_AND_RETHROW(self.start_mining(num_threads, background_mining, ignore_battery)); }, py::arg("num_threads") = py::none(), py::arg("background_mining") = py::none(), py::arg("ignore_battery") = py::none(), py::call_guard()) - .def("stop_mining", [](PyMoneroWallet& self) { + .def("stop_mining", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.stop_mining()); }, py::call_guard()) - .def("wait_for_next_block", [](PyMoneroWallet& self) { + .def("wait_for_next_block", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.wait_for_next_block()); }, py::call_guard()) - .def("is_multisig_import_needed", [](PyMoneroWallet& self) { + .def("is_multisig_import_needed", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.is_multisig_import_needed()); }, py::call_guard()) - .def("is_multisig", [](PyMoneroWallet& self) { + .def("is_multisig", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.is_multisig()); }, py::call_guard()) - .def("get_multisig_info", [](PyMoneroWallet& self) { + .def("get_multisig_info", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_multisig_info()); }, py::call_guard()) - .def("prepare_multisig", [](PyMoneroWallet& self) { + .def("prepare_multisig", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.prepare_multisig()); }, py::call_guard()) - .def("make_multisig", [](PyMoneroWallet& self, const std::vector& multisig_hexes, int threshold, const std::string& password) { + .def("make_multisig", [](monero_wallet& self, const std::vector& multisig_hexes, int threshold, const std::string& password) { MONERO_CATCH_AND_RETHROW(self.make_multisig(multisig_hexes, threshold, password)); }, py::arg("multisig_hexes"), py::arg("threshold"), py::arg("password"), py::call_guard()) - .def("exchange_multisig_keys", [](PyMoneroWallet& self, const std::vector& multisig_hexes, const std::string& password) { + .def("exchange_multisig_keys", [](monero_wallet& self, const std::vector& multisig_hexes, const std::string& password) { MONERO_CATCH_AND_RETHROW(self.exchange_multisig_keys(multisig_hexes, password)); }, py::arg("multisig_hexes"), py::arg("password"), py::call_guard()) - .def("export_multisig_hex", [](PyMoneroWallet& self) { + .def("export_multisig_hex", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.export_multisig_hex()); }, py::call_guard()) - .def("import_multisig_hex", [](PyMoneroWallet& self, const std::vector& multisig_hexes, bool refresh_after_import) { + .def("import_multisig_hex", [](monero_wallet& self, const std::vector& multisig_hexes, bool refresh_after_import) { MONERO_CATCH_AND_RETHROW(self.import_multisig_hex(multisig_hexes, refresh_after_import)); }, py::arg("multisig_hexes"), py::arg("refresh_after_import") = true, py::call_guard()) - .def("sign_multisig_tx_hex", [](PyMoneroWallet& self, const std::string& multisig_tx_hex) { + .def("sign_multisig_tx_hex", [](monero_wallet& self, const std::string& multisig_tx_hex) { MONERO_CATCH_AND_RETHROW(self.sign_multisig_tx_hex(multisig_tx_hex)); }, py::arg("multisig_tx_hex"), py::call_guard()) - .def("submit_multisig_tx_hex", [](PyMoneroWallet& self, const std::string& signed_multisig_tx_hex) { + .def("submit_multisig_tx_hex", [](monero_wallet& self, const std::string& signed_multisig_tx_hex) { MONERO_CATCH_AND_RETHROW(self.submit_multisig_tx_hex(signed_multisig_tx_hex)); }, py::arg("signed_multisig_tx_hex"), py::call_guard()) - .def("change_password", [](PyMoneroWallet& self, const std::string& old_password, const std::string& new_password) { + .def("change_password", [](monero_wallet& self, const std::string& old_password, const std::string& new_password) { MONERO_CATCH_AND_RETHROW(self.change_password(old_password, new_password)); }, py::arg("old_password"), py::arg("new_password"), py::call_guard()) - .def("move_to", [](PyMoneroWallet& self, const std::string& path, const std::string& password) { + .def("move_to", [](monero_wallet& self, const std::string& path, const std::string& password) { MONERO_CATCH_AND_RETHROW(self.move_to(path, password)); }, py::arg("path"), py::arg("password"), py::call_guard()) - .def("save", [](PyMoneroWallet& self) { + .def("save", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.save()); }, py::call_guard()) .def("close", [](monero_wallet& self, bool save) { @@ -1160,10 +1160,10 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { MONERO_CATCH_AND_RETHROW(self.set_poll_period_in_ms(period_ms)); }, py::arg("period_ms"), py::call_guard()) // this because of function hiding - .def("set_daemon_connection", [](PyMoneroWallet& self, const std::shared_ptr& connection, const boost::optional& is_trusted) { + .def("set_daemon_connection", [](monero_wallet& self, const std::shared_ptr& connection, const boost::optional& is_trusted) { MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(connection, is_trusted)); }, py::arg("connection"), py::arg("is_trusted") = py::none(), py::call_guard()) - .def("set_daemon_connection", [](PyMoneroWallet& self, const std::string& uri, const std::string& username, const std::string& password, const std::string& proxy, const boost::optional& is_trusted) { + .def("set_daemon_connection", [](monero_wallet& self, const std::string& uri, const std::string& username, const std::string& password, const std::string& proxy, const boost::optional& is_trusted) { MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(uri, username, password, proxy, is_trusted)); }, py::arg("uri"), py::arg("username") = "", py::arg("password") = "", py::arg("proxy") = "", py::arg("is_trusted") = py::none(), py::call_guard()) .def("set_daemon_connection", [](monero_wallet_rpc& self, const std::shared_ptr& connection, bool is_trusted, const boost::optional& ssl_options) { From 7a731402c4737430bf4456a292d7cdcbf4501660 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 22:55:07 +0100 Subject: [PATCH 04/19] wallet: add the missing overrides of the wallet trampoline --- src/cpp/wallet/py_monero_wallet.h | 24 ++++++++++ tests/wallet/test_interface.py | 73 ++++++++++++++++++++++++++++++- 2 files changed, 96 insertions(+), 1 deletion(-) diff --git a/src/cpp/wallet/py_monero_wallet.h b/src/cpp/wallet/py_monero_wallet.h index e189099..200e58a 100644 --- a/src/cpp/wallet/py_monero_wallet.h +++ b/src/cpp/wallet/py_monero_wallet.h @@ -202,6 +202,10 @@ class PyMoneroWallet : public monero_wallet { PYBIND11_OVERRIDE(monero_version, monero_wallet, get_version); } + std::string get_path() const override { + PYBIND11_OVERRIDE(std::string, monero_wallet, get_path); + } + monero_network_type get_network_type() const override { PYBIND11_OVERRIDE(monero_network_type, monero_wallet, get_network_type); } @@ -306,6 +310,10 @@ class PyMoneroWallet : public monero_wallet { PYBIND11_OVERRIDE(void, monero_wallet, start_syncing, sync_period_in_ms); } + void stop_syncing() override { + PYBIND11_OVERRIDE(void, monero_wallet, stop_syncing); + } + void scan_txs(const std::vector& tx_hashes) override { PYBIND11_OVERRIDE(void, monero_wallet, scan_txs, tx_hashes); } @@ -370,6 +378,22 @@ class PyMoneroWallet : public monero_wallet { PYBIND11_OVERRIDE(monero_account, monero_wallet, create_account, label); } + void tag_accounts(const std::string& tag, const std::vector& account_indices) override { + PYBIND11_OVERRIDE(void, monero_wallet, tag_accounts, tag, account_indices); + } + + void untag_accounts(const std::vector& account_indices) override { + PYBIND11_OVERRIDE(void, monero_wallet, untag_accounts, account_indices); + } + + std::vector> get_account_tags() const override { + PYBIND11_OVERRIDE(std::vector>, monero_wallet, get_account_tags); + } + + void set_account_tag_label(const std::string& tag, const std::string& label) override { + PYBIND11_OVERRIDE(void, monero_wallet, set_account_tag_label, tag, label); + } + std::vector get_subaddresses(uint32_t account_idx) const override { PYBIND11_OVERRIDE(std::vector, monero_wallet, get_subaddresses, account_idx); } diff --git a/tests/wallet/test_interface.py b/tests/wallet/test_interface.py index c13dacb..89c165d 100644 --- a/tests/wallet/test_interface.py +++ b/tests/wallet/test_interface.py @@ -1,9 +1,12 @@ import pytest import logging +from typing import Optional from typing_extensions import override -from monero import MoneroWallet, MoneroTxWallet, MoneroMessageSignatureResult +from monero import ( + MoneroAccountTag, MoneroError, MoneroMessageSignatureResult, MoneroSubaddress, MoneroTxWallet, MoneroWallet +) from utils import WalletUtils, BaseTestClass, WalletCall, WALLET_CALLS @@ -75,4 +78,72 @@ def import_multisig_hex(self, multisig_hexes: list[str], refresh_after_import: b assert MoneroWallet.import_multisig_hex(wallet, multisig_hexes=["gh"], refresh_after_import=False) == 42 assert forwarded == [False, True, True, False] + # The binding calls the python overrides of the path, the syncing and the account tags + def test_path_syncing_and_account_tags_overrides(self) -> None: + calls: list[tuple[object, ...]] = [] + + class TaggedWallet(MoneroWallet): + @override + def get_path(self) -> str: + return "path" + + @override + def stop_syncing(self) -> None: + calls.append(("stop_syncing",)) + + @override + def tag_accounts(self, tag: str, account_indices: list[int]) -> None: + calls.append(("tag_accounts", tag, list(account_indices))) + + @override + def untag_accounts(self, account_indices: list[int]) -> None: + calls.append(("untag_accounts", list(account_indices))) + + @override + def get_account_tags(self) -> list[MoneroAccountTag]: + return [MoneroAccountTag("tag", "label", [1])] + + @override + def set_account_tag_label(self, tag: str, label: str) -> None: + calls.append(("set_account_tag_label", tag, label)) + + wallet: MoneroWallet = TaggedWallet() + + assert MoneroWallet.get_path(wallet) == "path" + MoneroWallet.stop_syncing(wallet) + MoneroWallet.tag_accounts(wallet, "tag", [0, 1]) + MoneroWallet.untag_accounts(wallet, [1]) + MoneroWallet.set_account_tag_label(wallet, "tag", "label") + tags: list[MoneroAccountTag] = MoneroWallet.get_account_tags(wallet) + + assert [tag.label for tag in tags] == ["label"] + assert calls == [ + ("stop_syncing",), + ("tag_accounts", "tag", [0, 1]), + ("untag_accounts", [1]), + ("set_account_tag_label", "tag", "label") + ] + + # get_subaddress gets the subaddress from the override of get_subaddresses + def test_get_subaddress_uses_get_subaddresses(self) -> None: + class SubaddressWallet(MoneroWallet): + @override + def get_subaddresses(self, account_idx: int, subaddress_indices: Optional[list[int]] = None) -> list[MoneroSubaddress]: + assert subaddress_indices is not None + result: list[MoneroSubaddress] = [] + # the wallet has no subaddress of an index above 0 + if list(subaddress_indices) == [0]: + subaddress: MoneroSubaddress = MoneroSubaddress() + subaddress.account_index = account_idx + subaddress.index = 0 + result.append(subaddress) + return result + + wallet: MoneroWallet = SubaddressWallet() + + assert wallet.get_subaddress(2, 0).account_index == 2 + + with pytest.raises(MoneroError, match="Subaddress is not initialized"): + wallet.get_subaddress(2, 1) + #endregion From fc895abc8103c450620990d88558f08bc4cc32be Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:01:01 +0100 Subject: [PATCH 05/19] wallet: rethrow monero errors in get_tx() --- src/cpp/wallet/py_monero_wallet_bindings.cpp | 16 ++++++++-------- tests/wallet/test_interface.py | 5 +++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp index 6cd5dfa..61c67af 100644 --- a/src/cpp/wallet/py_monero_wallet_bindings.cpp +++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp @@ -81,6 +81,13 @@ static std::vector> get_outgoing_trans return transfers; } +static std::shared_ptr get_tx(const monero_wallet& wallet, const std::string& tx_hash) { + monero_tx_query query; + query.m_hashes.push_back(tx_hash); + std::vector> txs = wallet.get_txs(query); + return txs.empty() ? nullptr : txs[0]; +} + void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { // monero_wallet_config t.py_monero_wallet_config @@ -812,14 +819,7 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { MONERO_CATCH_AND_RETHROW(self.set_subaddress_label(account_idx, subaddress_idx, label)); }, py::arg("account_idx"), py::arg("subaddress_idx"), py::arg("label") = "", py::call_guard()) .def("get_tx", [](monero_wallet& self, const std::string& tx_hash) { - std::shared_ptr result = nullptr; - monero_tx_query query; - query.m_hashes.push_back(tx_hash); - auto txs = self.get_txs(query); - if (txs.size() > 0) { - result = txs[0]; - } - return result; + MONERO_CATCH_AND_RETHROW(get_tx(self, tx_hash)); }, py::arg("tx_hash"), py::call_guard()) .def("get_txs", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_txs()); diff --git a/tests/wallet/test_interface.py b/tests/wallet/test_interface.py index 89c165d..5fb0cda 100644 --- a/tests/wallet/test_interface.py +++ b/tests/wallet/test_interface.py @@ -55,6 +55,11 @@ def test_relay_txs_empty_metadata_raises(self, wallet: MoneroWallet) -> None: wallet.relay_txs([tx]) assert str(exc_info.value) == "Tx metadata is not initialized" + # get_tx raises the errors of the wallet as monero errors, as the other methods do + def test_get_tx_raises_monero_error(self, wallet: MoneroWallet) -> None: + with pytest.raises(MoneroError, match="not supported"): + wallet.get_tx("") + def test_verify_message(self, wallet: MoneroWallet) -> None: result: MoneroMessageSignatureResult = wallet.verify_message("", "", "") WalletUtils.test_message_signature_result(result, False) From f6d763a659c72530b36ba54ce882f64651a4c602 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:01:01 +0100 Subject: [PATCH 06/19] docs: fix the return type of get_new_key_images_from_last_import() --- src/monero/monero_wallet.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monero/monero_wallet.pyi b/src/monero/monero_wallet.pyi index ba0c949..fc04b9c 100644 --- a/src/monero/monero_wallet.pyi +++ b/src/monero/monero_wallet.pyi @@ -480,7 +480,7 @@ class MoneroWallet: """ Get new key images from the last imported outputs. - :returns list[MoneroKeyImage]: the key images from the last imported outputs. + :returns MoneroKeyImageExportResult: the key images from the last imported outputs. """ ... @typing.overload From c7401c1e5c74ffd31f9dd49fc6ddab56e3a19c2c Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:15:06 +0100 Subject: [PATCH 07/19] daemon: register the trampoline of MoneroDaemon for python subclasses --- src/cpp/daemon/py_monero_daemon.h | 4 +++ src/cpp/py_monero_types.h | 2 +- tests/daemon/test_interface.py | 59 ++++++++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/cpp/daemon/py_monero_daemon.h b/src/cpp/daemon/py_monero_daemon.h index e8491b9..a4a5cbc 100644 --- a/src/cpp/daemon/py_monero_daemon.h +++ b/src/cpp/daemon/py_monero_daemon.h @@ -381,6 +381,10 @@ class PyMoneroDaemon : public monero_daemon { PYBIND11_OVERRIDE(void, monero_daemon, set_bootstrap_daemon, address, username, password, proxy); } + void remove_bootstrap_daemon() override { + PYBIND11_OVERRIDE(void, monero_daemon, remove_bootstrap_daemon); + } + void set_log_hash_rate(bool is_visible) override { PYBIND11_OVERRIDE(void, monero_daemon, set_log_hash_rate, is_visible); } diff --git a/src/cpp/py_monero_types.h b/src/cpp/py_monero_types.h index 92ef271..9a41136 100644 --- a/src/cpp/py_monero_types.h +++ b/src/cpp/py_monero_types.h @@ -171,7 +171,7 @@ struct PyMoneroTypes { py::class_> py_monero_address_book_entry; py::class_> py_monero_wallet_listener; py::class_> py_monero_daemon_listener; - py::class_> py_monero_daemon; + py::class_> py_monero_daemon; py::class_> py_monero_daemon_rpc; py::class_> py_monero_wallet; py::class_> py_monero_wallet_keys; diff --git a/tests/daemon/test_interface.py b/tests/daemon/test_interface.py index eab8c29..14bb40e 100644 --- a/tests/daemon/test_interface.py +++ b/tests/daemon/test_interface.py @@ -1,7 +1,9 @@ import pytest import logging -from monero import MoneroDaemon, MoneroBan, MoneroDaemonListener +from typing_extensions import override + +from monero import MoneroBan, MoneroBlockHeader, MoneroDaemon, MoneroDaemonListener from utils import BaseTestClass logger: logging.Logger = logging.getLogger("TestMoneroDaemonInterface") @@ -20,6 +22,61 @@ def daemon(cls) -> MoneroDaemon: #region Tests + # The binding calls the python overrides of a daemon through the trampoline + def test_overrides(self) -> None: + listener: MoneroDaemonListener = MoneroDaemonListener() + added: list[MoneroDaemonListener] = [] + + class CustomDaemon(MoneroDaemon): + @override + def get_height(self) -> int: + return 42 + + @override + def add_listener(self, listener: MoneroDaemonListener) -> None: + added.append(listener) + + @override + def get_listeners(self) -> set[MoneroDaemonListener]: + return set(added) + + @override + def get_block_headers_by_range(self, start_height: int, end_height: int) -> list[MoneroBlockHeader]: + header: MoneroBlockHeader = MoneroBlockHeader() + header.height = start_height + return [header] + + daemon: MoneroDaemon = CustomDaemon() + + assert MoneroDaemon.get_height(daemon) == 42 + MoneroDaemon.add_listener(daemon, listener) + # the override gets the listener of the caller, not a copy of it + assert len(added) == 1 and added[0] is listener + assert MoneroDaemon.get_listeners(daemon) == {listener} + headers: list[MoneroBlockHeader] = MoneroDaemon.get_block_headers_by_range(daemon, 7, 8) + assert [header.height for header in headers] == [7] + + # remove_bootstrap_daemon disables the bootstrap daemon through the override of set_bootstrap_daemon, or calls its own + def test_remove_bootstrap_daemon_overrides(self) -> None: + addresses: list[str] = [] + removed: list[bool] = [] + + class SettingDaemon(MoneroDaemon): + @override + def set_bootstrap_daemon(self, address: str, username: str = "", password: str = "", proxy: str = "") -> None: + addresses.append(address) + + class RemovingDaemon(MoneroDaemon): + @override + def remove_bootstrap_daemon(self) -> None: + removed.append(True) + + MoneroDaemon.remove_bootstrap_daemon(SettingDaemon()) + MoneroDaemon.remove_bootstrap_daemon(RemovingDaemon()) + + assert addresses == [""] + assert removed == [True] + # Test interface calls @pytest.mark.not_supported From 8b4acfa7a084a27302dcd259eee329247098a174 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:17:49 +0100 Subject: [PATCH 08/19] wallet: accept a 64 bit num_blocks_fetched in the constructor of MoneroSyncResult --- src/cpp/wallet/py_monero_wallet_bindings.cpp | 2 +- tests/wallet/test_interface.py | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp index 61c67af..c524706 100644 --- a/src/cpp/wallet/py_monero_wallet_bindings.cpp +++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp @@ -139,7 +139,7 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { // monero_sync_result t.py_monero_sync_result .def(py::init<>()) - .def(py::init(), py::arg("num_blocks_fetched"), py::arg("received_money")) + .def(py::init(), py::arg("num_blocks_fetched"), py::arg("received_money")) .def_static("deserialize", [](const std::string& json) { MONERO_CATCH_AND_RETHROW(monero_sync_result::deserialize(json)); }, py::arg("json")) diff --git a/tests/wallet/test_interface.py b/tests/wallet/test_interface.py index 5fb0cda..e9802f5 100644 --- a/tests/wallet/test_interface.py +++ b/tests/wallet/test_interface.py @@ -5,7 +5,8 @@ from typing_extensions import override from monero import ( - MoneroAccountTag, MoneroError, MoneroMessageSignatureResult, MoneroSubaddress, MoneroTxWallet, MoneroWallet + MoneroAccountTag, MoneroError, MoneroMessageSignatureResult, MoneroSubaddress, MoneroSyncResult, + MoneroTxWallet, MoneroWallet ) from utils import WalletUtils, BaseTestClass, WalletCall, WALLET_CALLS @@ -64,6 +65,12 @@ def test_verify_message(self, wallet: MoneroWallet) -> None: result: MoneroMessageSignatureResult = wallet.verify_message("", "", "") WalletUtils.test_message_signature_result(result, False) + # The number of fetched blocks of a sync result is not limited to 16 bits + def test_sync_result_num_blocks_fetched(self) -> None: + result: MoneroSyncResult = MoneroSyncResult(100000, True) + assert result.num_blocks_fetched == 100000 + assert result.received_money is True + # A python override of import_multisig_hex gets the refresh flag of the caller def test_import_multisig_hex_forwards_refresh_after_import(self) -> None: forwarded: list[bool] = [] From 7af3f823656fe0226391bd7290cb7347070294fb Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:17:49 +0100 Subject: [PATCH 09/19] docs: fix the return type of export_key_images() --- src/monero/monero_wallet.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monero/monero_wallet.pyi b/src/monero/monero_wallet.pyi index fc04b9c..e61f8f6 100644 --- a/src/monero/monero_wallet.pyi +++ b/src/monero/monero_wallet.pyi @@ -221,7 +221,7 @@ class MoneroWallet: Export signed key images. :param bool all: export all key images if `True`, else export key images since the last export. - :returns MoneroKeyImageResult: the wallet's signed key images. + :returns MoneroKeyImageExportResult: the wallet's signed key images. """ ... def export_multisig_hex(self) -> str: From 5f510c255471a0a56f8ab07d09c3f9e77e5fbbdd Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:17:49 +0100 Subject: [PATCH 10/19] utils: remove the unused regex include --- src/cpp/utils/py_monero_utils.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cpp/utils/py_monero_utils.cpp b/src/cpp/utils/py_monero_utils.cpp index 4c32443..016a944 100644 --- a/src/cpp/utils/py_monero_utils.cpp +++ b/src/cpp/utils/py_monero_utils.cpp @@ -51,7 +51,6 @@ * * Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers */ -#include #include "cryptonote_basic/cryptonote_format_utils.h" #include "py_monero_utils.h" From ed047a4631cf55521cac42b845cbf1171fb9da3a Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:18:02 +0100 Subject: [PATCH 11/19] bindings: remove the redundant catch of monero_rpc_error --- src/cpp/py_monero_types.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/cpp/py_monero_types.h b/src/cpp/py_monero_types.h index 9a41136..3f4c82f 100644 --- a/src/cpp/py_monero_types.h +++ b/src/cpp/py_monero_types.h @@ -103,12 +103,9 @@ std::shared_ptr make_gil_free_holder(T* ptr) { #define MONERO_CATCH_AND_RETHROW(expr) \ try { \ return expr; \ - } catch (const monero_rpc_error& e) { \ + } catch (const monero_error&) { \ throw; \ - } catch (const monero_error& e) { \ - throw; \ - } \ - catch (const std::exception& e) { \ + } catch (const std::exception& e) { \ throw monero_error(e.what()); \ } From 4fe854f023145ba329edfa3eeddc41ee57e7f055 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:18:13 +0100 Subject: [PATCH 12/19] wallet: define the overloads of set_daemon_connection() of MoneroWalletRpc once --- src/cpp/wallet/py_monero_wallet_bindings.cpp | 28 +++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp index c524706..3c16982 100644 --- a/src/cpp/wallet/py_monero_wallet_bindings.cpp +++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp @@ -88,6 +88,19 @@ static std::shared_ptr get_tx(const monero_wallet& wallet, con return txs.empty() ? nullptr : txs[0]; } +// the overloads of set_daemon_connection() of the interface. A class that adds one of its own has to define them too, because its +// attribute hides the one of its base +template +static void def_set_daemon_connection(PyClass& cls) { + cls + .def("set_daemon_connection", [](monero_wallet& self, const std::shared_ptr& connection, const boost::optional& is_trusted) { + MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(connection, is_trusted)); + }, py::arg("connection"), py::arg("is_trusted") = py::none(), py::call_guard()) + .def("set_daemon_connection", [](monero_wallet& self, const std::string& uri, const std::string& username, const std::string& password, const std::string& proxy, const boost::optional& is_trusted) { + MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(uri, username, password, proxy, is_trusted)); + }, py::arg("uri"), py::arg("username") = "", py::arg("password") = "", py::arg("proxy") = "", py::arg("is_trusted") = py::none(), py::call_guard()); +} + void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { // monero_wallet_config t.py_monero_wallet_config @@ -641,18 +654,13 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }, py::arg("output")); // monero_wallet + def_set_daemon_connection(t.py_monero_wallet); t.py_monero_wallet .def(py::init<>()) .def_property_readonly_static("DEFAULT_LANGUAGE", [](py::object /* self */) { return std::string("English"); }) .def("is_view_only", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.is_view_only()); }, py::call_guard()) - .def("set_daemon_connection", [](monero_wallet& self, const std::shared_ptr& connection, const boost::optional& is_trusted) { - MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(connection, is_trusted)); - }, py::arg("connection"), py::arg("is_trusted") = py::none(), py::call_guard()) - .def("set_daemon_connection", [](monero_wallet& self, const std::string& uri, const std::string& username, const std::string& password, const std::string& proxy, const boost::optional& is_trusted) { - MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(uri, username, password, proxy, is_trusted)); - }, py::arg("uri"), py::arg("username") = "", py::arg("password") = "", py::arg("proxy") = "", py::arg("is_trusted") = py::none(), py::call_guard()) .def("get_daemon_connection", [](monero_wallet& self) { MONERO_CATCH_AND_RETHROW(self.get_daemon_connection()); }, py::call_guard()) @@ -1134,6 +1142,7 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { }); // monero_wallet_rpc + def_set_daemon_connection(t.py_monero_wallet_rpc); t.py_monero_wallet_rpc .def(py::init([](const std::shared_ptr& rpc_connection) { return make_gil_free_holder(new monero_wallet_rpc(rpc_connection)); @@ -1159,13 +1168,6 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def("set_poll_period_in_ms", [](monero_wallet_rpc& self, uint64_t period_ms) { MONERO_CATCH_AND_RETHROW(self.set_poll_period_in_ms(period_ms)); }, py::arg("period_ms"), py::call_guard()) - // this because of function hiding - .def("set_daemon_connection", [](monero_wallet& self, const std::shared_ptr& connection, const boost::optional& is_trusted) { - MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(connection, is_trusted)); - }, py::arg("connection"), py::arg("is_trusted") = py::none(), py::call_guard()) - .def("set_daemon_connection", [](monero_wallet& self, const std::string& uri, const std::string& username, const std::string& password, const std::string& proxy, const boost::optional& is_trusted) { - MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(uri, username, password, proxy, is_trusted)); - }, py::arg("uri"), py::arg("username") = "", py::arg("password") = "", py::arg("proxy") = "", py::arg("is_trusted") = py::none(), py::call_guard()) .def("set_daemon_connection", [](monero_wallet_rpc& self, const std::shared_ptr& connection, bool is_trusted, const boost::optional& ssl_options) { MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(connection, is_trusted, ssl_options)); }, py::arg("connection"), py::arg("is_trusted"), py::arg("ssl_options"), py::call_guard()) From 197782e32782f72c81dd01a465028193e5e4fb87 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:43:51 +0100 Subject: [PATCH 13/19] wallet full: release the GIL while getting the keys and cache file buffers --- src/cpp/wallet/py_monero_wallet_bindings.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/cpp/wallet/py_monero_wallet_bindings.cpp b/src/cpp/wallet/py_monero_wallet_bindings.cpp index 3c16982..8c10354 100644 --- a/src/cpp/wallet/py_monero_wallet_bindings.cpp +++ b/src/cpp/wallet/py_monero_wallet_bindings.cpp @@ -101,6 +101,13 @@ static void def_set_daemon_connection(PyClass& cls) { }, py::arg("uri"), py::arg("username") = "", py::arg("password") = "", py::arg("proxy") = "", py::arg("is_trusted") = py::none(), py::call_guard()); } +// runs a call without the GIL, which is taken again before the caller makes a python object of the result +template +static auto call_without_gil(const Call& call) -> decltype(call()) { + py::gil_scoped_release release; + return call(); +} + void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { // monero_wallet_config t.py_monero_wallet_config @@ -1134,11 +1141,12 @@ void py_monero_bind_wallet(py::module_& m, PyMoneroTypes& t) { .def_static("get_default_ringdb_path", [](monero_network_type nettype) { MONERO_CATCH_AND_RETHROW(get_default_ringdb_path(static_cast(nettype))); }, py::arg("nettype")) - .def("get_keys_file_buffer", [](monero_wallet_full& self, std::string& password, bool view_only) -> py::bytes { - MONERO_CATCH_AND_RETHROW(py::bytes(self.get_keys_file_buffer(password, view_only))); + // the buffers wait for the sync, whose thread takes the GIL to notify the python listeners + .def("get_keys_file_buffer", [](monero_wallet_full& self, const std::string& password, bool view_only) -> py::bytes { + MONERO_CATCH_AND_RETHROW(py::bytes(call_without_gil([&] { return self.get_keys_file_buffer(password, view_only); }))); }, py::arg("password"), py::arg("view_only")) .def("get_cache_file_buffer", [](monero_wallet_full& self) -> py::bytes { - MONERO_CATCH_AND_RETHROW(py::bytes(self.get_cache_file_buffer())); + MONERO_CATCH_AND_RETHROW(py::bytes(call_without_gil([&] { return self.get_cache_file_buffer(); }))); }); // monero_wallet_rpc From 8728adc7f722ca023c8a502cbe88e55940816faf Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:43:51 +0100 Subject: [PATCH 14/19] docs: type the listeners of get_listeners() as a set --- docs/monero-spec.drawio | 4 ++-- src/monero/monero_daemon.pyi | 4 ++-- src/monero/monero_wallet.pyi | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/monero-spec.drawio b/docs/monero-spec.drawio index 7c62a4e..7e82b41 100644 --- a/docs/monero-spec.drawio +++ b/docs/monero-spec.drawio @@ -845,7 +845,7 @@ - + @@ -2219,7 +2219,7 @@ - + diff --git a/src/monero/monero_daemon.pyi b/src/monero/monero_daemon.pyi index 7dd75de..a03c3e9 100644 --- a/src/monero/monero_daemon.pyi +++ b/src/monero/monero_daemon.pyi @@ -338,11 +338,11 @@ class MoneroDaemon: """ ... - def get_listeners(self) -> list[MoneroDaemonListener]: + def get_listeners(self) -> set[MoneroDaemonListener]: """ Get the listeners registered with the daemon. - :returns list[MoneroDaemonListener]: the registered listeners. + :returns set[MoneroDaemonListener]: the registered listeners. """ ... diff --git a/src/monero/monero_wallet.pyi b/src/monero/monero_wallet.pyi index e61f8f6..fe3a647 100644 --- a/src/monero/monero_wallet.pyi +++ b/src/monero/monero_wallet.pyi @@ -455,11 +455,11 @@ class MoneroWallet: :returns MoneroIntegratedAddress: the integrated address. """ ... - def get_listeners(self) -> list[MoneroWalletListener]: + def get_listeners(self) -> set[MoneroWalletListener]: """ Get the listeners registered with the wallet. - :returns list[MoneroWalletListener]: List of listener registered with the wallet. + :returns set[MoneroWalletListener]: the listeners registered with the wallet. """ ... def get_multisig_info(self) -> MoneroMultisigInfo: From fec91e70a8585efe2149a7e0763343ff11379f60 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:43:51 +0100 Subject: [PATCH 15/19] docs: type the wallet that create_wallet() and open_wallet() of MoneroWalletRpc return --- src/monero/monero_wallet_rpc.pyi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/monero/monero_wallet_rpc.pyi b/src/monero/monero_wallet_rpc.pyi index 6c90341..5508b29 100644 --- a/src/monero/monero_wallet_rpc.pyi +++ b/src/monero/monero_wallet_rpc.pyi @@ -41,11 +41,12 @@ class MoneroWalletRpc(MoneroWallet): """ ... - def create_wallet(self, config: MoneroWalletConfig) -> None: + def create_wallet(self, config: MoneroWalletConfig) -> MoneroWalletRpc: """ Create and open a wallet on the monero-wallet-rpc server. :param MoneroWalletConfig config: configures the wallet to create. + :returns MoneroWalletRpc: this wallet. """ ... @@ -58,21 +59,23 @@ class MoneroWalletRpc(MoneroWallet): ... @typing.overload - def open_wallet(self, config: MoneroWalletConfig) -> None: + def open_wallet(self, config: MoneroWalletConfig) -> MoneroWalletRpc: """ Open an existing wallet on the monero-wallet-rpc server. :param MoneroWalletConfig config: configures the wallet to open. + :returns MoneroWalletRpc: this wallet. """ ... @typing.overload - def open_wallet(self, name: str, password: str) -> None: + def open_wallet(self, name: str, password: str) -> MoneroWalletRpc: """ Open an existing wallet on the monero-wallet-rpc server. :param str name: is the name of the wallet file to open. :param str password: is the wallet's password. + :returns MoneroWalletRpc: this wallet. """ ... From 2a526a5df09f93b2cc3403a48ee68b1f85a66f29 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:43:51 +0100 Subject: [PATCH 16/19] docs: add the inherited overloads of set_daemon_connection() to MoneroWalletRpc --- src/monero/monero_wallet_rpc.pyi | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/monero/monero_wallet_rpc.pyi b/src/monero/monero_wallet_rpc.pyi index 5508b29..54faaa5 100644 --- a/src/monero/monero_wallet_rpc.pyi +++ b/src/monero/monero_wallet_rpc.pyi @@ -100,7 +100,28 @@ class MoneroWalletRpc(MoneroWallet): ... @typing.overload - def set_daemon_connection(self, connection: MoneroRpcConnection | None, is_trusted: bool, ssl_options: SslOptions | None) -> None: # type: ignore + def set_daemon_connection(self, connection: MoneroRpcConnection | None, is_trusted: bool | None = None) -> None: + """ + Set the wallet's daemon connection. + + :param MoneroRpcConnection|None connection: is the connection to set. + :param bool|None is_trusted: indicates if daemon connection is trusted. + """ + ... + @typing.overload + def set_daemon_connection(self, uri: str, username: str = '', password: str = '', proxy_uri: str = '', is_trusted: bool | None = None) -> None: + """ + Set the wallet's daemon connection. + + :param str uri: is the connection to set. + :param str username: is the username to authenticate with the daemon (optional). + :param str password: is the password to authenticate with the daemon (optional). + :param str proxy_uri: proxy for the connection (optional). + :param bool|None is_trusted: indicates if daemon connection is trusted. + """ + ... + @typing.overload + def set_daemon_connection(self, connection: MoneroRpcConnection | None, is_trusted: bool, ssl_options: SslOptions | None) -> None: """ Set daemon connection. From 286a1322762c77701280244d19945b393e4aaed3 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sat, 28 Nov 2026 23:43:51 +0100 Subject: [PATCH 17/19] tests: validate the public keys as public keys --- tests/wallet/test_keys_and_addresses.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/wallet/test_keys_and_addresses.py b/tests/wallet/test_keys_and_addresses.py index 6639085..04a862a 100644 --- a/tests/wallet/test_keys_and_addresses.py +++ b/tests/wallet/test_keys_and_addresses.py @@ -65,13 +65,13 @@ def test_get_private_spend_key(self, wallet: MoneroWallet) -> None: @pytest.mark.skipif(TestUtils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled") def test_get_public_view_key(self, wallet: MoneroWallet) -> None: public_view_key: str = wallet.get_public_view_key() - MoneroUtils.validate_private_spend_key(public_view_key) + MoneroUtils.validate_public_view_key(public_view_key) # Can get the public spend key @pytest.mark.skipif(TestUtils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled") def test_get_public_spend_key(self, wallet: MoneroWallet) -> None: public_spend_key: str = wallet.get_public_spend_key() - MoneroUtils.validate_private_spend_key(public_spend_key) + MoneroUtils.validate_public_spend_key(public_spend_key) # Can get the primary address @pytest.mark.skipif(TestUtils.TEST_NON_RELAYS is False, reason="TEST_NON_RELAYS disabled") From 034507cab9578f338e4c90619495b2110e019e40 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sun, 29 Nov 2026 01:31:32 +0100 Subject: [PATCH 18/19] docs: type merge() with the class that it accepts --- src/monero/monero_block.pyi | 13 +------------ src/monero/monero_incoming_transfer.pyi | 12 +----------- src/monero/monero_outgoing_transfer.pyi | 12 +----------- src/monero/monero_output_wallet.pyi | 12 +----------- src/monero/monero_tx_wallet.pyi | 11 +---------- 5 files changed, 5 insertions(+), 55 deletions(-) diff --git a/src/monero/monero_block.pyi b/src/monero/monero_block.pyi index c354564..20d5085 100644 --- a/src/monero/monero_block.pyi +++ b/src/monero/monero_block.pyi @@ -39,8 +39,7 @@ class MoneroBlock(MoneroBlockHeader): """ ... - @typing.overload - def merge(self, other: MoneroBlock) -> None: + def merge(self, other: MoneroBlock) -> None: # type: ignore[override] """ Merge current block with another one. @@ -48,13 +47,3 @@ class MoneroBlock(MoneroBlockHeader): :raises Exception: on reconciliation error. """ ... - - @typing.overload - def merge(self, other: MoneroBlockHeader) -> None: - """ - Merge current block with another block header. - - :param MoneroBlockHeader other: block header to merge with. - :raises Exception: on reconciliation error. - """ - ... diff --git a/src/monero/monero_incoming_transfer.pyi b/src/monero/monero_incoming_transfer.pyi index 9f8cf86..c1eeccd 100644 --- a/src/monero/monero_incoming_transfer.pyi +++ b/src/monero/monero_incoming_transfer.pyi @@ -36,8 +36,7 @@ class MoneroIncomingTransfer(MoneroTransfer): """ ... - @typing.overload - def merge(self, other: MoneroIncomingTransfer) -> None: + def merge(self, other: MoneroIncomingTransfer) -> None: # type: ignore[override] """ Merge current incoming transfer with another one. @@ -45,15 +44,6 @@ class MoneroIncomingTransfer(MoneroTransfer): """ ... - @typing.overload - def merge(self, other: MoneroTransfer) -> None: - """ - Merge current incoming transfer with another transfer. - - :param MoneroTransfer other: other transfer to merge with. - """ - ... - def __lt__(self, other: MoneroIncomingTransfer) -> bool: """ Compare this incoming transfer to another by ascending tx height, diff --git a/src/monero/monero_outgoing_transfer.pyi b/src/monero/monero_outgoing_transfer.pyi index 4210d81..657bbaf 100644 --- a/src/monero/monero_outgoing_transfer.pyi +++ b/src/monero/monero_outgoing_transfer.pyi @@ -37,20 +37,10 @@ class MoneroOutgoingTransfer(MoneroTransfer): """ ... - @typing.overload - def merge(self, other: MoneroOutgoingTransfer) -> None: + def merge(self, other: MoneroOutgoingTransfer) -> None: # type: ignore[override] """ Merge current outgoing transfer with another one. :param MoneroOutgoingTransfer other: other outgoing transfer to merge with. """ ... - - @typing.overload - def merge(self, other: MoneroTransfer) -> None: - """ - Merge current outgoing transfer with another transfer. - - :param MoneroOutgoingTransfer other: other transfer to merge with. - """ - ... diff --git a/src/monero/monero_output_wallet.pyi b/src/monero/monero_output_wallet.pyi index 30f6acb..2fdf929 100644 --- a/src/monero/monero_output_wallet.pyi +++ b/src/monero/monero_output_wallet.pyi @@ -39,8 +39,7 @@ class MoneroOutputWallet(MoneroOutput): """ ... - @typing.overload - def merge(self, other: MoneroOutputWallet) -> None: + def merge(self, other: MoneroOutputWallet) -> None: # type: ignore[override] """ Merge current output wallet with another one. @@ -48,15 +47,6 @@ class MoneroOutputWallet(MoneroOutput): """ ... - @typing.overload - def merge(self, other: MoneroOutput) -> None: - """ - Merge current output wallet with another output. - - :param MoneroOutput other: other output to merge with. - """ - ... - def __lt__(self, other: MoneroOutputWallet) -> bool: """ Compare this output to another by ascending tx height, then account diff --git a/src/monero/monero_tx_wallet.pyi b/src/monero/monero_tx_wallet.pyi index 6b58932..3d7f41d 100644 --- a/src/monero/monero_tx_wallet.pyi +++ b/src/monero/monero_tx_wallet.pyi @@ -148,19 +148,10 @@ class MoneroTxWallet(MoneroTx): :returns int: total amount spent in current wallet tx. """ ... - @typing.overload - def merge(self, tgt: MoneroTxWallet) -> None: + def merge(self, tgt: MoneroTxWallet) -> None: # type: ignore[override] """ Merge current wallet tx with another one. :param MoneroTxWallet tgt: another wallet tx to merge with. """ ... - @typing.overload - def merge(self, tgt: MoneroTx) -> None: # type: ignore - """ - Merge current wallet tx with another tx. - - :param MoneroTx tgt: another tx to merge with. - """ - ... From 6034ea935a18bdd87131624c124dcf3d0a35940d Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Sun, 29 Nov 2026 01:32:35 +0100 Subject: [PATCH 19/19] docs: accept None in the arguments of MoneroDaemon.start_mining() --- docs/monero-spec.drawio | 2 +- src/monero/monero_daemon.pyi | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/monero-spec.drawio b/docs/monero-spec.drawio index 7e82b41..f2f5270 100644 --- a/docs/monero-spec.drawio +++ b/docs/monero-spec.drawio @@ -2189,7 +2189,7 @@ - + diff --git a/src/monero/monero_daemon.pyi b/src/monero/monero_daemon.pyi index a03c3e9..48172ac 100644 --- a/src/monero/monero_daemon.pyi +++ b/src/monero/monero_daemon.pyi @@ -755,14 +755,14 @@ class MoneroDaemon: """ ... - def start_mining(self, address: str, num_threads: int, is_background: bool, ignore_battery: bool) -> None: + def start_mining(self, address: str, num_threads: int | None, is_background: bool | None, ignore_battery: bool | None) -> None: """ Start mining. :param str address: is the address given miner rewards if the daemon mines a block. - :param int num_threads: is the number of mining threads to run. - :param bool is_background: specifies if the miner should run in the background or not. - :param bool ignore_battery: specifies if the battery state (e.g. on laptop) should be ignored or not. + :param int|None num_threads: is the number of mining threads to run. + :param bool|None is_background: specifies if the miner should run in the background or not. + :param bool|None ignore_battery: specifies if the battery state (e.g. on laptop) should be ignored or not. """ ...