Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Python library for using Monero

A Python library for creating Monero applications using RPC and Python bindings to [monero v0.18.4.0 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.4.0).
A Python library for creating Monero applications using RPC and Python bindings to [monero v0.18.4.3 'Fluorine Fermi'](https://github.com/monero-project/monero/tree/v0.18.4.3).

* Supports wallet and daemon RPC clients.
* Supports client-side wallets using Python bindings.
Expand Down
10 changes: 6 additions & 4 deletions src/cpp/daemon/py_monero_daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,6 @@ class PyMoneroIsKeyImageSpentParams : public PyMoneroRequestParams {
class PyMoneroRpcConnection : public monero_rpc_connection {
public:
boost::optional<std::string> m_zmq_uri;
boost::optional<std::string> m_proxy;
int m_priority;
uint64_t m_timeout;
boost::optional<long> m_response_time;
Expand All @@ -1693,13 +1692,14 @@ class PyMoneroRpcConnection : public monero_rpc_connection {
}
}

PyMoneroRpcConnection(const std::string& uri = "", const std::string& username = "", const std::string& password = "", const std::string& zmq_uri = "", int priority = 0, uint64_t timeout = 0) {
PyMoneroRpcConnection(const std::string& uri = "", const std::string& username = "", const std::string& password = "", const std::string& proxy_uri, const std::string& zmq_uri = "", int priority = 0, uint64_t timeout = 0) {
m_uri = uri;
m_username = username;
m_password = password;
m_zmq_uri = zmq_uri;
m_priority = priority;
m_timeout = timeout;
m_proxy_uri = proxy_uri;
auto factory = new net::http::client_factory();
m_http_client = factory->create();
}
Expand All @@ -1711,6 +1711,7 @@ class PyMoneroRpcConnection : public monero_rpc_connection {
m_zmq_uri = rpc.m_zmq_uri;
m_priority = rpc.m_priority;
m_timeout = rpc.m_timeout;
m_proxy_uri = rpc.m_proxy_uri;
auto factory = new net::http::client_factory();
m_http_client = factory->create();
}
Expand All @@ -1719,6 +1720,7 @@ class PyMoneroRpcConnection : public monero_rpc_connection {
m_uri = rpc.m_uri;
m_username = rpc.m_username;
m_password = rpc.m_password;
m_proxy_uri = rpc.m_proxy_uri;
m_zmq_uri = "";
m_priority = 0;
m_timeout = 500;
Expand Down Expand Up @@ -1790,8 +1792,8 @@ class PyMoneroRpcConnection : public monero_rpc_connection {
m_http_client->disconnect();
}

if (m_proxy != boost::none) {
if(!m_http_client->set_proxy(m_proxy.get())) {
if (m_proxy_uri != boost::none) {
if(!m_http_client->set_proxy(m_proxy_uri.get())) {
throw std::runtime_error("Could not set proxy");
}
}
Expand Down
17 changes: 4 additions & 13 deletions src/cpp/py_monero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,7 @@ PYBIND11_MODULE(monero, m) {
.def_readwrite("uri", &PyMoneroRpcConnection::m_uri)
.def_readwrite("username", &PyMoneroRpcConnection::m_username)
.def_readwrite("password", &PyMoneroRpcConnection::m_password)
.def_property("proxy",
[](const PyMoneroRpcConnection& self) { return self.m_proxy; },
[](PyMoneroRpcConnection& self, std::optional<std::string> val) {
if (val.has_value()) self.m_proxy = val.value();
else self.m_proxy = boost::none;
})
.def_readwrite("proxy_uri", &PyMoneroRpcConnection::m_proxy_uri)
.def_property("zmq_uri",
[](const PyMoneroRpcConnection& self) { return self.m_zmq_uri; },
[](PyMoneroRpcConnection& self, std::optional<std::string> val) {
Expand Down Expand Up @@ -1453,14 +1448,10 @@ PYBIND11_MODULE(monero, m) {
assert_wallet_is_not_closed(&self);
MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(connection));
}, py::arg("connection"))
.def("set_daemon_connection", [](PyMoneroWallet& self, std::string uri, std::string username, std::string password) {
assert_wallet_is_not_closed(&self);
MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(uri, username, password));
}, py::arg("uri") = "", py::arg("username") = "", py::arg("password") = "")
.def("set_daemon_proxy", [](PyMoneroWallet& self, const std::string& uri) {
.def("set_daemon_connection", [](PyMoneroWallet& self, std::string uri, std::string username, std::string password, std::string proxy) {
assert_wallet_is_not_closed(&self);
MONERO_CATCH_AND_RETHROW(self.set_daemon_proxy(uri));
}, py::arg("uri") = "")
MONERO_CATCH_AND_RETHROW(self.set_daemon_connection(uri, username, password, proxy));
}, py::arg("uri") = "", py::arg("username") = "", py::arg("password") = "", py::arg("proxy"))
.def("get_daemon_connection", [](PyMoneroWallet& self) {
assert_wallet_is_not_closed(&self);
MONERO_CATCH_AND_RETHROW(self.get_daemon_connection());
Expand Down
13 changes: 2 additions & 11 deletions src/cpp/wallet/py_monero_wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2436,12 +2436,12 @@ class PyMoneroWallet : public monero::monero_wallet {
);
}

void set_daemon_connection(const std::string& uri, const std::string& username = "", const std::string& password = "") override {
void set_daemon_connection(const std::string& uri, const std::string& username = "", const std::string& password = "", const std::string& proxy = "") override {
PYBIND11_OVERRIDE(
void,
monero_wallet,
set_daemon_connection,
uri, username, password
uri, username, password, proxy
);
}

Expand All @@ -2454,15 +2454,6 @@ class PyMoneroWallet : public monero::monero_wallet {
);
}

void set_daemon_proxy(const std::string& uri = "") override {
PYBIND11_OVERRIDE(
void,
monero_wallet,
set_daemon_proxy,
uri
);
}

boost::optional<monero_rpc_connection> get_daemon_connection() const override {
PYBIND11_OVERRIDE(
boost::optional<monero_rpc_connection>,
Expand Down
6 changes: 4 additions & 2 deletions src/python/monero_rpc_connection.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MoneroRpcConnection:
"""Connection authentication password."""
priority: int
"""Connection priority."""
proxy: str | None
proxy_uri: str | None
"""Connection proxy address."""
response_time: int | None
"""Connection response time."""
Expand All @@ -33,13 +33,15 @@ class MoneroRpcConnection:
"""
...
@typing.overload
def __init__(self, uri: str = '', username: str = '', password: str = '', zmq_uri: str = '', priority: int = 0, timeout: int = 0) -> None:
def __init__(self, uri: str = '', username: str = '', password: str = '', proxy_uri: str = '', zmq_uri: str = '', priority: int = 0, timeout: int = 0) -> None:
"""
Initialize a RPC connection.

:param str uri: URI string
:param str username: username used for authentication
:param str password: password used for authentication
:param str proxy_uri: proxy uri
:param str zmq_uri: ZMQ uri
:param int priority: priorioty of the connection
:param int timeout: connection timeout in milliseconds
"""
Expand Down
10 changes: 2 additions & 8 deletions src/python/monero_wallet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -928,20 +928,14 @@ class MoneroWallet:
"""
...
@typing.overload
def set_daemon_connection(self, uri: str = '', username: str = '', password: str = '') -> None:
def set_daemon_connection(self, uri: str = '', username: str = '', password: str = '', proxy_uri: str = '') -> 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).
"""
...
def set_daemon_proxy(self, uri: str = '') -> None:
"""
Set the Tor proxy to the daemon.

:param str uri: is the proxy uri to set.
:param str proxy_uri: proxy for the connection.
"""
...
def set_restore_height(self, restore_height: int) -> None:
Expand Down
Loading