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 src/cpp/daemon/py_monero_daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PyMoneroDaemon {
virtual PyMoneroKeyImageSpentStatus get_key_image_spent_status(std::string& key_image) { throw std::runtime_error("PyMoneroDaemon: not supported"); }
virtual std::vector<PyMoneroKeyImageSpentStatus> get_key_image_spent_statuses(std::vector<std::string>& key_images) { throw std::runtime_error("PyMoneroDaemon: not supported"); }
virtual std::vector<std::shared_ptr<monero::monero_output>> get_outputs(std::vector<monero::monero_output>& outputs) { throw std::runtime_error("PyMoneroDaemon: not supported"); }
virtual std::vector<std::shared_ptr<PyMoneroOutputHistogramEntry>> get_output_histogram(std::vector<uint64_t> amounts, int min_count, int max_count, bool is_unlocked, int recent_cutoff) { throw std::runtime_error("PyMoneroDaemon: not supported"); }
virtual std::vector<std::shared_ptr<PyMoneroOutputHistogramEntry>> get_output_histogram(const std::vector<uint64_t>& amounts, const boost::optional<int>& min_count, const boost::optional<int>& max_count, const boost::optional<bool>& is_unlocked, const boost::optional<int>& recent_cutoff) { throw std::runtime_error("PyMoneroDaemon: not supported"); }
virtual std::vector<std::shared_ptr<PyMoneroOutputDistributionEntry>> get_output_distribution(std::vector<uint64_t> amounts) { throw std::runtime_error("PyMoneroDaemon: not supported"); }
virtual std::vector<std::shared_ptr<PyMoneroOutputDistributionEntry>> get_output_distribution(std::vector<uint64_t> amounts, bool is_cumulative, uint64_t start_height, uint64_t end_height) { throw std::runtime_error("PyMoneroDaemon: not supported"); }
virtual std::shared_ptr<PyMoneroDaemonInfo> get_info() { throw std::runtime_error("PyMoneroDaemon: not supported"); }
Expand Down
20 changes: 11 additions & 9 deletions src/cpp/daemon/py_monero_daemon_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void PyMoneroTx::from_property_tree(const boost::property_tree::ptree& node, con
}
else if (key == std::string("as_json")) as_json = it->second.data();
else if (key == std::string("tx_json")) tx_json = it->second.data();
else if (key == std::string("as_hex") || key == std::string("tx_blob")) tx->m_full_hex = it->second.data();
else if ((key == std::string("as_hex") || key == std::string("tx_blob")) && !it->second.data().empty()) tx->m_full_hex = it->second.data();
else if (key == std::string("blob_size")) tx->m_size = it->second.get_value<uint64_t>();
else if (key == std::string("weight")) tx->m_weight = it->second.get_value<uint64_t>();
else if (key == std::string("fee")) tx->m_fee = it->second.get_value<uint64_t>();
Expand Down Expand Up @@ -320,19 +320,21 @@ void PyMoneroTx::from_property_tree(const boost::property_tree::ptree& node, con
}
}
else if (key == std::string("max_used_block_height")) tx->m_max_used_block_height = it->second.get_value<uint64_t>();
else if (key == std::string("max_used_block_id_hash")) tx->m_max_used_block_hash = it->second.data();
else if (key == std::string("prunable_hash")) tx->m_prunable_hash = it->second.data();
else if (key == std::string("prunable_as_hex")) tx->m_prunable_hex = it->second.data();
else if (key == std::string("pruned_as_hex")) tx->m_pruned_hex = it->second.data();
else if (key == std::string("max_used_block_id_hash") && !it->second.data().empty()) tx->m_max_used_block_hash = it->second.data();
else if (key == std::string("prunable_hash") && !it->second.data().empty()) tx->m_prunable_hash = it->second.data();
else if (key == std::string("prunable_as_hex") && !it->second.data().empty()) tx->m_prunable_hex = it->second.data();
else if (key == std::string("pruned_as_hex") && !it->second.data().empty()) tx->m_pruned_hex = it->second.data();
}

