mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-25 18:18:52 +01:00
remove old property tree serialization code;
rename to_json_val -> to_rapidjson_val
This commit is contained in:
+115
-213
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user