@@ -1137,47 +1137,17 @@ PYBIND11_MODULE(monero, m) {
11371137 .def_property (" transfer_query" ,
11381138 [](const monero::monero_tx_query& self) { return self.m_transfer_query ; },
11391139 [](std::shared_ptr<monero::monero_tx_query>& self, const boost::optional<std::shared_ptr<monero::monero_transfer_query>>& val) {
1140- const auto old_query = self->m_transfer_query ;
1141- self->m_transfer_query = val;
1142- if (self->m_transfer_query != boost::none) {
1143- self->m_transfer_query .get ()->m_tx_query = self;
1144- }
1145- if (old_query != boost::none) {
1146- if (val != boost::none && val.get () == old_query.get ()) {
1147- return ;
1148- }
1149- old_query.get ()->m_tx_query = boost::none;
1150- }
1140+ set_query (self, self->m_transfer_query , val);
11511141 })
11521142 .def_property (" input_query" ,
11531143 [](const monero::monero_tx_query& self) { return self.m_input_query ; },
11541144 [](std::shared_ptr<monero::monero_tx_query>& self, const boost::optional<std::shared_ptr<monero::monero_output_query>>& val) {
1155- const auto old_query = self->m_input_query ;
1156- self->m_input_query = val;
1157- if (self->m_input_query != boost::none) {
1158- self->m_input_query .get ()->m_tx_query = self;
1159- }
1160- if (old_query != boost::none) {
1161- if (val != boost::none && val.get () == old_query.get ()) {
1162- return ;
1163- }
1164- old_query.get ()->m_tx_query = boost::none;
1165- }
1145+ set_query (self, self->m_input_query , val);
11661146 })
11671147 .def_property (" output_query" ,
11681148 [](const monero::monero_tx_query& self) { return self.m_output_query ; },
11691149 [](std::shared_ptr<monero::monero_tx_query>& self, const boost::optional<std::shared_ptr<monero::monero_output_query>>& val) {
1170- const auto old_query = self->m_output_query ;
1171- self->m_output_query = val;
1172- if (self->m_output_query != boost::none) {
1173- self->m_output_query .get ()->m_tx_query = self;
1174- }
1175- if (old_query != boost::none) {
1176- if (val != boost::none && val.get () == old_query.get ()) {
1177- return ;
1178- }
1179- old_query.get ()->m_tx_query = boost::none;
1180- }
1150+ set_query (self, self->m_output_query , val);
11811151 })
11821152 .def (" copy" , [](const std::shared_ptr<monero::monero_tx_query>& self) {
11831153 auto tgt = std::make_shared<monero::monero_tx_query>();
@@ -1774,34 +1744,10 @@ PYBIND11_MODULE(monero, m) {
17741744 MONERO_CATCH_AND_RETHROW (self.get_txs ());
17751745 })
17761746 .def (" get_txs" , [](PyMoneroWallet& self, const monero::monero_tx_query& query) {
1777- try {
1778- auto txs = self.get_txs (query);
1779- PyMoneroUtils::sort_txs_wallet (txs, query.m_hashes );
1780- return txs;
1781- } catch (const PyMoneroRpcError& e) {
1782- throw ;
1783- } catch (const PyMoneroError& e) {
1784- throw ;
1785- }
1786- catch (const std::exception& e) {
1787- throw PyMoneroError (e.what ());
1788- }
1747+ MONERO_CATCH_AND_RETHROW (PyMoneroUtils::get_and_sort_txs (self, query));
17891748 }, py::arg (" query" ))
17901749 .def (" get_txs" , [](PyMoneroWallet& self, const std::vector<std::string>& tx_hashes) {
1791- try {
1792- monero_tx_query query;
1793- query.m_hashes = tx_hashes;
1794- auto txs = self.get_txs (query);
1795- PyMoneroUtils::sort_txs_wallet (txs, query.m_hashes );
1796- return txs;
1797- } catch (const PyMoneroRpcError& e) {
1798- throw ;
1799- } catch (const PyMoneroError& e) {
1800- throw ;
1801- }
1802- catch (const std::exception& e) {
1803- throw PyMoneroError (e.what ());
1804- }
1750+ MONERO_CATCH_AND_RETHROW (PyMoneroUtils::get_and_sort_txs (self, tx_hashes));
18051751 }, py::arg (" tx_hashes" ))
18061752 .def (" get_transfers" , [](PyMoneroWallet& self, const monero::monero_transfer_query& query) {
18071753 MONERO_CATCH_AND_RETHROW (self.get_transfers (query));
@@ -2130,49 +2076,13 @@ PYBIND11_MODULE(monero, m) {
21302076 .def (py::init<const std::shared_ptr<PyMoneroRpcConnection>&>(), py::arg (" rpc_connection" ))
21312077 .def (py::init<const std::string&, const std::string&, const std::string&, const std::string&, const std::string&, uint64_t >(), py::arg (" uri" ) = " " , py::arg (" username" ) = " " , py::arg (" password" ) = " " , py::arg (" proxy_uri" ) = " " , py::arg (" zmq_uri" ) = " " , py::arg (" timeout" ) = 20000 )
21322078 .def (" create_wallet" , [](PyMoneroWalletRpc& self, const std::shared_ptr<PyMoneroWalletConfig>& config) {
2133- try {
2134- self.create_wallet (config);
2135- return &self;
2136- }
2137- catch (const PyMoneroRpcError& ex) {
2138- throw ;
2139- }
2140- catch (const PyMoneroError& ex) {
2141- throw ;
2142- }
2143- catch (const std::exception& ex) {
2144- throw PyMoneroError (ex.what ());
2145- }
2079+ MONERO_CATCH_AND_RETHROW (self.create_wallet (config));
21462080 }, py::arg (" config" ))
21472081 .def (" open_wallet" , [](PyMoneroWalletRpc& self, const std::shared_ptr<PyMoneroWalletConfig>& config) {
2148- try {
2149- self.open_wallet (config);
2150- return &self;
2151- }
2152- catch (const PyMoneroRpcError& ex) {
2153- throw ;
2154- }
2155- catch (const PyMoneroError& ex) {
2156- throw ;
2157- }
2158- catch (const std::exception& ex) {
2159- throw PyMoneroError (ex.what ());
2160- }
2082+ MONERO_CATCH_AND_RETHROW (self.open_wallet (config));
21612083 }, py::arg (" config" ))
21622084 .def (" open_wallet" , [](PyMoneroWalletRpc& self, const std::string& name, const std::string& password) {
2163- try {
2164- self.open_wallet (name, password);
2165- return &self;
2166- }
2167- catch (const PyMoneroRpcError& ex) {
2168- throw ;
2169- }
2170- catch (const PyMoneroError& ex) {
2171- throw ;
2172- }
2173- catch (const std::exception& ex) {
2174- throw PyMoneroError (ex.what ());
2175- }
2085+ MONERO_CATCH_AND_RETHROW (self.open_wallet (name, password));
21762086 }, py::arg (" name" ), py::arg (" password" ))
21772087 .def (" is_closed" , [](const PyMoneroWalletRpc& self) {
21782088 MONERO_CATCH_AND_RETHROW (self.is_closed ());
0 commit comments