if (block != nullptr) {
bool is_confirmed = tx->m_is_confirmed != boost::none && tx->m_is_confirmed.get();

if (block != nullptr && is_confirmed) {
block->m_txs.push_back(tx);
tx->m_block = block;
}

// initialize remaining known fields
if (tx->m_is_confirmed) {
if (is_confirmed) {
tx->m_relay = true;
tx->m_is_relayed = true;
tx->m_is_failed = false;
Expand All @@ -358,7 +360,7 @@ void PyMoneroTx::from_property_tree(const boost::property_tree::ptree& node, con
PyMoneroTx::from_property_tree(n, tx);
}

if (tx->m_is_relayed != true) tx->m_last_relayed_timestamp = boost::none;
if (tx->m_is_relayed != boost::none && !tx->m_is_relayed.get()) tx->m_last_relayed_timestamp = boost::none;
}

void PyMoneroTx::from_property_tree(const boost::property_tree::ptree& node, std::vector<std::shared_ptr<monero::monero_tx>>& txs) {
Expand Down Expand Up @@ -649,7 +651,7 @@ void PyMoneroOutputHistogramEntry::from_property_tree(const boost::property_tree

for(boost::property_tree::ptree::const_iterator it2 = node2.begin(); it2 != node2.end(); ++it2) {
auto entry = std::make_shared<PyMoneroOutputHistogramEntry>();
from_property_tree(node2, entry);
from_property_tree(it2->second, entry);
entries.push_back(entry);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/daemon/py_monero_daemon_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ class PyMoneroGetOutputHistrogramParams : public PyMoneroJsonRequestParams {
boost::optional<bool> m_is_unlocked;
boost::optional<int> m_recent_cutoff;

PyMoneroGetOutputHistrogramParams(const std::vector<uint64_t> &amounts, int min_count, int max_count, bool is_unlocked, int recent_cutoff) {
PyMoneroGetOutputHistrogramParams(const std::vector<uint64_t>& amounts, const boost::optional<int>& min_count, const boost::optional<int>& max_count, const boost::optional<bool>& is_unlocked, const boost::optional<int>& recent_cutoff) {
m_amounts = amounts;
m_min_count = min_count;
m_max_count = max_count;
Expand Down
14 changes: 12 additions & 2 deletions src/cpp/daemon/py_monero_daemon_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,17 @@ std::vector<std::shared_ptr<monero::monero_tx>> PyMoneroDaemonRpc::get_txs(const
}

std::vector<std::string> PyMoneroDaemonRpc::get_tx_hexes(const std::vector<std::string>& tx_hashes, bool prune) {
throw std::runtime_error("PyMoneroDaemon: not implemented");
std::vector<std::string> hexes;
for(const auto& tx : get_txs(tx_hashes, prune)) {
// tx may be pruned regardless of configuration
if (tx->m_pruned_hex == boost::none) {
if (tx->m_full_hex == boost::none) throw std::runtime_error("Tx has no hex");
hexes.push_back(tx->m_full_hex.get());
} else {
hexes.push_back(tx->m_pruned_hex.get());
}
}
return hexes;
}

std::shared_ptr<PyMoneroMinerTxSum> PyMoneroDaemonRpc::get_miner_tx_sum(uint64_t height, uint64_t num_blocks) {
Expand Down Expand Up @@ -486,7 +496,7 @@ std::vector<std::shared_ptr<monero::monero_output>> PyMoneroDaemonRpc::get_outpu
throw std::runtime_error("PyMoneroDaemonRpc::get_outputs(): not implemented");
}

std::vector<std::shared_ptr<PyMoneroOutputHistogramEntry>> PyMoneroDaemonRpc::get_output_histogram(std::vector<uint64_t> amounts, int min_count, int max_count, bool is_unlocked, int recent_cutoff) {
std::vector<std::shared_ptr<PyMoneroOutputHistogramEntry>> PyMoneroDaemonRpc::get_output_histogram(const std::vector<uint64_t>& amounts, const boost::optional<int>& min_count, const boost::optional<int>& max_count, const boost::optional<bool>& is_unlocked, const boost::optional<int>& recent_cutoff) {
auto params = std::make_shared<PyMoneroGetOutputHistrogramParams>(amounts, min_count, max_count, is_unlocked, recent_cutoff);
PyMoneroJsonRequest request("get_output_histogram", params);
std::shared_ptr<PyMoneroJsonResponse> response = m_rpc->send_json_request(request);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/daemon/py_monero_daemon_rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class PyMoneroDaemonRpc : public PyMoneroDaemonDefault {
void flush_tx_pool(const std::string &hash) override;
std::vector<PyMoneroKeyImageSpentStatus> get_key_image_spent_statuses(std::vector<std::string>& key_images) override;
std::vector<std::shared_ptr<monero::monero_output>> get_outputs(std::vector<monero::monero_output>& outputs) override;
std::vector<std::shared_ptr<PyMoneroOutputHistogramEntry>> get_output_histogram(std::vector<uint64_t> amounts, int min_count, int max_count, bool is_unlocked, int recent_cutoff) override;
std::vector<std::shared_ptr<PyMoneroOutputHistogramEntry>> get_output_histogram(const std::vector<uint64_t>& amounts, const boost::optional<int>& min_count, const boost::optional<int>& max_count, const boost::optional<bool>& is_unlocked, const boost::optional<int>& recent_cutoff) override;
std::shared_ptr<PyMoneroDaemonInfo> get_info() override;
std::shared_ptr<PyMoneroDaemonSyncInfo> get_sync_info() override;
std::shared_ptr<PyMoneroHardForkInfo> get_hard_fork_info() override;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/py_monero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ PYBIND11_MODULE(monero, m) {
.def("get_outputs", [](PyMoneroDaemon& self, std::vector<monero::monero_output>& outputs) {
MONERO_CATCH_AND_RETHROW(self.get_outputs(outputs));
}, py::arg("outputs"))
.def("get_output_histogram", [](PyMoneroDaemon& self, std::vector<uint64_t>& amounts, int min_count, int max_count, bool is_unlocked, int recent_cutoff) {
.def("get_output_histogram", [](PyMoneroDaemon& self, const std::vector<uint64_t>& amounts, const boost::optional<int>& min_count, const boost::optional<int>& max_count, const boost::optional<bool>& is_unlocked, const boost::optional<int>& recent_cutoff) {
MONERO_CATCH_AND_RETHROW(self.get_output_histogram(amounts, min_count, max_count, is_unlocked, recent_cutoff));
}, py::arg("amounts"), py::arg("min_count"), py::arg("max_count"), py::arg("is_unlocked"), py::arg("recent_cutoff"))
.def("get_output_distribution", [](PyMoneroDaemon& self, std::vector<uint64_t>& amounts) {
Expand Down
12 changes: 6 additions & 6 deletions src/python/monero_daemon.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -324,17 +324,17 @@ class MoneroDaemon:
:return list[MoneroOutputDistributionEntry]: output distribution entries meeting the parameters
"""
...
def get_output_histogram(self, amounts: list[int], min_count: int, max_count: int, is_unlocked: bool, recent_cutoff: int) -> list[MoneroOutputHistogramEntry]:
def get_output_histogram(self, amounts: list[int], min_count: int | None, max_count: int | None, is_unlocked: bool | None, recent_cutoff: int | None) -> list[MoneroOutputHistogramEntry]:
"""
Get a histogram of output amounts. For all amounts (possibly filtered by
parameters), gives the number of outputs on the chain for that amount.
RingCT outputs counts as 0 amount.

:param int amounts: are amounts of outputs to make the histogram with
:param int min_count: TODO
:param int max_count: TODO
:param bool is_unlocked: makes a histogram with outputs with the specified lock state
:param int recent_cutoff: TODO
:param list[int] amounts: are amounts of outputs to make the histogram with
:param int | None min_count: TODO
:param int | None max_count: TODO
:param bool | None is_unlocked: makes a histogram with outputs with the specified lock state
:param int | None recent_cutoff: TODO
:return list[MoneroOutputHistogramEntry]: output histogram entries meeting the parameters
"""
...
Expand Down
Loading
Loading