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: 2 additions & 0 deletions src/cpp/common/py_monero_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ PyMoneroPathRequest::PyMoneroPathRequest(const std::string& method, const boost:
PyMoneroPathRequest::PyMoneroPathRequest(const std::string& method, const std::shared_ptr<PyMoneroRequestParams>& params):
m_params(params) {
m_method = method;
if (params == nullptr) m_params = std::make_shared<PyMoneroRequestEmptyParams>();
}

PyMoneroBinaryRequest::PyMoneroBinaryRequest(const std::string& method, const boost::optional<py::object>& params) {
Expand Down Expand Up @@ -212,6 +213,7 @@ PyMoneroJsonRequest::PyMoneroJsonRequest(const std::string& method, const std::s
m_id("0"),
m_params(params) {
m_method = method;
if (params == nullptr) m_params = boost::none;
}


Expand Down
16 changes: 16 additions & 0 deletions src/cpp/common/py_monero_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ class PyMoneroRpcConnection : public monero::monero_rpc_connection {
bool is_connected() const;
bool check_connection(const boost::optional<int>& timeout_ms = boost::none);

inline const boost::property_tree::ptree send_json_request(const std::string& path, const std::shared_ptr<PyMoneroJsonRequestParams>& params = nullptr) {
PyMoneroJsonRequest request(path, params);
auto response = send_json_request(request);

if (response->m_result == boost::none) throw std::runtime_error("Invalid Monero JSONRPC response");
return response->m_result.get();
}

inline const std::shared_ptr<PyMoneroJsonResponse> send_json_request(const PyMoneroJsonRequest &request, std::chrono::milliseconds timeout = std::chrono::seconds(15)) {
PyMoneroJsonResponse response;

Expand All @@ -290,6 +298,14 @@ class PyMoneroRpcConnection : public monero::monero_rpc_connection {
return std::make_shared<PyMoneroJsonResponse>(response);
}

inline const boost::property_tree::ptree send_path_request(const std::string& path, const std::shared_ptr<PyMoneroRequestParams>& params = nullptr) {
PyMoneroPathRequest request(path, params);
auto response = send_path_request(request);

if (response->m_response == boost::none) throw std::runtime_error("Invalid Monero path response");
return response->m_response.get();
}

inline const std::shared_ptr<PyMoneroPathResponse> send_path_request(const PyMoneroPathRequest &request, std::chrono::milliseconds timeout = std::chrono::seconds(15)) {
PyMoneroPathResponse response;

Expand Down
Loading
Loading