mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-18 23:58:59 +02:00
tx, transfer, output request -> query
This commit is contained in:
@@ -238,7 +238,7 @@ namespace monero {
|
||||
if (m_is_miner_tx != boost::none) node.put("isMinerTx", *m_is_miner_tx);
|
||||
if (m_payment_id != boost::none) node.put("paymentId", *m_payment_id);
|
||||
if (m_fee != boost::none) node.put("fee", *m_fee);
|
||||
if (m_mixin != boost::none) node.put("m_mixin", *m_mixin);
|
||||
if (m_mixin != boost::none) node.put("mixin", *m_mixin);
|
||||
if (m_do_not_relay != boost::none) node.put("doNotRelay", *m_do_not_relay);
|
||||
if (m_is_relayed != boost::none) node.put("isRelayed", *m_is_relayed);
|
||||
if (m_is_confirmed != boost::none) node.put("isConfirmed", *m_is_confirmed);
|
||||
|
||||
+79
-79
@@ -70,28 +70,28 @@ void node_to_transfer(const boost::property_tree::ptree& node, shared_ptr<monero
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<monero_transfer_request> node_to_transfer_request(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_transfer_request> m_transfer_request = make_shared<monero_transfer_request>();
|
||||
node_to_transfer(node, m_transfer_request);
|
||||
shared_ptr<monero_transfer_query> node_to_transfer_query(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_transfer_query> m_transfer_query = make_shared<monero_transfer_query>();
|
||||
node_to_transfer(node, m_transfer_query);
|
||||
|
||||
// initialize request from node
|
||||
// initialize query from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("isIncoming")) m_transfer_request->m_is_incoming = it->second.get_value<bool>();
|
||||
else if (key == string("address")) m_transfer_request->m_address = it->second.data();
|
||||
if (key == string("isIncoming")) m_transfer_query->m_is_incoming = it->second.get_value<bool>();
|
||||
else if (key == string("address")) m_transfer_query->m_address = it->second.data();
|
||||
else if (key == string("addresses")) throw runtime_error("addresses not implemented");
|
||||
else if (key == string("subaddressIndex")) m_transfer_request->m_subaddress_index = it->second.get_value<uint32_t>();
|
||||
else if (key == string("subaddressIndex")) m_transfer_query->m_subaddress_index = it->second.get_value<uint32_t>();
|
||||
else if (key == string("subaddressIndices")) {
|
||||
vector<uint32_t> m_subaddress_indices;
|
||||
for (const auto& child : it->second) m_subaddress_indices.push_back(child.second.get_value<uint32_t>());
|
||||
m_transfer_request->m_subaddress_indices = m_subaddress_indices;
|
||||
m_transfer_query->m_subaddress_indices = m_subaddress_indices;
|
||||
}
|
||||
else if (key == string("destinations")) throw runtime_error("destinations not implemented");
|
||||
else if (key == string("hasDestinations")) m_transfer_request->m_has_destinations = it->second.get_value<bool>();
|
||||
else if (key == string("txRequest")) throw runtime_error("txRequest not implemented");
|
||||
else if (key == string("hasDestinations")) m_transfer_query->m_has_destinations = it->second.get_value<bool>();
|
||||
else if (key == string("txQuery")) throw runtime_error("txQuery not implemented");
|
||||
}
|
||||
|
||||
return m_transfer_request;
|
||||
return m_transfer_query;
|
||||
}
|
||||
|
||||
shared_ptr<monero_key_image> node_to_key_image(const boost::property_tree::ptree& node) {
|
||||
@@ -132,18 +132,18 @@ void node_to_output_wallet(const boost::property_tree::ptree& node, shared_ptr<m
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<monero_output_request> node_to_output_request(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_output_request> m_output_request = make_shared<monero_output_request>();
|
||||
node_to_output_wallet(node, m_output_request);
|
||||
shared_ptr<monero_output_query> node_to_output_query(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_output_query> m_output_query = make_shared<monero_output_query>();
|
||||
node_to_output_wallet(node, m_output_query);
|
||||
|
||||
// initialize request from node
|
||||
// initialize query from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("subaddressIndices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_output_request->m_subaddress_indices.push_back(it2->second.get_value<uint32_t>());
|
||||
else if (key == string("txRequest")) {} // ignored
|
||||
if (key == string("subaddressIndices")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_output_query->m_subaddress_indices.push_back(it2->second.get_value<uint32_t>());
|
||||
else if (key == string("txQuery")) {} // ignored
|
||||
}
|
||||
|
||||
return m_output_request;
|
||||
return m_output_query;
|
||||
}
|
||||
|
||||
void node_to_tx(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx) {
|
||||
@@ -201,37 +201,37 @@ void node_to_tx_wallet(const boost::property_tree::ptree& node, shared_ptr<moner
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<monero_tx_request> node_to_tx_request(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_tx_request> m_tx_request = make_shared<monero_tx_request>();
|
||||
node_to_tx_wallet(node, m_tx_request);
|
||||
shared_ptr<monero_tx_query> node_to_tx_query(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_tx_query> m_tx_query = make_shared<monero_tx_query>();
|
||||
node_to_tx_wallet(node, m_tx_query);
|
||||
|
||||
// initialize request from node
|
||||
// initialize query from node
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("isOutgoing")) m_tx_request->m_is_outgoing = it->second.get_value<bool>();
|
||||
else if (key == string("isIncoming")) m_tx_request->m_is_incoming = it->second.get_value<bool>();
|
||||
else if (key == string("txIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_tx_request->m_tx_ids.push_back(it2->second.data());
|
||||
else if (key == string("hasPaymentId")) m_tx_request->m_has_payment_id = it->second.get_value<bool>();
|
||||
else if (key == string("paymentIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_tx_request->m_payment_ids.push_back(it2->second.data());
|
||||
else if (key == string("height")) m_tx_request->m_height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("minHeight")) m_tx_request->m_min_height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("maxHeight")) m_tx_request->m_max_height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("includeOutputs")) m_tx_request->m_include_outputs = it->second.get_value<bool>();
|
||||
else if (key == string("transferRequest")) m_tx_request->m_transfer_request = node_to_transfer_request(it->second);
|
||||
else if (key == string("outputRequest")) m_tx_request->m_output_request = node_to_output_request(it->second);
|
||||
if (key == string("isOutgoing")) m_tx_query->m_is_outgoing = it->second.get_value<bool>();
|
||||
else if (key == string("isIncoming")) m_tx_query->m_is_incoming = it->second.get_value<bool>();
|
||||
else if (key == string("txIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_tx_query->m_tx_ids.push_back(it2->second.data());
|
||||
else if (key == string("hasPaymentId")) m_tx_query->m_has_payment_id = it->second.get_value<bool>();
|
||||
else if (key == string("paymentIds")) for (boost::property_tree::ptree::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) m_tx_query->m_payment_ids.push_back(it2->second.data());
|
||||
else if (key == string("height")) m_tx_query->m_height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("minHeight")) m_tx_query->m_min_height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("maxHeight")) m_tx_query->m_max_height = it->second.get_value<uint64_t>();
|
||||
else if (key == string("includeOutputs")) m_tx_query->m_include_outputs = it->second.get_value<bool>();
|
||||
else if (key == string("transferQuery")) m_tx_query->m_transfer_query = node_to_transfer_query(it->second);
|
||||
else if (key == string("outputQuery")) m_tx_query->m_output_query = node_to_output_query(it->second);
|
||||
}
|
||||
|
||||
return m_tx_request;
|
||||
return m_tx_query;
|
||||
}
|
||||
|
||||
shared_ptr<monero_block> node_to_block_request(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_block> node_to_blockquery(const boost::property_tree::ptree& node) {
|
||||
shared_ptr<monero_block> block = make_shared<monero_block>();
|
||||
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
|
||||
string key = it->first;
|
||||
if (key == string("txs")) {
|
||||
boost::property_tree::ptree txsNode = it->second;
|
||||
for (boost::property_tree::ptree::const_iterator it2 = txsNode.begin(); it2 != txsNode.end(); ++it2) {
|
||||
block->m_txs.push_back(node_to_tx_request(it2->second));
|
||||
block->m_txs.push_back(node_to_tx_query(it2->second));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -314,75 +314,75 @@ void monero_utils::binary_blocks_to_json(const std::string &bin, std::string &js
|
||||
json = ss.str();
|
||||
}
|
||||
|
||||
shared_ptr<monero_tx_request> monero_utils::deserialize_tx_request(const string& txRequestStr) {
|
||||
shared_ptr<monero_tx_query> monero_utils::deserialize_tx_query(const string& tx_query_str) {
|
||||
|
||||
// deserialize tx request string to property rooted at block
|
||||
std::istringstream iss = txRequestStr.empty() ? std::istringstream() : std::istringstream(txRequestStr);
|
||||
boost::property_tree::ptree blockNode;
|
||||
boost::property_tree::read_json(iss, blockNode);
|
||||
// deserialize tx query string to property rooted at block
|
||||
std::istringstream iss = tx_query_str.empty() ? std::istringstream() : std::istringstream(tx_query_str);
|
||||
boost::property_tree::ptree block_node;
|
||||
boost::property_tree::read_json(iss, block_node);
|
||||
|
||||
// convert request property tree to block
|
||||
shared_ptr<monero_block> block = node_to_block_request(blockNode);
|
||||
// convert query property tree to block
|
||||
shared_ptr<monero_block> block = node_to_blockquery(block_node);
|
||||
|
||||
// get tx request
|
||||
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->m_txs[0]);
|
||||
// get tx query
|
||||
shared_ptr<monero_tx_query> tx_query = static_pointer_cast<monero_tx_query>(block->m_txs[0]);
|
||||
|
||||
// return deserialized request
|
||||
return tx_request;
|
||||
// return deserialized query
|
||||
return tx_query;
|
||||
}
|
||||
|
||||
shared_ptr<monero_transfer_request> monero_utils::deserialize_transfer_request(const string& transfer_request_str) {
|
||||
shared_ptr<monero_transfer_query> monero_utils::deserialize_transfer_query(const string& transfer_query_str) {
|
||||
|
||||
// deserialize transfer request string to property rooted at block
|
||||
std::istringstream iss = transfer_request_str.empty() ? std::istringstream() : std::istringstream(transfer_request_str);
|
||||
// deserialize transfer query string to property rooted at block
|
||||
std::istringstream iss = transfer_query_str.empty() ? std::istringstream() : std::istringstream(transfer_query_str);
|
||||
boost::property_tree::ptree blockNode;
|
||||
boost::property_tree::read_json(iss, blockNode);
|
||||
|
||||
// convert request property tree to block
|
||||
shared_ptr<monero_block> block = node_to_block_request(blockNode);
|
||||
// convert query property tree to block
|
||||
shared_ptr<monero_block> block = node_to_blockquery(blockNode);
|
||||
|
||||
// return mpty request if no txs
|
||||
if (block->m_txs.empty()) return make_shared<monero_transfer_request>();
|
||||
// return mpty query if no txs
|
||||
if (block->m_txs.empty()) return make_shared<monero_transfer_query>();
|
||||
|
||||
// get tx request
|
||||
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->m_txs[0]);
|
||||
// get tx query
|
||||
shared_ptr<monero_tx_query> tx_query = static_pointer_cast<monero_tx_query>(block->m_txs[0]);
|
||||
|
||||
// get / create transfer request
|
||||
shared_ptr<monero_transfer_request> transfer_request = tx_request->m_transfer_request == boost::none ? make_shared<monero_transfer_request>() : *tx_request->m_transfer_request;
|
||||
// get / create transfer query
|
||||
shared_ptr<monero_transfer_query> transfer_query = tx_query->m_transfer_query == boost::none ? make_shared<monero_transfer_query>() : *tx_query->m_transfer_query;
|
||||
|
||||
// transfer request references tx request but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias()
|
||||
transfer_request->m_tx_request = tx_request;
|
||||
tx_request->m_transfer_request = boost::none;
|
||||
// transfer query references tx query but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias()
|
||||
transfer_query->m_tx_query = tx_query;
|
||||
tx_query->m_transfer_query = boost::none;
|
||||
|
||||
// return deserialized request
|
||||
return transfer_request;
|
||||
// return deserialized query
|
||||
return transfer_query;
|
||||
}
|
||||
|
||||
shared_ptr<monero_output_request> monero_utils::deserialize_output_request(const string& output_request_str) {
|
||||
shared_ptr<monero_output_query> monero_utils::deserialize_output_query(const string& output_query_str) {
|
||||
|
||||
// deserialize output request string to property rooted at block
|
||||
std::istringstream iss = output_request_str.empty() ? std::istringstream() : std::istringstream(output_request_str);
|
||||
// deserialize output query string to property rooted at block
|
||||
std::istringstream iss = output_query_str.empty() ? std::istringstream() : std::istringstream(output_query_str);
|
||||
boost::property_tree::ptree blockNode;
|
||||
boost::property_tree::read_json(iss, blockNode);
|
||||
|
||||
// convert request property tree to block
|
||||
shared_ptr<monero_block> block = node_to_block_request(blockNode);
|
||||
// convert query property tree to block
|
||||
shared_ptr<monero_block> block = node_to_blockquery(blockNode);
|
||||
|
||||
// empty request if no txs
|
||||
if (block->m_txs.empty()) return make_shared<monero_output_request>();
|
||||
// empty query if no txs
|
||||
if (block->m_txs.empty()) return make_shared<monero_output_query>();
|
||||
|
||||
// get tx request
|
||||
shared_ptr<monero_tx_request> tx_request = static_pointer_cast<monero_tx_request>(block->m_txs[0]);
|
||||
// get tx query
|
||||
shared_ptr<monero_tx_query> tx_query = static_pointer_cast<monero_tx_query>(block->m_txs[0]);
|
||||
|
||||
// get / create output request
|
||||
shared_ptr<monero_output_request> output_request = tx_request->m_output_request == boost::none ? make_shared<monero_output_request>() : *tx_request->m_output_request;
|
||||
// get / create output query
|
||||
shared_ptr<monero_output_query> output_query = tx_query->m_output_query == boost::none ? make_shared<monero_output_query>() : *tx_query->m_output_query;
|
||||
|
||||
// output request references tx request but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias()
|
||||
output_request->m_tx_request = tx_request;
|
||||
tx_request->m_output_request = boost::none;
|
||||
// output query references tx query but not the other way around to avoid circular loop // TODO: could add check within meetsCriterias(), TODO: move this temp hack to the caller
|
||||
output_query->m_tx_query = tx_query;
|
||||
tx_query->m_output_query = boost::none;
|
||||
|
||||
// return deserialized request
|
||||
return output_request;
|
||||
// return deserialized query
|
||||
return output_query;
|
||||
}
|
||||
|
||||
shared_ptr<monero_send_request> monero_utils::deserialize_send_request(const string& send_request_str) {
|
||||
|
||||
@@ -72,11 +72,11 @@ namespace monero_utils
|
||||
|
||||
void binary_blocks_to_json(const std::string &bin, std::string &json);
|
||||
|
||||
shared_ptr<monero_tx_request> deserialize_tx_request(const string& txRequestStr);
|
||||
shared_ptr<monero_tx_query> deserialize_tx_query(const string& txQueryStr);
|
||||
|
||||
shared_ptr<monero_transfer_request> deserialize_transfer_request(const string& transfer_request_str);
|
||||
shared_ptr<monero_transfer_query> deserialize_transfer_query(const string& transfer_query_str);
|
||||
|
||||
shared_ptr<monero_output_request> deserialize_output_request(const string& output_request_str);
|
||||
shared_ptr<monero_output_query> deserialize_output_query(const string& output_query_str);
|
||||
|
||||
shared_ptr<monero_send_request> deserialize_send_request(const string& send_request_str);
|
||||
|
||||
|
||||
+297
-298
File diff suppressed because it is too large
Load Diff
@@ -633,7 +633,7 @@ namespace monero {
|
||||
* @param request filters query results (optional)
|
||||
* @return wallet transactions per the request
|
||||
*/
|
||||
vector<shared_ptr<monero_tx_wallet>> get_txs(const monero_tx_request& request) const;
|
||||
vector<shared_ptr<monero_tx_wallet>> get_txs(const monero_tx_query& request) const;
|
||||
|
||||
// /**
|
||||
// * Get all incoming and outgoing transfers to and from this wallet. An
|
||||
@@ -682,7 +682,7 @@ namespace monero {
|
||||
* a subaddress within an account. Transfers belong to transactions which
|
||||
* are stored on the blockchain.
|
||||
*
|
||||
* Query results can be filtered by passing in a monero_transfer_request.
|
||||
* Query results can be filtered by passing in a monero_transfer_query.
|
||||
* Transfers must meet every criteria defined in the request in order to be
|
||||
* returned. All filtering is optional and no filtering is applied when not
|
||||
* defined.
|
||||
@@ -690,7 +690,7 @@ namespace monero {
|
||||
* @param request filters query results (optional)
|
||||
* @return wallet transfers per the request
|
||||
*/
|
||||
vector<shared_ptr<monero_transfer>> get_transfers(const monero_transfer_request& request) const;
|
||||
vector<shared_ptr<monero_transfer>> get_transfers(const monero_transfer_query& request) const;
|
||||
|
||||
// /**
|
||||
// * Get outputs created from previous transactions that belong to the wallet
|
||||
@@ -706,14 +706,14 @@ namespace monero {
|
||||
* (i.e. that the wallet can spend one time). Outputs are part of
|
||||
* transactions which are stored in blocks on the blockchain.
|
||||
*
|
||||
* Results can be configured by passing a monero_output_request. Outputs must
|
||||
* Results can be configured by passing a monero_output_query. Outputs must
|
||||
* meet every criteria defined in the request in order to be returned. All
|
||||
* filtering is optional and no filtering is applied when not defined.
|
||||
*
|
||||
* @param request specifies request options (optional)
|
||||
* @return List<monero_output_wallet> are wallet outputs per the request
|
||||
*/
|
||||
vector<shared_ptr<monero_output_wallet>> get_outputs(const monero_output_request& request) const;
|
||||
vector<shared_ptr<monero_output_wallet>> get_outputs(const monero_output_query& request) const;
|
||||
|
||||
/**
|
||||
* Export all outputs in hex format.
|
||||
@@ -1204,9 +1204,9 @@ namespace monero {
|
||||
|
||||
private:
|
||||
friend struct wallet2_listener;
|
||||
unique_ptr<tools::wallet2> w2; // internal wallet implementation
|
||||
unique_ptr<wallet2_listener> w2_listener; // listener for internal wallet implementation
|
||||
boost::optional<monero_wallet_listener&> listener = boost::none; // wallet's external listener
|
||||
unique_ptr<tools::wallet2> m_w2; // internal wallet implementation
|
||||
unique_ptr<wallet2_listener> m_w2_listener; // listener for internal wallet implementation
|
||||
boost::optional<monero_wallet_listener&> m_listener = boost::none; // wallet's external listener
|
||||
|
||||
void init_common();
|
||||
vector<monero_subaddress> get_subaddresses_aux(uint32_t account_idx, const vector<uint32_t>& subaddress_indices, const vector<tools::wallet2::transfer_details>& transfers) const;
|
||||
|
||||
@@ -184,22 +184,22 @@ namespace monero {
|
||||
|
||||
// -------------------------- MONERO TX REQUEST -----------------------------
|
||||
|
||||
shared_ptr<monero_tx_request> monero_tx_request::copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const {
|
||||
return copy(static_pointer_cast<monero_tx_request>(src), static_pointer_cast<monero_tx_request>(tgt));
|
||||
shared_ptr<monero_tx_query> monero_tx_query::copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const {
|
||||
return copy(static_pointer_cast<monero_tx_query>(src), static_pointer_cast<monero_tx_query>(tgt));
|
||||
};
|
||||
|
||||
shared_ptr<monero_tx_request> monero_tx_request::copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const {
|
||||
return copy(static_pointer_cast<monero_tx_request>(src), static_pointer_cast<monero_tx_request>(tgt));
|
||||
shared_ptr<monero_tx_query> monero_tx_query::copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const {
|
||||
return copy(static_pointer_cast<monero_tx_query>(src), static_pointer_cast<monero_tx_query>(tgt));
|
||||
};
|
||||
|
||||
shared_ptr<monero_tx_request> monero_tx_request::copy(const shared_ptr<monero_tx_request>& src, const shared_ptr<monero_tx_request>& tgt) const {
|
||||
MTRACE("monero_tx_request::copy(const shared_ptr<monero_tx_request>& src, const shared_ptr<monero_tx_request>& tgt)");
|
||||
shared_ptr<monero_tx_query> monero_tx_query::copy(const shared_ptr<monero_tx_query>& src, const shared_ptr<monero_tx_query>& tgt) const {
|
||||
MTRACE("monero_tx_query::copy(const shared_ptr<monero_tx_query>& src, const shared_ptr<monero_tx_query>& tgt)");
|
||||
if (this != src.get()) throw runtime_error("this != src");
|
||||
|
||||
// copy base class
|
||||
monero_tx_wallet::copy(static_pointer_cast<monero_tx>(src), static_pointer_cast<monero_tx>(tgt));
|
||||
|
||||
// copy request extensions
|
||||
// copy query extensions
|
||||
tgt->m_is_outgoing = src->m_is_outgoing;
|
||||
tgt->m_is_incoming = src->m_is_incoming;
|
||||
if (!src->m_tx_ids.empty()) tgt->m_tx_ids = vector<string>(src->m_tx_ids);
|
||||
@@ -209,12 +209,12 @@ namespace monero {
|
||||
tgt->m_min_height = src->m_min_height;
|
||||
tgt->m_max_height = src->m_max_height;
|
||||
tgt->m_include_outputs = src->m_include_outputs;
|
||||
if (src->m_transfer_request != boost::none) tgt->m_transfer_request = src->m_transfer_request.get()->copy(src->m_transfer_request.get(), make_shared<monero_transfer_request>());
|
||||
if (src->m_output_request != boost::none) tgt->m_output_request = src->m_output_request.get()->copy(src->m_output_request.get(), make_shared<monero_output_request>());
|
||||
if (src->m_transfer_query != boost::none) tgt->m_transfer_query = src->m_transfer_query.get()->copy(src->m_transfer_query.get(), make_shared<monero_transfer_query>());
|
||||
if (src->m_output_query != boost::none) tgt->m_output_query = src->m_output_query.get()->copy(src->m_output_query.get(), make_shared<monero_output_query>());
|
||||
return tgt;
|
||||
};
|
||||
|
||||
boost::property_tree::ptree monero_tx_request::to_property_tree() const {
|
||||
boost::property_tree::ptree monero_tx_query::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_tx_wallet::to_property_tree();
|
||||
if (m_is_outgoing != boost::none) node.put("isOutgoing", *m_is_outgoing);
|
||||
if (m_is_incoming != boost::none) node.put("isIncoming", *m_is_incoming);
|
||||
@@ -225,11 +225,11 @@ namespace monero {
|
||||
if (m_min_height != boost::none) node.put("minHeight", *m_min_height);
|
||||
if (m_max_height != boost::none) node.put("maxHeight", *m_max_height);
|
||||
if (m_include_outputs != boost::none) node.put("includeOutputs", *m_include_outputs);
|
||||
if (m_transfer_request != boost::none) node.add_child("transferRequest", (*m_transfer_request)->to_property_tree());
|
||||
if (m_transfer_query != boost::none) node.add_child("transferQuery", (*m_transfer_query)->to_property_tree());
|
||||
return node;
|
||||
}
|
||||
|
||||
bool monero_tx_request::meets_criteria(monero_tx_wallet* tx) const {
|
||||
bool monero_tx_query::meets_criteria(monero_tx_wallet* tx) const {
|
||||
if (tx == nullptr) return false;
|
||||
|
||||
// filter on tx
|
||||
@@ -241,13 +241,13 @@ namespace monero {
|
||||
if (m_is_failed != boost::none && m_is_failed != tx->m_is_failed) return false;
|
||||
if (m_is_miner_tx != boost::none && m_is_miner_tx != tx->m_is_miner_tx) return false;
|
||||
|
||||
// at least one transfer must meet transfer request if defined
|
||||
if (m_transfer_request != boost::none) {
|
||||
// at least one transfer must meet transfer query if defined
|
||||
if (m_transfer_query != boost::none) {
|
||||
bool matchFound = false;
|
||||
if (tx->m_outgoing_transfer != boost::none && (*m_transfer_request)->meets_criteria((*tx->m_outgoing_transfer).get())) matchFound = true;
|
||||
if (tx->m_outgoing_transfer != boost::none && (*m_transfer_query)->meets_criteria((*tx->m_outgoing_transfer).get())) matchFound = true;
|
||||
else if (!tx->m_incoming_transfers.empty()) {
|
||||
for (const shared_ptr<monero_incoming_transfer>& incomingTransfer : tx->m_incoming_transfers) {
|
||||
if ((*m_transfer_request)->meets_criteria(incomingTransfer.get())) {
|
||||
if ((*m_transfer_query)->meets_criteria(incomingTransfer.get())) {
|
||||
matchFound = true;
|
||||
break;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ namespace monero {
|
||||
if (m_min_height != boost::none && (txHeight == boost::none || *txHeight < *m_min_height)) return false;
|
||||
if (m_max_height != boost::none && (txHeight == boost::none || *txHeight > *m_max_height)) return false;
|
||||
|
||||
// transaction meets request criteria
|
||||
// transaction meets query criteria
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -407,12 +407,12 @@ namespace monero {
|
||||
|
||||
// ----------------------- MONERO TRANSFER REQUEST --------------------------
|
||||
|
||||
shared_ptr<monero_transfer_request> monero_transfer_request::copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const {
|
||||
return copy(static_pointer_cast<monero_transfer_request>(src), static_pointer_cast<monero_transfer>(tgt));
|
||||
shared_ptr<monero_transfer_query> monero_transfer_query::copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const {
|
||||
return copy(static_pointer_cast<monero_transfer_query>(src), static_pointer_cast<monero_transfer>(tgt));
|
||||
};
|
||||
|
||||
shared_ptr<monero_transfer_request> monero_transfer_request::copy(const shared_ptr<monero_transfer_request>& src, const shared_ptr<monero_transfer_request>& tgt) const {
|
||||
MTRACE("monero_transfer_request::copy(const shared_ptr<monero_transfer_request>& src, const shared_ptr<monero_transfer_request>& tgt)");
|
||||
shared_ptr<monero_transfer_query> monero_transfer_query::copy(const shared_ptr<monero_transfer_query>& src, const shared_ptr<monero_transfer_query>& tgt) const {
|
||||
MTRACE("monero_transfer_query::copy(const shared_ptr<monero_transfer_query>& src, const shared_ptr<monero_transfer_query>& tgt)");
|
||||
if (this != src.get()) throw runtime_error("this != src");
|
||||
|
||||
// copy base class
|
||||
@@ -430,13 +430,13 @@ namespace monero {
|
||||
}
|
||||
}
|
||||
tgt->m_has_destinations = src->m_has_destinations;
|
||||
tgt->m_tx_request = src->m_tx_request;
|
||||
tgt->m_tx_query = src->m_tx_query;
|
||||
return tgt;
|
||||
};
|
||||
|
||||
boost::optional<bool> monero_transfer_request::is_incoming() const { return m_is_incoming; }
|
||||
boost::optional<bool> monero_transfer_query::is_incoming() const { return m_is_incoming; }
|
||||
|
||||
boost::property_tree::ptree monero_transfer_request::to_property_tree() const {
|
||||
boost::property_tree::ptree monero_transfer_query::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_transfer::to_property_tree();
|
||||
if (is_incoming() != boost::none) node.put("isIncoming", *is_incoming());
|
||||
if (m_address != boost::none) node.put("address", *m_address);
|
||||
@@ -448,9 +448,9 @@ namespace monero {
|
||||
return node;
|
||||
}
|
||||
|
||||
bool monero_transfer_request::meets_criteria(monero_transfer* transfer) const {
|
||||
bool monero_transfer_query::meets_criteria(monero_transfer* transfer) const {
|
||||
if (transfer == nullptr) throw runtime_error("transfer is null");
|
||||
if (m_tx_request != boost::none && (*m_tx_request)->m_transfer_request != boost::none) throw runtime_error("Transfer request's tx request cannot have a circular transfer request"); // TODO: could auto detect and handle this. port to java/js
|
||||
if (m_tx_query != boost::none && (*m_tx_query)->m_transfer_query != boost::none) throw runtime_error("Transfer query's tx query cannot have a circular transfer query"); // TODO: could auto detect and handle this. port to java/js
|
||||
|
||||
// filter on common fields
|
||||
if (is_incoming() != boost::none && *is_incoming() != *transfer->is_incoming()) return false;
|
||||
@@ -515,8 +515,8 @@ namespace monero {
|
||||
// validate type
|
||||
if (inTransfer == nullptr && out_transfer == nullptr) throw runtime_error("Transfer must be monero_incoming_transfer or monero_outgoing_transfer");
|
||||
|
||||
// filter with tx request
|
||||
if (m_tx_request != boost::none && !(*m_tx_request)->meets_criteria(transfer->m_tx.get())) return false;
|
||||
// filter with tx query
|
||||
if (m_tx_query != boost::none && !(*m_tx_query)->meets_criteria(transfer->m_tx.get())) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -563,16 +563,16 @@ namespace monero {
|
||||
|
||||
// ------------------------ MONERO OUTPUT REQUEST ---------------------------
|
||||
|
||||
shared_ptr<monero_output_request> monero_output_request::copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const {
|
||||
return monero_output_request::copy(static_pointer_cast<monero_output_request>(src), static_pointer_cast<monero_output_request>(tgt));
|
||||
shared_ptr<monero_output_query> monero_output_query::copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const {
|
||||
return monero_output_query::copy(static_pointer_cast<monero_output_query>(src), static_pointer_cast<monero_output_query>(tgt));
|
||||
};
|
||||
|
||||
shared_ptr<monero_output_request> monero_output_request::copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const {
|
||||
return monero_output_request::copy(static_pointer_cast<monero_output_request>(src), static_pointer_cast<monero_output_request>(tgt));
|
||||
shared_ptr<monero_output_query> monero_output_query::copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const {
|
||||
return monero_output_query::copy(static_pointer_cast<monero_output_query>(src), static_pointer_cast<monero_output_query>(tgt));
|
||||
};
|
||||
|
||||
shared_ptr<monero_output_request> monero_output_request::copy(const shared_ptr<monero_output_request>& src, const shared_ptr<monero_output_request>& tgt) const {
|
||||
MTRACE("monero_output_request::copy(output_request)");
|
||||
shared_ptr<monero_output_query> monero_output_query::copy(const shared_ptr<monero_output_query>& src, const shared_ptr<monero_output_query>& tgt) const {
|
||||
MTRACE("monero_output_query::copy(output_query)");
|
||||
if (this != src.get()) throw runtime_error("this != src");
|
||||
|
||||
// copy base class
|
||||
@@ -583,13 +583,13 @@ namespace monero {
|
||||
return tgt;
|
||||
};
|
||||
|
||||
boost::property_tree::ptree monero_output_request::to_property_tree() const {
|
||||
boost::property_tree::ptree monero_output_query::to_property_tree() const {
|
||||
boost::property_tree::ptree node = monero_output_wallet::to_property_tree();
|
||||
if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices));
|
||||
return node;
|
||||
}
|
||||
|
||||
bool monero_output_request::meets_criteria(monero_output_wallet* output) const {
|
||||
bool monero_output_query::meets_criteria(monero_output_wallet* output) const {
|
||||
|
||||
// filter on output
|
||||
if (m_account_index != boost::none && *m_account_index != *output->m_account_index) return false;
|
||||
@@ -608,10 +608,10 @@ namespace monero {
|
||||
// filter on extensions
|
||||
if (!m_subaddress_indices.empty() && find(m_subaddress_indices.begin(), m_subaddress_indices.end(), *output->m_subaddress_index) == m_subaddress_indices.end()) return false;
|
||||
|
||||
// filter with tx request
|
||||
if (m_tx_request != boost::none && !(*m_tx_request)->meets_criteria(static_pointer_cast<monero_tx_wallet>(output->m_tx).get())) return false;
|
||||
// filter with tx query
|
||||
if (m_tx_query != boost::none && !(*m_tx_query)->meets_criteria(static_pointer_cast<monero_tx_wallet>(output->m_tx).get())) return false;
|
||||
|
||||
// output meets request
|
||||
// output meets query
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ namespace monero {
|
||||
|
||||
// forward declarations
|
||||
struct monero_tx_wallet;
|
||||
struct monero_tx_request;
|
||||
struct monero_tx_query;
|
||||
|
||||
/**
|
||||
* Models an outgoing transfer destination.
|
||||
@@ -190,11 +190,11 @@ namespace monero {
|
||||
};
|
||||
|
||||
/**
|
||||
* Configures a request to retrieve transfers.
|
||||
* Configures a query to retrieve transfers.
|
||||
*
|
||||
* All transfers are returned except those that do not meet the criteria defined in this request.
|
||||
* All transfers are returned except those that do not meet the criteria defined in this query.
|
||||
*/
|
||||
struct monero_transfer_request : public monero_transfer {
|
||||
struct monero_transfer_query : public monero_transfer {
|
||||
boost::optional<bool> m_is_incoming;
|
||||
boost::optional<string> m_address;
|
||||
vector<string> m_addresses;
|
||||
@@ -202,10 +202,10 @@ namespace monero {
|
||||
vector<uint32_t> m_subaddress_indices;
|
||||
vector<shared_ptr<monero_destination>> m_destinations;
|
||||
boost::optional<bool> m_has_destinations;
|
||||
boost::optional<shared_ptr<monero_tx_request>> m_tx_request;
|
||||
boost::optional<shared_ptr<monero_tx_query>> m_tx_query;
|
||||
|
||||
shared_ptr<monero_transfer_request> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
|
||||
shared_ptr<monero_transfer_request> copy(const shared_ptr<monero_transfer_request>& src, const shared_ptr<monero_transfer_request>& tgt) const;
|
||||
shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
|
||||
shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer_query>& src, const shared_ptr<monero_transfer_query>& tgt) const;
|
||||
boost::optional<bool> is_incoming() const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
bool meets_criteria(monero_transfer* transfer) const;
|
||||
@@ -229,19 +229,19 @@ namespace monero {
|
||||
};
|
||||
|
||||
/**
|
||||
* Configures a request to retrieve wallet outputs (i.e. outputs that the wallet has or had the
|
||||
* Configures a query to retrieve wallet outputs (i.e. outputs that the wallet has or had the
|
||||
* ability to spend).
|
||||
*
|
||||
* All outputs are returned except those that do not meet the criteria defined in this request.
|
||||
* All outputs are returned except those that do not meet the criteria defined in this query.
|
||||
*/
|
||||
struct monero_output_request : public monero_output_wallet {
|
||||
struct monero_output_query : public monero_output_wallet {
|
||||
vector<uint32_t> m_subaddress_indices;
|
||||
boost::optional<shared_ptr<monero_tx_request>> m_tx_request;
|
||||
boost::optional<shared_ptr<monero_tx_query>> m_tx_query;
|
||||
|
||||
// TODO: necessary to override all super classes?
|
||||
shared_ptr<monero_output_request> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
|
||||
shared_ptr<monero_output_request> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
|
||||
shared_ptr<monero_output_request> copy(const shared_ptr<monero_output_request>& src, const shared_ptr<monero_output_request>& tgt) const;
|
||||
shared_ptr<monero_output_query> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
|
||||
shared_ptr<monero_output_query> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
|
||||
shared_ptr<monero_output_query> copy(const shared_ptr<monero_output_query>& src, const shared_ptr<monero_output_query>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
bool meets_criteria(monero_output_wallet* output) const;
|
||||
};
|
||||
@@ -264,11 +264,11 @@ namespace monero {
|
||||
};
|
||||
|
||||
/**
|
||||
* Configures a request to retrieve transactions.
|
||||
* Configures a query to retrieve transactions.
|
||||
*
|
||||
* All transactions are returned except those that do not meet the criteria defined in this request.
|
||||
* All transactions are returned except those that do not meet the criteria defined in this query.
|
||||
*/
|
||||
struct monero_tx_request : public monero_tx_wallet {
|
||||
struct monero_tx_query : public monero_tx_wallet {
|
||||
boost::optional<bool> m_is_outgoing;
|
||||
boost::optional<bool> m_is_incoming;
|
||||
vector<string> m_tx_ids;
|
||||
@@ -278,13 +278,13 @@ namespace monero {
|
||||
boost::optional<uint64_t> m_min_height;
|
||||
boost::optional<uint64_t> m_max_height;
|
||||
boost::optional<uint64_t> m_include_outputs;
|
||||
boost::optional<shared_ptr<monero_transfer_request>> m_transfer_request;
|
||||
boost::optional<shared_ptr<monero_output_request>> m_output_request;
|
||||
boost::optional<shared_ptr<monero_transfer_query>> m_transfer_query;
|
||||
boost::optional<shared_ptr<monero_output_query>> m_output_query;
|
||||
|
||||
// TODO: necessary to override all super classes?
|
||||
shared_ptr<monero_tx_request> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
|
||||
shared_ptr<monero_tx_request> copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const;
|
||||
shared_ptr<monero_tx_request> copy(const shared_ptr<monero_tx_request>& src, const shared_ptr<monero_tx_request>& tgt) const;
|
||||
shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
|
||||
shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const;
|
||||
shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx_query>& src, const shared_ptr<monero_tx_query>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
bool meets_criteria(monero_tx_wallet* tx) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user