remove old property tree serialization code;

rename to_json_val -> to_rapidjson_val
This commit is contained in:
woodser
2019-11-30 17:24:11 -05:00
parent c3bc05d979
commit 2db2b209f5
6 changed files with 209 additions and 621 deletions
+115 -213
View File
@@ -3,7 +3,7 @@
// rapidjson::Value root(rapidjson::kObjectType);
// // serialize root from superclass
// rapidjson::Value root = superclass::to_json_val(allocator);
// rapidjson::Value root = superclass::to_rapidjson_val(allocator);
//
// // set num values
// rapidjson::Value value_num(rapidjson::kNumberType);
@@ -32,19 +32,19 @@
// if (m_todo != boost::none) monero_utils::addJsonMember("m_todo", m_todo.get(), allocator, root);
//
// // set sub-arrays
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_json_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_json_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_json_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_json_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_json_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_rapidjson_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_rapidjson_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_rapidjson_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_rapidjson_val(allocator, m_todos), allocator);
// if (!m_todos.empty()) root.AddMember("todos", monero_utils::to_rapidjson_val(allocator, m_todos), allocator);
//
// // set sub-objects
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_json_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_json_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_json_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_json_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_json_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_json_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_rapidjson_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_rapidjson_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_rapidjson_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_rapidjson_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_rapidjson_val(allocator), allocator);
// if (m_todo != boost::none) root.AddMember("todo", m_todo.get()->to_rapidjson_val(allocator), allocator);
//
// // return root
// return root;
@@ -135,21 +135,14 @@ namespace monero {
string serializable_struct::serialize() const {
rapidjson::Document doc;
doc.SetObject();
rapidjson::Value val = to_json_val(doc.GetAllocator());
rapidjson::Value val = to_rapidjson_val(doc.GetAllocator());
val.Swap(doc);
return monero_utils::serialize(doc);
}
// ----------------------------- MONERO VERSION -----------------------------
// boost::property_tree::ptree monero_version::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_version_number != boost::none) node.put("versionNumber", *m_version_number);
// if (m_is_release != boost::none) node.put("isRelease", *m_is_release);
// return node;
// }
rapidjson::Value monero_version::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_version::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -167,30 +160,7 @@ namespace monero {
// ------------------------- MONERO BLOCK HEADER ----------------------------
// boost::property_tree::ptree monero_block_header::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_id != boost::none) node.put("id", *m_id);
// if (m_height != boost::none) node.put("height", *m_height);
// if (m_timestamp != boost::none) node.put("timestamp", *m_timestamp);
// if (m_size != boost::none) node.put("size", *m_size);
// if (m_weight != boost::none) node.put("weight", *m_weight);
// if (m_long_term_weight != boost::none) node.put("longTermWeight", *m_long_term_weight);
// if (m_depth != boost::none) node.put("depth", *m_depth);
// if (m_difficulty != boost::none) node.put("difficulty", *m_difficulty);
// if (m_cumulative_difficulty != boost::none) node.put("cumulativeDifficulty", *m_cumulative_difficulty);
// if (m_major_version != boost::none) node.put("majorVersion", *m_major_version);
// if (m_minor_version != boost::none) node.put("minorVersion", *m_minor_version);
// if (m_nonce != boost::none) node.put("m_nonce", *m_nonce);
// if (m_miner_tx_id != boost::none) node.put("minerTxId", *m_miner_tx_id);
// if (m_num_txs != boost::none) node.put("numTxs", *m_num_txs);
// if (m_orphan_status != boost::none) node.put("orphanStatus", *m_orphan_status);
// if (m_prev_id != boost::none) node.put("prevId", *m_prev_id);
// if (m_reward != boost::none) node.put("m_reward", *m_reward);
// if (m_pow_hash != boost::none) node.put("powHash", *m_pow_hash);
// return node;
// }
rapidjson::Value monero_block_header::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_block_header::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -250,30 +220,21 @@ namespace monero {
// ----------------------------- MONERO BLOCK -------------------------------
// boost::property_tree::ptree monero_block::to_property_tree() const {
// boost::property_tree::ptree node = monero_block_header::to_property_tree();
// if (m_hex != boost::none) node.put("hex", *m_hex);
// if (m_miner_tx != boost::none) node.add_child("minerTx", (*m_miner_tx)->to_property_tree());
// if (!m_txs.empty()) node.add_child("txs", monero_utils::to_property_tree(m_txs));
// if (!m_tx_ids.empty()) node.add_child("txIds", monero_utils::to_property_tree(m_tx_ids));
// return node;
// }
rapidjson::Value monero_block::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_block::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_block_header::to_json_val(allocator);
rapidjson::Value root = monero_block_header::to_rapidjson_val(allocator);
// set string values
rapidjson::Value value_str(rapidjson::kStringType);
if (m_hex != boost::none) monero_utils::addJsonMember("hex", m_hex.get(), allocator, root, value_str);
// set sub-arrays
if (!m_txs.empty()) root.AddMember("txs", monero_utils::to_json_val(allocator, m_txs), allocator);
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_json_val(allocator, m_tx_ids), allocator);
if (!m_txs.empty()) root.AddMember("txs", monero_utils::to_rapidjson_val(allocator, m_txs), allocator);
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_ids), allocator);
// set sub-objects
if (m_miner_tx != boost::none) root.AddMember("minerTx", m_miner_tx.get()->to_json_val(allocator), allocator);
if (m_miner_tx != boost::none) root.AddMember("minerTx", m_miner_tx.get()->to_rapidjson_val(allocator), allocator);
// return root
return root;
@@ -312,147 +273,105 @@ namespace monero {
// ------------------------------- MONERO TX --------------------------------
// boost::property_tree::ptree monero_tx::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_id != boost::none) node.put("id", *m_id);
// if (m_version != boost::none) node.put("version", *m_version);
// 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_ring_size != boost::none) node.put("ringSize", *m_ring_size);
// 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);
// if (m_in_tx_pool != boost::none) node.put("inTxPool", *m_in_tx_pool);
// if (m_num_confirmations != boost::none) node.put("numConfirmations", *m_num_confirmations);
// if (m_unlock_time != boost::none) node.put("unlockTime", *m_unlock_time);
// if (m_last_relayed_timestamp != boost::none) node.put("lastRelayedTimestamp", *m_last_relayed_timestamp);
// if (m_received_timestamp != boost::none) node.put("receivedTimestamp", *m_received_timestamp);
// if (m_is_double_spend_seen != boost::none) node.put("isDoubleSpendSeen", *m_is_double_spend_seen);
// if (m_key != boost::none) node.put("key", *m_key);
// if (m_full_hex != boost::none) node.put("fullHex", *m_full_hex);
// if (m_pruned_hex != boost::none) node.put("prunedHex", *m_pruned_hex);
// if (m_prunable_hex != boost::none) node.put("prunableHex", *m_prunable_hex);
// if (m_prunable_hash != boost::none) node.put("prunableHash", *m_prunable_hash);
// if (m_size != boost::none) node.put("size", *m_size);
// if (m_weight != boost::none) node.put("weight", *m_weight);
// if (!m_vins.empty()) node.add_child("vins", monero_utils::to_property_tree(m_vins));
// if (!m_vouts.empty()) node.add_child("vouts", monero_utils::to_property_tree(m_vouts));
// if (!m_output_indices.empty()) throw runtime_error("m_output_indices not implemented");
// if (m_metadata != boost::none) node.put("metadata", *m_metadata);
// if (m_common_tx_sets != boost::none) throw runtime_error("m_common_tx_sets not implemented");
// if (!m_extra.empty()) node.add_child("extra", monero_utils::to_property_tree(m_extra));
// if (m_rct_signatures != boost::none) throw runtime_error("m_rct_signatures not implemented");
// if (m_rct_sig_prunable != boost::none) throw runtime_error("m_rct_sig_prunable not implemented");
// if (m_is_kept_by_block != boost::none) node.put("isKeptByBlock", *m_is_kept_by_block);
// if (m_is_failed != boost::none) node.put("isFailed", *m_is_failed);
// if (m_last_failed_height != boost::none) node.put("lastFailedHeight", *m_last_failed_height);
// if (m_last_failed_id != boost::none) node.put("lastFailedId", *m_last_failed_id);
// if (m_max_used_block_height != boost::none) node.put("maxUsedBlockHeight", *m_max_used_block_height);
// if (m_max_used_block_id != boost::none) node.put("maxUsedBlockId", *m_max_used_block_id);
// if (!m_signatures.empty()) throw runtime_error("m_signatures not implemented");
// return node;
// }
rapidjson::Value monero_tx::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_tx::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
// create root
rapidjson::Value root(rapidjson::kObjectType);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
if (m_version != boost::none) monero_utils::addJsonMember("version", m_version.get(), allocator, root, value_num);
if (m_fee != boost::none) monero_utils::addJsonMember("fee", m_fee.get(), allocator, root, value_num);
if (m_ring_size != boost::none) monero_utils::addJsonMember("ringSize", m_ring_size.get(), allocator, root, value_num);
if (m_num_confirmations != boost::none) monero_utils::addJsonMember("numConfirmations", m_num_confirmations.get(), allocator, root, value_num);
if (m_unlock_time != boost::none) monero_utils::addJsonMember("unlockTime", m_unlock_time.get(), allocator, root, value_num);
if (m_last_relayed_timestamp != boost::none) monero_utils::addJsonMember("lastRelayedTimestamp", m_last_relayed_timestamp.get(), allocator, root, value_num);
if (m_received_timestamp != boost::none) monero_utils::addJsonMember("receivedTimestamp", m_received_timestamp.get(), allocator, root, value_num);
if (m_size != boost::none) monero_utils::addJsonMember("size", m_size.get(), allocator, root, value_num);
if (m_weight != boost::none) monero_utils::addJsonMember("weight", m_weight.get(), allocator, root, value_num);
if (m_last_failed_height != boost::none) monero_utils::addJsonMember("lastFailedHeight", m_last_failed_height.get(), allocator, root, value_num);
if (m_max_used_block_height != boost::none) monero_utils::addJsonMember("maxUsedBlockHeight", m_max_used_block_height.get(), allocator, root, value_num);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
if (m_version != boost::none) monero_utils::addJsonMember("version", m_version.get(), allocator, root, value_num);
if (m_fee != boost::none) monero_utils::addJsonMember("fee", m_fee.get(), allocator, root, value_num);
if (m_ring_size != boost::none) monero_utils::addJsonMember("ringSize", m_ring_size.get(), allocator, root, value_num);
if (m_num_confirmations != boost::none) monero_utils::addJsonMember("numConfirmations", m_num_confirmations.get(), allocator, root, value_num);
if (m_unlock_time != boost::none) monero_utils::addJsonMember("unlockTime", m_unlock_time.get(), allocator, root, value_num);
if (m_last_relayed_timestamp != boost::none) monero_utils::addJsonMember("lastRelayedTimestamp", m_last_relayed_timestamp.get(), allocator, root, value_num);
if (m_received_timestamp != boost::none) monero_utils::addJsonMember("receivedTimestamp", m_received_timestamp.get(), allocator, root, value_num);
if (m_size != boost::none) monero_utils::addJsonMember("size", m_size.get(), allocator, root, value_num);
if (m_weight != boost::none) monero_utils::addJsonMember("weight", m_weight.get(), allocator, root, value_num);
if (m_last_failed_height != boost::none) monero_utils::addJsonMember("lastFailedHeight", m_last_failed_height.get(), allocator, root, value_num);
if (m_max_used_block_height != boost::none) monero_utils::addJsonMember("maxUsedBlockHeight", m_max_used_block_height.get(), allocator, root, value_num);
// set string values
rapidjson::Value value_str(rapidjson::kStringType);
if (m_id != boost::none) monero_utils::addJsonMember("id", m_id.get(), allocator, root, value_str);
if (m_payment_id != boost::none) monero_utils::addJsonMember("paymentId", m_payment_id.get(), allocator, root, value_str);
if (m_key != boost::none) monero_utils::addJsonMember("key", m_key.get(), allocator, root, value_str);
if (m_full_hex != boost::none) monero_utils::addJsonMember("fullHex", m_full_hex.get(), allocator, root, value_str);
if (m_pruned_hex != boost::none) monero_utils::addJsonMember("prunedHex", m_pruned_hex.get(), allocator, root, value_str);
if (m_prunable_hex != boost::none) monero_utils::addJsonMember("prunableHex", m_prunable_hex.get(), allocator, root, value_str);
if (m_prunable_hash != boost::none) monero_utils::addJsonMember("prunableHash", m_prunable_hash.get(), allocator, root, value_str);
if (m_metadata != boost::none) monero_utils::addJsonMember("metadata", m_metadata.get(), allocator, root, value_str);
if (m_common_tx_sets != boost::none) monero_utils::addJsonMember("commonTxSets", m_common_tx_sets.get(), allocator, root, value_str);
if (m_rct_signatures != boost::none) monero_utils::addJsonMember("rctSignatures", m_rct_signatures.get(), allocator, root, value_str);
if (m_rct_sig_prunable != boost::none) monero_utils::addJsonMember("rctSigPrunable", m_rct_sig_prunable.get(), allocator, root, value_str);
if (m_last_failed_id != boost::none) monero_utils::addJsonMember("lastFailedId", m_last_failed_id.get(), allocator, root, value_str);
if (m_max_used_block_id != boost::none) monero_utils::addJsonMember("maxUsedBlockId", m_max_used_block_id.get(), allocator, root, value_str);
// set string values
rapidjson::Value value_str(rapidjson::kStringType);
if (m_id != boost::none) monero_utils::addJsonMember("id", m_id.get(), allocator, root, value_str);
if (m_payment_id != boost::none) monero_utils::addJsonMember("paymentId", m_payment_id.get(), allocator, root, value_str);
if (m_key != boost::none) monero_utils::addJsonMember("key", m_key.get(), allocator, root, value_str);
if (m_full_hex != boost::none) monero_utils::addJsonMember("fullHex", m_full_hex.get(), allocator, root, value_str);
if (m_pruned_hex != boost::none) monero_utils::addJsonMember("prunedHex", m_pruned_hex.get(), allocator, root, value_str);
if (m_prunable_hex != boost::none) monero_utils::addJsonMember("prunableHex", m_prunable_hex.get(), allocator, root, value_str);
if (m_prunable_hash != boost::none) monero_utils::addJsonMember("prunableHash", m_prunable_hash.get(), allocator, root, value_str);
if (m_metadata != boost::none) monero_utils::addJsonMember("metadata", m_metadata.get(), allocator, root, value_str);
if (m_common_tx_sets != boost::none) monero_utils::addJsonMember("commonTxSets", m_common_tx_sets.get(), allocator, root, value_str);
if (m_rct_signatures != boost::none) monero_utils::addJsonMember("rctSignatures", m_rct_signatures.get(), allocator, root, value_str);
if (m_rct_sig_prunable != boost::none) monero_utils::addJsonMember("rctSigPrunable", m_rct_sig_prunable.get(), allocator, root, value_str);
if (m_last_failed_id != boost::none) monero_utils::addJsonMember("lastFailedId", m_last_failed_id.get(), allocator, root, value_str);
if (m_max_used_block_id != boost::none) monero_utils::addJsonMember("maxUsedBlockId", m_max_used_block_id.get(), allocator, root, value_str);
// set bool values
if (m_is_miner_tx != boost::none) monero_utils::addJsonMember("isMinerTx", m_is_miner_tx.get(), allocator, root);
if (m_do_not_relay != boost::none) monero_utils::addJsonMember("doNotRelay", m_do_not_relay.get(), allocator, root);
if (m_is_relayed != boost::none) monero_utils::addJsonMember("isRelayed", m_is_relayed.get(), allocator, root);
if (m_is_confirmed != boost::none) monero_utils::addJsonMember("isConfirmed", m_is_confirmed.get(), allocator, root);
if (m_in_tx_pool != boost::none) monero_utils::addJsonMember("inTxPool", m_in_tx_pool.get(), allocator, root);
if (m_is_double_spend_seen != boost::none) monero_utils::addJsonMember("isDoubleSpendSeen", m_is_double_spend_seen.get(), allocator, root);
if (m_is_kept_by_block != boost::none) monero_utils::addJsonMember("isKeptByBlock", m_is_kept_by_block.get(), allocator, root);
if (m_is_failed != boost::none) monero_utils::addJsonMember("isFailed", m_is_failed.get(), allocator, root);
// set bool values
if (m_is_miner_tx != boost::none) monero_utils::addJsonMember("isMinerTx", m_is_miner_tx.get(), allocator, root);
if (m_do_not_relay != boost::none) monero_utils::addJsonMember("doNotRelay", m_do_not_relay.get(), allocator, root);
if (m_is_relayed != boost::none) monero_utils::addJsonMember("isRelayed", m_is_relayed.get(), allocator, root);
if (m_is_confirmed != boost::none) monero_utils::addJsonMember("isConfirmed", m_is_confirmed.get(), allocator, root);
if (m_in_tx_pool != boost::none) monero_utils::addJsonMember("inTxPool", m_in_tx_pool.get(), allocator, root);
if (m_is_double_spend_seen != boost::none) monero_utils::addJsonMember("isDoubleSpendSeen", m_is_double_spend_seen.get(), allocator, root);
if (m_is_kept_by_block != boost::none) monero_utils::addJsonMember("isKeptByBlock", m_is_kept_by_block.get(), allocator, root);
if (m_is_failed != boost::none) monero_utils::addJsonMember("isFailed", m_is_failed.get(), allocator, root);
// set sub-arrays
if (!m_vins.empty()) root.AddMember("vins", monero_utils::to_rapidjson_val(allocator, m_vins), allocator);
if (!m_vouts.empty()) root.AddMember("vouts", monero_utils::to_rapidjson_val(allocator, m_vouts), allocator);
if (!m_output_indices.empty()) root.AddMember("outputIndices", monero_utils::to_rapidjson_val(allocator, m_output_indices), allocator);
if (!m_extra.empty()) root.AddMember("extra", monero_utils::to_rapidjson_val(allocator, m_extra), allocator); // TODO
if (!m_signatures.empty()) root.AddMember("signatures", monero_utils::to_rapidjson_val(allocator, m_signatures), allocator);
// set sub-arrays
if (!m_vins.empty()) root.AddMember("vins", monero_utils::to_json_val(allocator, m_vins), allocator);
if (!m_vouts.empty()) root.AddMember("vouts", monero_utils::to_json_val(allocator, m_vouts), allocator);
if (!m_output_indices.empty()) root.AddMember("outputIndices", monero_utils::to_json_val(allocator, m_output_indices), allocator);
if (!m_extra.empty()) root.AddMember("extra", monero_utils::to_json_val(allocator, m_extra), allocator); // TODO
if (!m_signatures.empty()) root.AddMember("signatures", monero_utils::to_json_val(allocator, m_signatures), allocator);
// return root
return root;
}
// return root
return root;
void monero_tx::from_property_tree(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx) {
// initialize tx from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("id")) tx->m_id = it->second.data();
else if (key == string("version")) throw runtime_error("version deserializationn not implemented");
else if (key == string("isMinerTx")) tx->m_is_miner_tx = it->second.get_value<bool>();
else if (key == string("paymentId")) tx->m_payment_id = it->second.data(); // TODO: this threw runtime_error, how is "Can get transactions by payment ids" test passing in Java?
else if (key == string("fee")) tx->m_fee = it->second.get_value<uint64_t>();
else if (key == string("mixin")) throw runtime_error("mixin deserialization not implemented");
else if (key == string("doNotRelay")) tx->m_do_not_relay = it->second.get_value<bool>();
else if (key == string("isRelayed")) tx->m_is_relayed = it->second.get_value<bool>();
else if (key == string("isConfirmed")) tx->m_is_confirmed = it->second.get_value<bool>();
else if (key == string("inTxPool")) tx->m_in_tx_pool = it->second.get_value<bool>();
else if (key == string("numConfirmations")) tx->m_num_confirmations = it->second.get_value<uint64_t>();
else if (key == string("unlockTime")) tx->m_unlock_time = it->second.get_value<uint64_t>();
else if (key == string("lastRelayedTimestamp")) tx->m_last_relayed_timestamp = it->second.get_value<uint64_t>();
else if (key == string("receivedTimestamp")) tx->m_received_timestamp = it->second.get_value<uint64_t>();
else if (key == string("isDoubleSpendSeen")) tx->m_is_double_spend_seen = it->second.get_value<bool>();
else if (key == string("key")) tx->m_key = it->second.data();
else if (key == string("fullHex")) tx->m_full_hex = it->second.data();
else if (key == string("prunedHex")) tx->m_pruned_hex = it->second.data();
else if (key == string("prunableHex")) tx->m_prunable_hex = it->second.data();
else if (key == string("prunableHash")) tx->m_prunable_hash = it->second.data();
else if (key == string("size")) throw runtime_error("size deserialization not implemented");
else if (key == string("weight")) throw runtime_error("weight deserialization not implemented");
else if (key == string("vins")) throw runtime_error("vins deserializationn not implemented");
else if (key == string("vouts")) throw runtime_error("vouts deserializationn not implemented");
else if (key == string("outputIndices")) throw runtime_error("m_output_indices deserialization not implemented");
else if (key == string("metadata")) tx->m_metadata = it->second.data();
else if (key == string("commonTxSets")) throw runtime_error("commonTxSets deserialization not implemented");
else if (key == string("extra")) throw runtime_error("extra deserialization not implemented");
else if (key == string("rctSignatures")) throw runtime_error("rctSignatures deserialization not implemented");
else if (key == string("rctSigPrunable")) throw runtime_error("rctSigPrunable deserialization not implemented");
else if (key == string("isKeptByBlock")) tx->m_is_kept_by_block = it->second.get_value<bool>();
else if (key == string("isFailed")) tx->m_is_failed = it->second.get_value<bool>();
else if (key == string("lastFailedHeight")) throw runtime_error("lastFailedHeight deserialization not implemented");
else if (key == string("lastFailedId")) tx->m_last_failed_id = it->second.data();
else if (key == string("maxUsedBlockHeight")) throw runtime_error("maxUsedBlockHeight deserialization not implemented");
else if (key == string("maxUsedBlockId")) tx->m_max_used_block_id = it->second.data();
else if (key == string("signatures")) throw runtime_error("signatures deserialization not implemented");
}
void monero_tx::from_property_tree(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx) {
// initialize tx from node
for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) {
string key = it->first;
if (key == string("id")) tx->m_id = it->second.data();
else if (key == string("version")) throw runtime_error("version deserializationn not implemented");
else if (key == string("isMinerTx")) tx->m_is_miner_tx = it->second.get_value<bool>();
else if (key == string("paymentId")) tx->m_payment_id = it->second.data(); // TODO: this threw runtime_error, how is "Can get transactions by payment ids" test passing in Java?
else if (key == string("fee")) tx->m_fee = it->second.get_value<uint64_t>();
else if (key == string("mixin")) throw runtime_error("mixin deserialization not implemented");
else if (key == string("doNotRelay")) tx->m_do_not_relay = it->second.get_value<bool>();
else if (key == string("isRelayed")) tx->m_is_relayed = it->second.get_value<bool>();
else if (key == string("isConfirmed")) tx->m_is_confirmed = it->second.get_value<bool>();
else if (key == string("inTxPool")) tx->m_in_tx_pool = it->second.get_value<bool>();
else if (key == string("numConfirmations")) tx->m_num_confirmations = it->second.get_value<uint64_t>();
else if (key == string("unlockTime")) tx->m_unlock_time = it->second.get_value<uint64_t>();
else if (key == string("lastRelayedTimestamp")) tx->m_last_relayed_timestamp = it->second.get_value<uint64_t>();
else if (key == string("receivedTimestamp")) tx->m_received_timestamp = it->second.get_value<uint64_t>();
else if (key == string("isDoubleSpendSeen")) tx->m_is_double_spend_seen = it->second.get_value<bool>();
else if (key == string("key")) tx->m_key = it->second.data();
else if (key == string("fullHex")) tx->m_full_hex = it->second.data();
else if (key == string("prunedHex")) tx->m_pruned_hex = it->second.data();
else if (key == string("prunableHex")) tx->m_prunable_hex = it->second.data();
else if (key == string("prunableHash")) tx->m_prunable_hash = it->second.data();
else if (key == string("size")) throw runtime_error("size deserialization not implemented");
else if (key == string("weight")) throw runtime_error("weight deserialization not implemented");
else if (key == string("vins")) throw runtime_error("vins deserializationn not implemented");
else if (key == string("vouts")) throw runtime_error("vouts deserializationn not implemented");
else if (key == string("outputIndices")) throw runtime_error("m_output_indices deserialization not implemented");
else if (key == string("metadata")) tx->m_metadata = it->second.data();
else if (key == string("commonTxSets")) throw runtime_error("commonTxSets deserialization not implemented");
else if (key == string("extra")) throw runtime_error("extra deserialization not implemented");
else if (key == string("rctSignatures")) throw runtime_error("rctSignatures deserialization not implemented");
else if (key == string("rctSigPrunable")) throw runtime_error("rctSigPrunable deserialization not implemented");
else if (key == string("isKeptByBlock")) tx->m_is_kept_by_block = it->second.get_value<bool>();
else if (key == string("isFailed")) tx->m_is_failed = it->second.get_value<bool>();
else if (key == string("lastFailedHeight")) throw runtime_error("lastFailedHeight deserialization not implemented");
else if (key == string("lastFailedId")) tx->m_last_failed_id = it->second.data();
else if (key == string("maxUsedBlockHeight")) throw runtime_error("maxUsedBlockHeight deserialization not implemented");
else if (key == string("maxUsedBlockId")) tx->m_max_used_block_id = it->second.data();
else if (key == string("signatures")) throw runtime_error("signatures deserialization not implemented");
}
}
shared_ptr<monero_tx> monero_tx::copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const {
@@ -672,14 +591,7 @@ namespace monero {
// --------------------------- MONERO KEY IMAGE -----------------------------
// boost::property_tree::ptree monero_key_image::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_hex != boost::none) node.put("hex", *m_hex);
// if (m_signature != boost::none) node.put("signature", *m_signature);
// return node;
// }
rapidjson::Value monero_key_image::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_key_image::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -739,7 +651,7 @@ namespace monero {
// ------------------------------ MONERO OUTPUT -----------------------------
rapidjson::Value monero_output::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_output::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -751,10 +663,10 @@ namespace monero {
if (m_stealth_public_key != boost::none) monero_utils::addJsonMember("stealthPublicKey", m_stealth_public_key.get(), allocator, root, value_num);
// set sub-arrays
if (!m_ring_output_indices.empty()) root.AddMember("ringOutputIndices", monero_utils::to_json_val(allocator, m_ring_output_indices), allocator);
if (!m_ring_output_indices.empty()) root.AddMember("ringOutputIndices", monero_utils::to_rapidjson_val(allocator, m_ring_output_indices), allocator);
// set sub-objects
if (m_key_image != boost::none) root.AddMember("keyImage", m_key_image.get()->to_json_val(allocator), allocator);
if (m_key_image != boost::none) root.AddMember("keyImage", m_key_image.get()->to_rapidjson_val(allocator), allocator);
// return root
return root;
@@ -788,16 +700,6 @@ namespace monero {
return tgt;
}
// boost::property_tree::ptree monero_output::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_key_image != boost::none) node.add_child("keyImage", (*m_key_image)->to_property_tree());
// if (m_amount != boost::none) node.put("amount", *m_amount);
// if (m_index != boost::none) node.put("index", *m_index);
// if (!m_ring_output_indices.empty()) node.add_child("ringOutputIndices", monero_utils::to_property_tree(m_ring_output_indices));
// if (m_stealth_public_key != boost::none) node.put("stealthPublicKey", *m_stealth_public_key);
// return node;
// }
void monero_output::merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other) {
if (this != self.get()) throw runtime_error("this != self");
if (self == other) return;
+7 -21
View File
@@ -77,20 +77,13 @@ namespace monero {
*/
string serialize() const;
// /**
// * Convert the struct to a property tree.
// *
// * @return the converted property tree
// */
// virtual boost::property_tree::ptree to_property_tree() const = 0;
/**
* Converts the struct to a rapidjson Value.
*
* @param allocator is the rapidjson document allocator
* @return the struct as a rapidjson Value
*/
virtual rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const = 0;
virtual rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const = 0;
};
/**
@@ -109,8 +102,7 @@ namespace monero {
boost::optional<uint32_t> m_version_number;
boost::optional<bool> m_is_release;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -154,8 +146,7 @@ namespace monero {
boost::optional<uint64_t> m_reward;
boost::optional<string> m_pow_hash;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
virtual void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
};
@@ -168,9 +159,7 @@ namespace monero {
vector<shared_ptr<monero_tx>> m_txs;
vector<string> m_tx_ids;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
void merge(const shared_ptr<monero_block>& self, const shared_ptr<monero_block>& other);
};
@@ -219,8 +208,7 @@ namespace monero {
boost::optional<string> m_max_used_block_id;
vector<string> m_signatures;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx);
shared_ptr<monero_tx> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
virtual void merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other);
@@ -234,8 +222,7 @@ namespace monero {
boost::optional<string> m_hex;
boost::optional<string> m_signature;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_key_image>& key_image);
static vector<shared_ptr<monero_key_image>> deserialize_key_images(const string& key_images_json); // TODO: remove this specialty util used once
shared_ptr<monero_key_image> copy(const shared_ptr<monero_key_image>& src, const shared_ptr<monero_key_image>& tgt) const;
@@ -253,8 +240,7 @@ namespace monero {
vector<uint64_t> m_ring_output_indices;
boost::optional<string> m_stealth_public_key;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_output>& output);
shared_ptr<monero_output> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
virtual void merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other);
+7 -48
View File
@@ -170,7 +170,7 @@ void monero_utils::addJsonMember(string key, bool val, rapidjson::Document::Allo
}
}
rapidjson::Value monero_utils::to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<string>& strs) {
rapidjson::Value monero_utils::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<string>& strs) {
rapidjson::Value value_arr(rapidjson::kArrayType);
rapidjson::Value value_str(rapidjson::kStringType);
for (const string& str : strs) {
@@ -180,7 +180,7 @@ rapidjson::Value monero_utils::to_json_val(rapidjson::Document::AllocatorType& a
return value_arr;
}
rapidjson::Value monero_utils::to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<uint8_t>& nums) {
rapidjson::Value monero_utils::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<uint8_t>& nums) {
rapidjson::Value value_arr(rapidjson::kArrayType);
rapidjson::Value value_num(rapidjson::kNumberType);
for (const auto& num : nums) {
@@ -191,7 +191,7 @@ rapidjson::Value monero_utils::to_json_val(rapidjson::Document::AllocatorType& a
}
// TODO: remove these redundant implementations for different sizes?
rapidjson::Value monero_utils::to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<uint32_t>& nums) {
rapidjson::Value monero_utils::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<uint32_t>& nums) {
rapidjson::Value value_arr(rapidjson::kArrayType);
rapidjson::Value value_num(rapidjson::kNumberType);
for (const auto& num : nums) {
@@ -201,7 +201,7 @@ rapidjson::Value monero_utils::to_json_val(rapidjson::Document::AllocatorType& a
return value_arr;
}
rapidjson::Value monero_utils::to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<uint64_t>& nums) {
rapidjson::Value monero_utils::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<uint64_t>& nums) {
rapidjson::Value value_arr(rapidjson::kArrayType);
rapidjson::Value value_num(rapidjson::kNumberType);
for (const auto& num : nums) {
@@ -213,7 +213,7 @@ rapidjson::Value monero_utils::to_json_val(rapidjson::Document::AllocatorType& a
// ------------------------ PROPERTY TREES ---------------------------
// TODO: fully switch to rapidjson
// TODO: switch to rapidjson
string monero_utils::serialize(const boost::property_tree::ptree& node) {
std::stringstream ss;
@@ -222,7 +222,6 @@ string monero_utils::serialize(const boost::property_tree::ptree& node) {
return str.substr(0, str.size() - 1); // strip newline
}
// TODO: switch deserializes in this utils class to use this deserialize util
void monero_utils::deserialize(const string& json, boost::property_tree::ptree& root) {
std::istringstream iss = json.empty() ? std::istringstream() : std::istringstream(json);
try {
@@ -232,50 +231,10 @@ void monero_utils::deserialize(const string& json, boost::property_tree::ptree&
}
}
//boost::property_tree::ptree monero_utils::to_property_tree(const vector<string>& strs) {
// boost::property_tree::ptree strsNode;
// for (const auto& str : strs) {
// boost::property_tree::ptree strNode;
// strNode.put("", str);
// strsNode.push_back(std::make_pair("", strNode));
// }
// return strsNode;
//}
//
//boost::property_tree::ptree monero_utils::to_property_tree(const vector<uint8_t>& nums) {
// boost::property_tree::ptree numsNode;
// for (const auto& num : nums) {
// boost::property_tree::ptree numNode;
// numNode.put("", num);
// numsNode.push_back(std::make_pair("", numNode));
// }
// return numsNode;
//}
//
//// TODO: remove these redundant implementations for different sizes?
//boost::property_tree::ptree monero_utils::to_property_tree(const vector<uint32_t>& nums) {
// boost::property_tree::ptree numsNode;
// for (const auto& num : nums) {
// boost::property_tree::ptree numNode;
// numNode.put("", num);
// numsNode.push_back(std::make_pair("", numNode));
// }
// return numsNode;
//}
//
//boost::property_tree::ptree monero_utils::to_property_tree(const vector<uint64_t>& nums) {
// boost::property_tree::ptree numsNode;
// for (const auto& num : nums) {
// boost::property_tree::ptree numNode;
// numNode.put("", num);
// numsNode.push_back(std::make_pair("", numNode));
// }
// return numsNode;
//}
// ----------------------------------------------------------------------------
// TODO: is this unused?
// TODO: this is unused
shared_ptr<monero_block> monero_utils::cn_block_to_block(const cryptonote::block& cn_block) {
cryptonote::block temp = cn_block;
cout << cryptonote::obj_to_json_str(temp) << endl;
+8 -34
View File
@@ -66,8 +66,6 @@ namespace monero_utils
using namespace std;
using namespace cryptonote;
void dummy_method(const string& str); // TODO: remove this
// ------------------------ BINARY SERIALIZATION ----------------------------
void json_to_binary(const std::string &json, std::string &bin);
@@ -85,27 +83,27 @@ namespace monero_utils
void addJsonMember(string key, bool val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root);
// TODO: template implementation here, could move to monero_utils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation
template <class T> rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<shared_ptr<T>>& vals) {
template <class T> rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<shared_ptr<T>>& vals) {
rapidjson::Value value_arr(rapidjson::kArrayType);
for (const auto& val : vals) {
value_arr.PushBack(val->to_json_val(allocator), allocator);
value_arr.PushBack(val->to_rapidjson_val(allocator), allocator);
}
return value_arr;
}
// TODO: template implementation here, could move to monero_utils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation
template <class T> rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<T>& vals) {
template <class T> rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<T>& vals) {
rapidjson::Value value_arr(rapidjson::kArrayType);
for (const auto& val : vals) {
value_arr.PushBack(val.to_json_val(allocator), allocator);
value_arr.PushBack(val.to_rapidjson_val(allocator), allocator);
}
return value_arr;
}
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<string>& strs);
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<uint8_t>& nums);
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<uint32_t>& nums);
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator, const vector<uint64_t>& nums);
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<string>& strs);
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<uint8_t>& nums);
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<uint32_t>& nums);
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator, const vector<uint64_t>& nums);
// ------------------------ PROPERTY TREES ---------------------------
@@ -114,30 +112,6 @@ namespace monero_utils
string serialize(const boost::property_tree::ptree& node);
void deserialize(const string& json, boost::property_tree::ptree& root);
//
// // TODO: template implementation here, could move to monero_utils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation
// template <class T> boost::property_tree::ptree to_property_tree(const vector<shared_ptr<T>>& types) {
// boost::property_tree::ptree typeNodes;
// for (const auto& type : types) {
// typeNodes.push_back(std::make_pair("", type->to_property_tree()));
// }
// return typeNodes;
// }
//
// // TODO: template implementation here, could move to monero_utils.hpp per https://stackoverflow.com/questions/3040480/c-template-function-compiles-in-header-but-not-implementation
// template <class T> boost::property_tree::ptree to_property_tree(const vector<T>& types) {
// boost::property_tree::ptree typeNodes;
// for (const auto& type : types) {
// typeNodes.push_back(std::make_pair("", type.to_property_tree()));
// }
// return typeNodes;
// }
//
// boost::property_tree::ptree to_property_tree(const vector<string>& strs);
// boost::property_tree::ptree to_property_tree(const vector<uint8_t>& nums);
// boost::property_tree::ptree to_property_tree(const vector<uint32_t>& nums);
// boost::property_tree::ptree to_property_tree(const vector<uint64_t>& nums);
// --------------------------------------------------------------------------
/**
+49 -262
View File
@@ -94,7 +94,7 @@ namespace monero {
// -------------------------- MONERO SYNC RESULT ----------------------------
rapidjson::Value monero_sync_result::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_sync_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -112,17 +112,7 @@ namespace monero {
// -------------------------- MONERO ACCOUNT -----------------------------
// boost::property_tree::ptree monero_account::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_index != boost::none) node.put("index", *m_index);
// if (m_primary_address != boost::none) node.put("primaryAddress", *m_primary_address);
// if (m_balance != boost::none) node.put("balance", *m_balance);
// if (m_unlocked_balance != boost::none) node.put("unlockedBalance", *m_unlocked_balance);
// if (!m_subaddresses.empty()) node.add_child("subaddresses", monero_utils::to_property_tree(m_subaddresses));
// return node;
// }
rapidjson::Value monero_account::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_account::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -139,7 +129,7 @@ namespace monero {
if (m_tag != boost::none) monero_utils::addJsonMember("tag", m_tag.get(), allocator, root, value_str);
// set subaddresses
if (!m_subaddresses.empty()) root.AddMember("subaddresses", monero_utils::to_json_val(allocator, m_subaddresses), allocator);
if (!m_subaddresses.empty()) root.AddMember("subaddresses", monero_utils::to_rapidjson_val(allocator, m_subaddresses), allocator);
// return root
return root;
@@ -147,21 +137,7 @@ namespace monero {
// -------------------------- MONERO SUBADDRESS -----------------------------
// boost::property_tree::ptree monero_subaddress::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_account_index != boost::none) node.put("accountIndex", *m_account_index);
// if (m_index != boost::none) node.put("index", *m_index);
// if (m_address != boost::none) node.put("address", *m_address);
// if (m_label != boost::none) node.put("label", *m_label);
// if (m_balance != boost::none) node.put("balance", *m_balance);
// if (m_unlocked_balance != boost::none) node.put("unlockedBalance", *m_unlocked_balance);
// if (m_num_unspent_outputs != boost::none) node.put("numUnspentOutputs", *m_num_unspent_outputs);
// if (m_is_used != boost::none) node.put("isUsed", *m_is_used);
// if (m_num_blocks_to_unlock != boost::none) node.put("numBlocksToUnlock", *m_num_blocks_to_unlock);
// return node;
// }
rapidjson::Value monero_subaddress::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_subaddress::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -189,27 +165,10 @@ namespace monero {
// --------------------------- MONERO TX WALLET -----------------------------
// boost::property_tree::ptree monero_tx_wallet::to_property_tree() const {
// boost::property_tree::ptree node = monero_tx::to_property_tree();
// if (m_is_incoming != boost::none) node.put("isIncoming", *m_is_incoming);
// if (m_is_outgoing != boost::none) node.put("isOutgoing", *m_is_outgoing);
// if (!m_incoming_transfers.empty()) node.add_child("incomingTransfers", monero_utils::to_property_tree(m_incoming_transfers));
// if (m_outgoing_transfer != boost::none) node.add_child("outgoingTransfer", (*m_outgoing_transfer)->to_property_tree());
// if (m_note != boost::none) node.put("note", *m_note);
// if (m_is_locked != boost::none) node.put("isLocked", *m_is_locked);
// if (m_input_sum != boost::none) node.put("inputSum", *m_input_sum);
// if (m_output_sum != boost::none) node.put("outputSum", *m_output_sum);
// if (m_change_address != boost::none) node.put("changeAddress", *m_change_address);
// if (m_change_amount != boost::none) node.put("changeAmount", *m_change_amount);
// if (m_num_dummy_outputs != boost::none) node.put("numDummyOutputs", *m_num_dummy_outputs);
// if (m_extra_hex != boost::none) node.put("extraHex", *m_extra_hex);
// return node;
// }
rapidjson::Value monero_tx_wallet::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_tx_wallet::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_tx::to_json_val(allocator);
rapidjson::Value root = monero_tx::to_rapidjson_val(allocator);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
@@ -230,10 +189,10 @@ namespace monero {
if (m_is_locked != boost::none) monero_utils::addJsonMember("isLocked", m_is_locked.get(), allocator, root);
// set sub-arrays
if (!m_incoming_transfers.empty()) root.AddMember("incomingTransfers", monero_utils::to_json_val(allocator, m_incoming_transfers), allocator);
if (!m_incoming_transfers.empty()) root.AddMember("incomingTransfers", monero_utils::to_rapidjson_val(allocator, m_incoming_transfers), allocator);
// set sub-objects
if (m_outgoing_transfer != boost::none) root.AddMember("outgoingTransfer", m_outgoing_transfer.get()->to_json_val(allocator), allocator);
if (m_outgoing_transfer != boost::none) root.AddMember("outgoingTransfer", m_outgoing_transfer.get()->to_rapidjson_val(allocator), allocator);
// return root
return root;
@@ -332,25 +291,10 @@ namespace monero {
// -------------------------- MONERO TX QUERY -----------------------------
// 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);
// if (!m_tx_ids.empty()) node.add_child("txIds", monero_utils::to_property_tree(m_tx_ids));
// if (m_has_payment_id != boost::none) node.put("hasPaymentId", *m_has_payment_id);
// if (!m_payment_ids.empty()) node.add_child("paymentIds", monero_utils::to_property_tree(m_payment_ids));
// if (m_height != boost::none) node.put("height", *m_height);
// 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_query != boost::none) node.add_child("transferQuery", (*m_transfer_query)->to_property_tree());
// return node;
// }
rapidjson::Value monero_tx_query::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_tx_query::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_tx_wallet::to_json_val(allocator);
rapidjson::Value root = monero_tx_wallet::to_rapidjson_val(allocator);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
@@ -365,11 +309,11 @@ namespace monero {
if (m_include_outputs != boost::none) monero_utils::addJsonMember("includeOutputs", m_include_outputs.get(), allocator, root);
// set sub-arrays
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_json_val(allocator, m_tx_ids), allocator);
if (!m_payment_ids.empty()) root.AddMember("paymentIds", monero_utils::to_json_val(allocator, m_payment_ids), allocator);
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_ids), allocator);
if (!m_payment_ids.empty()) root.AddMember("paymentIds", monero_utils::to_rapidjson_val(allocator, m_payment_ids), allocator);
// set sub-objects
if (m_transfer_query != boost::none) root.AddMember("transferQuery", m_transfer_query.get()->to_json_val(allocator), allocator);
if (m_transfer_query != boost::none) root.AddMember("transferQuery", m_transfer_query.get()->to_rapidjson_val(allocator), allocator);
// return root
return root;
@@ -516,14 +460,7 @@ namespace monero {
// -------------------------- MONERO DESTINATION ----------------------------
// boost::property_tree::ptree monero_destination::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_address != boost::none) node.put("address", *m_address);
// if (m_amount != boost::none) node.put("amount", *m_amount);
// return node;
// }
rapidjson::Value monero_destination::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_destination::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -558,16 +495,7 @@ namespace monero {
// ----------------------------- MONERO TX SET ------------------------------
// boost::property_tree::ptree monero_tx_set::to_property_tree() const {
// boost::property_tree::ptree node;
// if (!m_txs.empty()) node.add_child("txs", monero_utils::to_property_tree(m_txs));
// if (m_multisig_tx_hex != boost::none) node.put("multisigTxHex", *m_multisig_tx_hex);
// if (m_unsigned_tx_hex != boost::none) node.put("unsignedTxHex", *m_unsigned_tx_hex);
// if (m_signed_tx_hex != boost::none) node.put("signedTxHex", *m_signed_tx_hex);
// return node;
// }
rapidjson::Value monero_tx_set::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_tx_set::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -579,7 +507,7 @@ namespace monero {
if (m_signed_tx_hex != boost::none) monero_utils::addJsonMember("signedTxHex", m_signed_tx_hex.get(), allocator, root, value_str);
// set sub-arrays
if (!m_txs.empty()) root.AddMember("txs", monero_utils::to_json_val(allocator, m_txs), allocator);
if (!m_txs.empty()) root.AddMember("txs", monero_utils::to_rapidjson_val(allocator, m_txs), allocator);
// return root
return root;
@@ -614,16 +542,7 @@ namespace monero {
// ---------------------------- MONERO TRANSFER -----------------------------
// boost::property_tree::ptree monero_transfer::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_amount != boost::none) node.put("amount", *m_amount);
// if (m_account_index != boost::none) node.put("accountIndex", *m_account_index);
// if (m_num_suggested_confirmations != boost::none) node.put("numSuggestedConfirmations", *m_num_suggested_confirmations);
// return node;
// }
rapidjson::Value monero_transfer::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_transfer::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -682,17 +601,10 @@ namespace monero {
// ----------------------- MONERO INCOMING TRANSFER -------------------------
// boost::property_tree::ptree monero_incoming_transfer::to_property_tree() const {
// boost::property_tree::ptree node = monero_transfer::to_property_tree();
// if (m_subaddress_index != boost::none) node.put("subaddressIndex", *m_subaddress_index);
// if (m_address != boost::none) node.put("address", *m_address);
// return node;
// }
rapidjson::Value monero_incoming_transfer::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_incoming_transfer::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_transfer::to_json_val(allocator);
rapidjson::Value root = monero_transfer::to_rapidjson_val(allocator);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
@@ -730,23 +642,15 @@ namespace monero {
// ----------------------- MONERO OUTGOING TRANSFER -------------------------
// boost::property_tree::ptree monero_outgoing_transfer::to_property_tree() const {
// boost::property_tree::ptree node = monero_transfer::to_property_tree();
// if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices));
// if (!m_addresses.empty()) node.add_child("addresses", monero_utils::to_property_tree(m_addresses));
// if (!m_destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(m_destinations));
// return node;
// }
rapidjson::Value monero_outgoing_transfer::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_outgoing_transfer::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_transfer::to_json_val(allocator);
rapidjson::Value root = monero_transfer::to_rapidjson_val(allocator);
// set sub-arrays
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_json_val(allocator, m_subaddress_indices), allocator);
if (!m_addresses.empty()) root.AddMember("addresses", monero_utils::to_json_val(allocator, m_addresses), allocator);
if (!m_destinations.empty()) root.AddMember("destinations", monero_utils::to_json_val(allocator, m_destinations), allocator);
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_rapidjson_val(allocator, m_subaddress_indices), allocator);
if (!m_addresses.empty()) root.AddMember("addresses", monero_utils::to_rapidjson_val(allocator, m_addresses), allocator);
if (!m_destinations.empty()) root.AddMember("destinations", monero_utils::to_rapidjson_val(allocator, m_destinations), allocator);
// return root
return root;
@@ -777,10 +681,10 @@ namespace monero {
// ----------------------- MONERO TRANSFER REQUEST --------------------------
rapidjson::Value monero_transfer_query::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_transfer_query::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_transfer::to_json_val(allocator);
rapidjson::Value root = monero_transfer::to_rapidjson_val(allocator);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
@@ -795,9 +699,9 @@ namespace monero {
if (m_address != boost::none) monero_utils::addJsonMember("address", m_address.get(), allocator, root, value_str);
// set sub-arrays
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_json_val(allocator, m_subaddress_indices), allocator);
if (!m_addresses.empty()) root.AddMember("addresses", monero_utils::to_json_val(allocator, m_addresses), allocator);
if (!m_destinations.empty()) root.AddMember("destinations", monero_utils::to_json_val(allocator, m_destinations), allocator);
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_rapidjson_val(allocator, m_subaddress_indices), allocator);
if (!m_addresses.empty()) root.AddMember("addresses", monero_utils::to_rapidjson_val(allocator, m_addresses), allocator);
if (!m_destinations.empty()) root.AddMember("destinations", monero_utils::to_rapidjson_val(allocator, m_destinations), allocator);
// return root
return root;
@@ -952,34 +856,12 @@ namespace monero {
boost::optional<bool> monero_transfer_query::is_incoming() const { return m_is_incoming; }
// 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);
// if (m_subaddress_index != boost::none) node.put("subaddressIndex", *m_subaddress_index);
// if (m_has_destinations != boost::none) node.put("hasDestinations", *m_has_destinations);
// if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices));
// if (!m_addresses.empty()) node.add_child("addresses", monero_utils::to_property_tree(m_addresses));
// if (!m_destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(m_destinations));
// return node;
// }
// ------------------------- MONERO OUTPUT WALLET ---------------------------
// boost::property_tree::ptree monero_output_wallet::to_property_tree() const {
// boost::property_tree::ptree node = monero_output::to_property_tree();
// if (m_account_index != boost::none) node.put("accountIndex", *m_account_index);
// if (m_subaddress_index != boost::none) node.put("subaddressIndex", *m_subaddress_index);
// if (m_is_spent != boost::none) node.put("isSpent", *m_is_spent);
// if (m_is_unlocked != boost::none) node.put("isUnlocked", *m_is_unlocked);
// if (m_is_frozen != boost::none) node.put("isFrozen", *m_is_frozen);
// return node;
// }
rapidjson::Value monero_output_wallet::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_output_wallet::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_output::to_json_val(allocator);
rapidjson::Value root = monero_output::to_rapidjson_val(allocator);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
@@ -1047,13 +929,13 @@ namespace monero {
// ------------------------ MONERO OUTPUT REQUEST ---------------------------
rapidjson::Value monero_output_query::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_output_query::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_output_wallet::to_json_val(allocator);
rapidjson::Value root = monero_output_wallet::to_rapidjson_val(allocator);
// set sub-arrays
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_json_val(allocator, m_subaddress_indices), allocator);
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_rapidjson_val(allocator, m_subaddress_indices), allocator);
// return root
return root;
@@ -1149,12 +1031,6 @@ namespace monero {
return true;
}
// 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;
// }
// ------------------------- MONERO SEND REQUEST ----------------------------
monero_send_request::monero_send_request(const monero_send_request& request) {
@@ -1179,27 +1055,7 @@ namespace monero {
m_key_image = request.m_key_image;
}
// boost::property_tree::ptree monero_send_request::to_property_tree() const {
// boost::property_tree::ptree node;
// if (!m_destinations.empty()) node.add_child("destinations", monero_utils::to_property_tree(m_destinations));
// if (m_payment_id != boost::none) node.put("paymentId", *m_payment_id);
// if (m_priority != boost::none) node.put("priority", *m_priority);
// if (m_mixin != boost::none) node.put("mixin", *m_mixin);
// if (m_ring_size != boost::none) node.put("ringSize", *m_ring_size);
// if (m_account_index != boost::none) node.put("accountIndex", *m_account_index);
// if (!m_subaddress_indices.empty()) node.add_child("subaddressIndices", monero_utils::to_property_tree(m_subaddress_indices));
// if (m_unlock_time != boost::none) node.put("unlockTime", *m_unlock_time);
// if (m_can_split != boost::none) node.put("canSplit", *m_can_split);
// if (m_do_not_relay != boost::none) node.put("doNotRelay", *m_do_not_relay);
// if (m_note != boost::none) node.put("note", *m_note);
// if (m_recipient_name != boost::none) node.put("recipientName", *m_recipient_name);
// if (m_below_amount != boost::none) node.put("belowAmount", *m_below_amount);
// if (m_sweep_each_subaddress != boost::none) node.put("sweepEachSubaddress", *m_sweep_each_subaddress);
// if (m_key_image != boost::none) node.put("keyImage", *m_key_image);
// return node;
// }
rapidjson::Value monero_send_request::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_send_request::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -1225,8 +1081,8 @@ namespace monero {
if (m_sweep_each_subaddress != boost::none) monero_utils::addJsonMember("sweepEachSubaddress", m_sweep_each_subaddress.get(), allocator, root);
// set sub-arrays
if (!m_destinations.empty()) root.AddMember("destinations", monero_utils::to_json_val(allocator, m_destinations), allocator);
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_json_val(allocator, m_subaddress_indices), allocator);
if (!m_destinations.empty()) root.AddMember("destinations", monero_utils::to_rapidjson_val(allocator, m_destinations), allocator);
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_rapidjson_val(allocator, m_subaddress_indices), allocator);
// return root
return root;
@@ -1276,15 +1132,7 @@ namespace monero {
// ---------------------- MONERO INTEGRATED ADDRESS -------------------------
// boost::property_tree::ptree monero_integrated_address::to_property_tree() const {
// boost::property_tree::ptree node;
// node.put("standardAddress", m_standard_address);
// node.put("paymentId", m_payment_id);
// node.put("integratedAddress", m_integrated_address);
// return node;
// }
rapidjson::Value monero_integrated_address::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_integrated_address::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -1301,15 +1149,7 @@ namespace monero {
// -------------------- MONERO KEY IMAGE IMPORT RESULT ----------------------
// boost::property_tree::ptree monero_key_image_import_result::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_height != boost::none) node.put("height", *m_height);
// if (m_spent_amount != boost::none) node.put("spentAmount", *m_spent_amount);
// if (m_unspent_amount != boost::none) node.put("unspentAmount", *m_unspent_amount);
// return node;
// }
rapidjson::Value monero_key_image_import_result::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_key_image_import_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -1326,13 +1166,7 @@ namespace monero {
// ----------------------------- MONERO CHECK -------------------------------
// boost::property_tree::ptree monero_check::to_property_tree() const {
// boost::property_tree::ptree node;
// node.put("isGood", m_is_good);
// return node;
// }
rapidjson::Value monero_check::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_check::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -1346,18 +1180,10 @@ namespace monero {
// --------------------------- MONERO CHECK TX ------------------------------
// boost::property_tree::ptree monero_check_tx::to_property_tree() const {
// boost::property_tree::ptree node = monero_check::to_property_tree();;
// if (m_in_tx_pool != boost::none) node.put("inTxPool", *m_in_tx_pool);
// if (m_num_confirmations != boost::none) node.put("numConfirmations", *m_num_confirmations);
// if (m_received_amount != boost::none) node.put("receivedAmount", *m_received_amount);
// return node;
// }
rapidjson::Value monero_check_tx::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_check_tx::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_check::to_json_val(allocator);
rapidjson::Value root = monero_check::to_rapidjson_val(allocator);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
@@ -1373,17 +1199,10 @@ namespace monero {
// ------------------------ MONERO CHECK RESERVE ----------------------------
// boost::property_tree::ptree monero_check_reserve::to_property_tree() const {
// boost::property_tree::ptree node = monero_check::to_property_tree();
// if (m_total_amount != boost::none) node.put("totalAmount", *m_total_amount);
// if (m_unconfirmed_spent_amount != boost::none) node.put("unconfirmedSpentAmount", *m_unconfirmed_spent_amount);
// return node;
// }
rapidjson::Value monero_check_reserve::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_check_reserve::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// serialize root from superclass
rapidjson::Value root = monero_check::to_json_val(allocator);
rapidjson::Value root = monero_check::to_rapidjson_val(allocator);
// set num values
rapidjson::Value value_num(rapidjson::kNumberType);
@@ -1396,16 +1215,7 @@ namespace monero {
// --------------------------- MONERO MULTISIG ------------------------------
// boost::property_tree::ptree monero_multisig_info::to_property_tree() const {
// boost::property_tree::ptree node;
// node.put("isMultisig", m_is_multisig);
// node.put("isReady", m_is_ready);
// node.put("threshold", m_threshold);
// node.put("numParticipants", m_num_participants);
// return node;
// }
rapidjson::Value monero_multisig_info::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_multisig_info::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -1423,14 +1233,7 @@ namespace monero {
return root;
}
// boost::property_tree::ptree monero_multisig_init_result::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_address != boost::none) node.put("address", *m_address);
// if (m_multisig_hex != boost::none) node.put("multisigHex", *m_multisig_hex);
// return node;
// }
rapidjson::Value monero_multisig_init_result::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_multisig_init_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -1444,14 +1247,7 @@ namespace monero {
return root;
}
// boost::property_tree::ptree monero_multisig_sign_result::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_signed_multisig_tx_hex != boost::none) node.put("signedMultisigTxHex", *m_signed_multisig_tx_hex);
// if (!m_tx_ids.empty()) node.add_child("txIds", monero_utils::to_property_tree(m_tx_ids));
// return node;
// }
rapidjson::Value monero_multisig_sign_result::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_multisig_sign_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
@@ -1460,7 +1256,7 @@ namespace monero {
if (m_signed_multisig_tx_hex != boost::none) monero_utils::addJsonMember("signedMultisigTxHex", m_signed_multisig_tx_hex.get(), allocator, root, value_str);
// set sub-arrays
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_json_val(allocator, m_tx_ids), allocator);
if (!m_tx_ids.empty()) root.AddMember("txIds", monero_utils::to_rapidjson_val(allocator, m_tx_ids), allocator);
// return root
return root;
@@ -1468,16 +1264,7 @@ namespace monero {
// -------------------------- MONERO ADDRESS BOOK ---------------------------
// boost::property_tree::ptree monero_address_book_entry::to_property_tree() const {
// boost::property_tree::ptree node;
// if (m_index != boost::none) node.put("index", *m_index);
// if (m_address != boost::none) node.put("address", *m_address);
// if (m_description != boost::none) node.put("description", *m_description);
// if (m_payment_id != boost::none) node.put("paymentId", *m_payment_id);
// return node;
// }
rapidjson::Value monero_address_book_entry::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
rapidjson::Value monero_address_book_entry::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const {
// create root
rapidjson::Value root(rapidjson::kObjectType);
+23 -43
View File
@@ -71,7 +71,7 @@ namespace monero {
monero_sync_result() {}
monero_sync_result(const uint64_t num_blocks_fetched, const bool received_money) : m_num_blocks_fetched(num_blocks_fetched), m_received_money(received_money) {}
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -88,8 +88,7 @@ namespace monero {
boost::optional<bool> m_is_used;
boost::optional<uint64_t> m_num_blocks_to_unlock;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -103,8 +102,7 @@ namespace monero {
boost::optional<string> m_tag;
vector<monero_subaddress> m_subaddresses;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -116,8 +114,7 @@ namespace monero {
monero_destination() {}
monero_destination(const string& address, uint64_t amount) : m_address(address), m_amount(amount) {}
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_destination>& destination);
shared_ptr<monero_destination> copy(const shared_ptr<monero_destination>& src, const shared_ptr<monero_destination>& tgt) const;
};
@@ -136,8 +133,7 @@ namespace monero {
boost::optional<uint32_t> m_account_index;
boost::optional<uint64_t> m_num_suggested_confirmations;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_transfer>& transfer);
virtual boost::optional<bool> is_incoming() const = 0; // derived class must implement
shared_ptr<monero_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
@@ -155,8 +151,7 @@ namespace monero {
boost::optional<uint32_t> m_subaddress_index;
boost::optional<string> m_address;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
shared_ptr<monero_incoming_transfer> copy(const shared_ptr<monero_incoming_transfer>& src, const shared_ptr<monero_incoming_transfer>& tgt) const;
boost::optional<bool> is_incoming() const;
@@ -172,8 +167,7 @@ namespace monero {
vector<string> m_addresses;
vector<shared_ptr<monero_destination>> m_destinations;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
shared_ptr<monero_outgoing_transfer> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
shared_ptr<monero_outgoing_transfer> copy(const shared_ptr<monero_outgoing_transfer>& src, const shared_ptr<monero_outgoing_transfer>& tgt) const;
boost::optional<bool> is_incoming() const;
@@ -196,8 +190,7 @@ namespace monero {
boost::optional<bool> m_has_destinations;
boost::optional<shared_ptr<monero_tx_query>> m_tx_query;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_transfer_query>& transfer_query);
static shared_ptr<monero_transfer_query> deserialize(const string& transfer_query_json);
shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
@@ -215,8 +208,7 @@ namespace monero {
boost::optional<bool> m_is_spent;
boost::optional<bool> m_is_frozen;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_output_wallet>& output_wallet);
shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
shared_ptr<monero_output_wallet> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
@@ -235,7 +227,7 @@ namespace monero {
boost::optional<shared_ptr<monero_tx_query>> m_tx_query;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_output_query>& output_query);
static shared_ptr<monero_output_query> deserialize(const string& output_query_json);
bool is_default() const;
@@ -266,8 +258,7 @@ namespace monero {
boost::optional<uint32_t> m_num_dummy_outputs;
boost::optional<string> m_extra_hex;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_tx_wallet>& tx_wallet);
shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
shared_ptr<monero_tx_wallet> copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const;
@@ -293,8 +284,7 @@ namespace monero {
boost::optional<shared_ptr<monero_transfer_query>> m_transfer_query;
boost::optional<shared_ptr<monero_output_query>> m_output_query;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static void from_property_tree(const boost::property_tree::ptree& node, const shared_ptr<monero_tx_query>& tx_query);
static shared_ptr<monero_tx_query> deserialize(const string& tx_query_json);
shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
@@ -318,7 +308,7 @@ namespace monero {
boost::optional<string> m_multisig_tx_hex;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static monero_tx_set deserialize(const string& tx_set_json);
};
@@ -330,8 +320,7 @@ namespace monero {
string m_payment_id;
string m_integrated_address;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -366,8 +355,7 @@ namespace monero {
monero_send_request() {}
monero_send_request(const monero_send_request& request);
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
static shared_ptr<monero_send_request> deserialize(const string& send_request_json);
monero_send_request copy() const;
};
@@ -380,8 +368,7 @@ namespace monero {
boost::optional<uint64_t> m_spent_amount;
boost::optional<uint64_t> m_unspent_amount;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -390,8 +377,7 @@ namespace monero {
struct monero_check : public serializable_struct {
bool m_is_good;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -402,8 +388,7 @@ namespace monero {
boost::optional<uint64_t> m_num_confirmations;
boost::optional<uint64_t> m_received_amount;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -413,8 +398,7 @@ namespace monero {
boost::optional<uint64_t> m_total_amount;
boost::optional<uint64_t> m_unconfirmed_spent_amount;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -426,8 +410,7 @@ namespace monero {
uint32_t m_threshold;
uint32_t m_num_participants;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -439,8 +422,7 @@ namespace monero {
boost::optional<string> m_address;
boost::optional<string> m_multisig_hex;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -450,8 +432,7 @@ namespace monero {
boost::optional<string> m_signed_multisig_tx_hex;
vector<string> m_tx_ids;
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
/**
@@ -465,7 +446,6 @@ namespace monero {
monero_address_book_entry() {}
monero_address_book_entry(uint64_t index, const string& address, const string& description, const string& payment_id) : m_index(index), m_address(address), m_description(description), m_payment_id(payment_id) {}
//boost::property_tree::ptree to_property_tree() const;
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const;
};
}