mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-19 08:08:39 +02:00
merge updates from latest wasm branch, mostly serializing using
rapidjson instead of boost::property_tree
This commit is contained in:
+7
-6
@@ -8,18 +8,19 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -std=c++11 -F/Library/Frameworks -
|
||||
|
||||
project(MoneroCppLibrary)
|
||||
|
||||
#############
|
||||
# System
|
||||
#############
|
||||
###################
|
||||
# monero-project
|
||||
###################
|
||||
|
||||
set(MONERO_CORE "external/monero-core")
|
||||
set(MONERO_CORE_SRC "${MONERO_CORE}/src")
|
||||
|
||||
# header includes
|
||||
include_directories(src/)
|
||||
include_directories(${MONERO_CORE}/contrib/epee/include)
|
||||
include_directories(${MONERO_CORE}/external/)
|
||||
include_directories(${MONERO_CORE}/external/easylogging++)
|
||||
include_directories("${MONERO_CORE}/contrib/epee/include")
|
||||
include_directories("${MONERO_CORE}/external/")
|
||||
include_directories("${MONERO_CORE}/external/easylogging++")
|
||||
include_directories("${MONERO_CORE}/external/rapidjson/include")
|
||||
include_directories("${MONERO_CORE_SRC}/")
|
||||
include_directories("${MONERO_CORE_SRC}/wallet")
|
||||
include_directories("${MONERO_CORE_SRC}/wallet/api")
|
||||
|
||||
@@ -1,3 +1,55 @@
|
||||
//SERIALIZATION TEMPLATE
|
||||
// // create root
|
||||
// rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// // serialize root from superclass
|
||||
// rapidjson::Value root = superclass::to_json_val(allocator);
|
||||
//
|
||||
// // set num values
|
||||
// rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_num);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_num);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_num);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_num);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_num);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_num);
|
||||
//
|
||||
// // set string values
|
||||
// rapidjson::Value value_str(rapidjson::kStringType);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_str);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_str);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_str);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_str);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("todo", m_todo.get(), allocator, root, value_str);
|
||||
//
|
||||
// // set bool values
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("m_todo", m_todo.get(), allocator, root);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("m_todo", m_todo.get(), allocator, root);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("m_todo", m_todo.get(), allocator, root);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("m_todo", m_todo.get(), allocator, root);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("m_todo", m_todo.get(), allocator, root);
|
||||
// if (m_todo != boost::none) monero_utils::addJsonMember("m_todo", m_todo.get(), allocator, root);
|
||||
// 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);
|
||||
//
|
||||
// // 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);
|
||||
//
|
||||
// // return root
|
||||
// return root;
|
||||
|
||||
|
||||
/**
|
||||
* Copyright (c) 2017-2019 woodser
|
||||
*
|
||||
@@ -81,41 +133,96 @@ namespace monero {
|
||||
// ------------------------- SERIALIZABLE STRUCT ----------------------------
|
||||
|
||||
string serializable_struct::serialize() const {
|
||||
return monero_utils::serialize(to_property_tree());
|
||||
rapidjson::Document doc;
|
||||
doc.SetObject();
|
||||
rapidjson::Value val = to_json_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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_version_number != boost::none) monero_utils::addJsonMember("versionNumber", m_version_number.get(), allocator, root, value_num);
|
||||
|
||||
// set bool values
|
||||
if (m_is_release != boost::none) monero_utils::addJsonMember("isRelease", m_is_release.get(), allocator, root);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
// ------------------------- 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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_height != boost::none) monero_utils::addJsonMember("height", m_height.get(), allocator, root, value_num);
|
||||
if (m_timestamp != boost::none) monero_utils::addJsonMember("timestamp", m_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_long_term_weight != boost::none) monero_utils::addJsonMember("longTermWeight", m_long_term_weight.get(), allocator, root, value_num);
|
||||
if (m_depth != boost::none) monero_utils::addJsonMember("depth", m_depth.get(), allocator, root, value_num);
|
||||
if (m_difficulty != boost::none) monero_utils::addJsonMember("difficulty", m_difficulty.get(), allocator, root, value_num);
|
||||
if (m_cumulative_difficulty != boost::none) monero_utils::addJsonMember("cumulativeDifficulty", m_cumulative_difficulty.get(), allocator, root, value_num);
|
||||
if (m_major_version != boost::none) monero_utils::addJsonMember("majorVersion", m_major_version.get(), allocator, root, value_num);
|
||||
if (m_minor_version != boost::none) monero_utils::addJsonMember("minorVersion", m_minor_version.get(), allocator, root, value_num);
|
||||
if (m_nonce != boost::none) monero_utils::addJsonMember("nonce", m_nonce.get(), allocator, root, value_num);
|
||||
if (m_miner_tx_id != boost::none) monero_utils::addJsonMember("minerTxId", m_miner_tx_id.get(), allocator, root, value_num);
|
||||
if (m_num_txs != boost::none) monero_utils::addJsonMember("numTxs", m_num_txs.get(), allocator, root, value_num);
|
||||
if (m_reward != boost::none) monero_utils::addJsonMember("reward", m_reward.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_prev_id != boost::none) monero_utils::addJsonMember("prevId", m_prev_id.get(), allocator, root, value_str);
|
||||
if (m_pow_hash != boost::none) monero_utils::addJsonMember("powHash", m_pow_hash.get(), allocator, root, value_str);
|
||||
|
||||
// set bool values
|
||||
if (m_orphan_status != boost::none) monero_utils::addJsonMember("orphanStatus", m_orphan_status.get(), allocator, root);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_block_header::merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other) {
|
||||
@@ -143,13 +250,33 @@ 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;
|
||||
// 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 {
|
||||
|
||||
// serialize root from superclass
|
||||
rapidjson::Value root = monero_block_header::to_json_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);
|
||||
|
||||
// set sub-objects
|
||||
if (m_miner_tx != boost::none) root.AddMember("minerTx", m_miner_tx.get()->to_json_val(allocator), allocator);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_block::merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other) {
|
||||
@@ -241,46 +368,102 @@ namespace monero {
|
||||
return tgt;
|
||||
}
|
||||
|
||||
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;
|
||||
// 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_json_val(rapidjson::Document::AllocatorType& allocator) const {
|
||||
|
||||
// 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 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 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;
|
||||
}
|
||||
|
||||
boost::optional<uint64_t> monero_tx::get_height() const {
|
||||
@@ -451,11 +634,25 @@ namespace monero {
|
||||
return tgt;
|
||||
}
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// 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);
|
||||
if (m_signature != boost::none) monero_utils::addJsonMember("signature", m_signature.get(), allocator, root, value_str);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_key_image::merge(const shared_ptr<monero_key_image>& self, const shared_ptr<monero_key_image>& other) {
|
||||
@@ -475,14 +672,35 @@ 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;
|
||||
// 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;
|
||||
// }
|
||||
|
||||
rapidjson::Value monero_output::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_amount != boost::none) monero_utils::addJsonMember("amount", m_amount.get(), allocator, root, value_num);
|
||||
if (m_index != boost::none) monero_utils::addJsonMember("index", m_index.get(), allocator, root, value_num);
|
||||
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);
|
||||
|
||||
// set sub-objects
|
||||
if (m_key_image != boost::none) root.AddMember("keyImage", m_key_image.get()->to_json_val(allocator), allocator);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_output::merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other) {
|
||||
|
||||
@@ -54,6 +54,9 @@
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include "rapidjson/document.h"
|
||||
#include "rapidjson/writer.h"
|
||||
#include "rapidjson/stringbuffer.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -74,12 +77,20 @@ 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;
|
||||
|
||||
/**
|
||||
* Convert the struct to a property tree.
|
||||
* Converts the struct to a rapidjson Value.
|
||||
*
|
||||
* @return the converted property tree
|
||||
* @param allocator is the rapidjson document allocator
|
||||
* @return the struct as a rapidjson Value
|
||||
*/
|
||||
virtual boost::property_tree::ptree to_property_tree() const = 0;
|
||||
virtual rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -97,7 +108,9 @@ namespace monero {
|
||||
struct monero_version : public serializable_struct {
|
||||
boost::optional<uint32_t> m_version_number;
|
||||
boost::optional<bool> m_is_release;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -141,7 +154,8 @@ namespace monero {
|
||||
boost::optional<uint64_t> m_reward;
|
||||
boost::optional<string> m_pow_hash;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
virtual void merge(const shared_ptr<monero_block_header>& self, const shared_ptr<monero_block_header>& other);
|
||||
};
|
||||
|
||||
@@ -154,7 +168,8 @@ namespace monero {
|
||||
vector<shared_ptr<monero_tx>> m_txs;
|
||||
vector<string> m_tx_ids;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_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);
|
||||
};
|
||||
@@ -204,7 +219,8 @@ namespace monero {
|
||||
vector<string> m_signatures;
|
||||
|
||||
shared_ptr<monero_tx> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
virtual void merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other);
|
||||
boost::optional<uint64_t> get_height() const;
|
||||
};
|
||||
@@ -217,7 +233,8 @@ namespace monero {
|
||||
boost::optional<string> m_signature;
|
||||
|
||||
shared_ptr<monero_key_image> copy(const shared_ptr<monero_key_image>& src, const shared_ptr<monero_key_image>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
void merge(const shared_ptr<monero_key_image>& self, const shared_ptr<monero_key_image>& other);
|
||||
};
|
||||
|
||||
@@ -233,7 +250,8 @@ namespace monero {
|
||||
boost::optional<string> m_stealth_public_key;
|
||||
|
||||
shared_ptr<monero_output> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
virtual void merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other);
|
||||
};
|
||||
}
|
||||
|
||||
+144
-38
@@ -54,6 +54,7 @@
|
||||
#include "rpc/core_rpc_server_commands_defs.h"
|
||||
#include "storages/portable_storage_template_helper.h"
|
||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||
#include "string_tools.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace cryptonote;
|
||||
@@ -148,6 +149,7 @@ shared_ptr<monero_output_query> node_to_output_query(const boost::property_tree:
|
||||
return m_output_query;
|
||||
}
|
||||
|
||||
// TODO: finish deserialization implementation, uses tests
|
||||
void node_to_tx(const boost::property_tree::ptree& node, shared_ptr<monero_tx> tx) {
|
||||
|
||||
// initialize tx from node
|
||||
@@ -156,7 +158,7 @@ void node_to_tx(const boost::property_tree::ptree& node, shared_ptr<monero_tx> t
|
||||
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")) throw runtime_error("paymentId deserializationn not implemented");
|
||||
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>();
|
||||
@@ -252,7 +254,7 @@ shared_ptr<monero_destination> node_to_destination(const boost::property_tree::p
|
||||
return destination;
|
||||
}
|
||||
|
||||
// ------------------------- PUBLIC STATIC UTILITIES --------------------------
|
||||
// -------------------------- BINARY SERIALIZATION ----------------------------
|
||||
|
||||
void monero_utils::json_to_binary(const std::string &json, std::string &bin) {
|
||||
epee::serialization::portable_storage ps;
|
||||
@@ -345,6 +347,93 @@ monero_tx_set monero_utils::deserialize_tx_set(const string& tx_set_str) {
|
||||
return tx_set;
|
||||
}
|
||||
|
||||
// ------------------------------- RAPIDJSON ----------------------------------
|
||||
|
||||
string monero_utils::serialize(const rapidjson::Document& doc) {
|
||||
rapidjson::StringBuffer buffer;
|
||||
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
|
||||
doc.Accept(writer);
|
||||
return buffer.GetString();
|
||||
}
|
||||
|
||||
void monero_utils::addJsonMember(string key, uint8_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) {
|
||||
rapidjson::Value field_key(key.c_str(), key.size(), allocator);
|
||||
field.SetInt(val);
|
||||
root.AddMember(field_key, field, allocator);
|
||||
}
|
||||
|
||||
void monero_utils::addJsonMember(string key, uint32_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) {
|
||||
rapidjson::Value field_key(key.c_str(), key.size(), allocator);
|
||||
field.SetUint64(val);
|
||||
root.AddMember(field_key, field, allocator);
|
||||
}
|
||||
|
||||
void monero_utils::addJsonMember(string key, uint64_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) {
|
||||
rapidjson::Value field_key(key.c_str(), key.size(), allocator);
|
||||
field.SetUint64(val);
|
||||
root.AddMember(field_key, field, allocator);
|
||||
}
|
||||
|
||||
void monero_utils::addJsonMember(string key, string val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field) {
|
||||
rapidjson::Value field_key(key.c_str(), key.size(), allocator);
|
||||
field.SetString(val.c_str(), val.size(), allocator);
|
||||
root.AddMember(field_key, field, allocator);
|
||||
}
|
||||
|
||||
void monero_utils::addJsonMember(string key, bool val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root) {
|
||||
rapidjson::Value field_key(key.c_str(), key.size(), allocator);
|
||||
if (val) {
|
||||
rapidjson::Value field_val(rapidjson::kTrueType);
|
||||
root.AddMember(field_key, field_val, allocator);
|
||||
} else {
|
||||
rapidjson::Value field_val(rapidjson::kFalseType);
|
||||
root.AddMember(field_key, field_val, allocator);
|
||||
}
|
||||
}
|
||||
|
||||
rapidjson::Value monero_utils::to_json_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) {
|
||||
value_str.SetString(str.c_str(), str.size(), allocator);
|
||||
value_arr.PushBack(value_str, allocator);
|
||||
}
|
||||
return value_arr;
|
||||
}
|
||||
|
||||
rapidjson::Value monero_utils::to_json_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) {
|
||||
value_num.SetInt(num);
|
||||
value_arr.PushBack(value_num, allocator);
|
||||
}
|
||||
return value_arr;
|
||||
}
|
||||
|
||||
// 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 value_arr(rapidjson::kArrayType);
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
for (const auto& num : nums) {
|
||||
value_num.SetUint64(num);
|
||||
value_arr.PushBack(value_num, allocator);
|
||||
}
|
||||
return value_arr;
|
||||
}
|
||||
|
||||
rapidjson::Value monero_utils::to_json_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) {
|
||||
value_num.SetUint64(num);
|
||||
value_arr.PushBack(value_num, allocator);
|
||||
}
|
||||
return value_arr;
|
||||
}
|
||||
|
||||
// -------------------------- MODEL DESERIALIZATION ---------------------------
|
||||
|
||||
shared_ptr<monero_tx_query> monero_utils::deserialize_tx_query(const string& tx_query_str) {
|
||||
|
||||
// deserialize tx query string to property rooted at block
|
||||
@@ -473,6 +562,10 @@ vector<shared_ptr<monero_key_image>> monero_utils::deserialize_key_images(const
|
||||
return key_images;
|
||||
}
|
||||
|
||||
// ------------------------ PROPERTY TREES ---------------------------
|
||||
|
||||
// TODO: fully switch to rapidjson
|
||||
|
||||
string monero_utils::serialize(const boost::property_tree::ptree& node) {
|
||||
std::stringstream ss;
|
||||
boost::property_tree::write_json(ss, node, false);
|
||||
@@ -480,47 +573,60 @@ string monero_utils::serialize(const boost::property_tree::ptree& node) {
|
||||
return str.substr(0, str.size() - 1); // strip newline
|
||||
}
|
||||
|
||||
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));
|
||||
// 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 {
|
||||
boost::property_tree::read_json(iss, root);
|
||||
} catch (std::exception const& e) {
|
||||
throw runtime_error("Invalid JSON");
|
||||
}
|
||||
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;
|
||||
}
|
||||
//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: 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?
|
||||
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;
|
||||
|
||||
+74
-34
@@ -53,38 +53,103 @@
|
||||
#ifndef monero_utils_h
|
||||
#define monero_utils_h
|
||||
|
||||
#include "wallet/monero_wallet.h"
|
||||
#include "wallet/monero_wallet_model.h"
|
||||
#include "cryptonote_basic/cryptonote_basic.h"
|
||||
#include "serialization/keyvalue_serialization.h" // TODO: consolidate with other binary deps?
|
||||
#include "storages/portable_storage.h"
|
||||
|
||||
/**
|
||||
* Collection of utilities for working with Monero's binary portable storage format.
|
||||
* Collection of utilities for the Monero library.
|
||||
*/
|
||||
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);
|
||||
|
||||
void binary_to_json(const std::string &bin, std::string &json);
|
||||
|
||||
void binary_blocks_to_json(const std::string &bin, std::string &json);
|
||||
|
||||
monero_tx_set deserialize_tx_set(const string& tx_set_str);
|
||||
// ------------------------------ RAPIDJSON ---------------------------------
|
||||
|
||||
string serialize(const rapidjson::Document& doc);
|
||||
|
||||
void addJsonMember(string key, uint8_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field);
|
||||
void addJsonMember(string key, uint32_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field);
|
||||
void addJsonMember(string key, uint64_t val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field);
|
||||
void addJsonMember(string key, string val, rapidjson::Document::AllocatorType& allocator, rapidjson::Value& root, rapidjson::Value& field);
|
||||
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) {
|
||||
rapidjson::Value value_arr(rapidjson::kArrayType);
|
||||
for (const auto& val : vals) {
|
||||
value_arr.PushBack(val->to_json_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) {
|
||||
rapidjson::Value value_arr(rapidjson::kArrayType);
|
||||
for (const auto& val : vals) {
|
||||
value_arr.PushBack(val.to_json_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);
|
||||
|
||||
// ------------------------ MODEL DESERIALIZATION ---------------------------
|
||||
|
||||
// TODO: move deserialization to static utilities on class
|
||||
|
||||
shared_ptr<monero_tx_query> deserialize_tx_query(const string& txQueryStr);
|
||||
|
||||
shared_ptr<monero_transfer_query> deserialize_transfer_query(const string& transfer_query_str);
|
||||
|
||||
shared_ptr<monero_output_query> deserialize_output_query(const string& output_query_str);
|
||||
|
||||
shared_ptr<monero_send_request> deserialize_send_request(const string& send_request_str);
|
||||
|
||||
vector<shared_ptr<monero_key_image>> deserialize_key_images(const string& key_images_json);
|
||||
monero_tx_set deserialize_tx_set(const string& tx_set_str);
|
||||
|
||||
// ------------------------ PROPERTY TREES ---------------------------
|
||||
|
||||
// TODO: fully switch from property trees to rapidjson
|
||||
|
||||
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);
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert a Monero Core cryptonote::block to a block in this library's native model.
|
||||
@@ -116,30 +181,5 @@ namespace monero_utils
|
||||
CHECK_AND_ASSERT_MES(r, std::string(), "Failed to serialize rct signatures base");
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
// ----------------------------- PROPERTY TREE ------------------------------
|
||||
|
||||
// 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);
|
||||
}
|
||||
#endif /* monero_utils_h */
|
||||
|
||||
+529
-168
@@ -50,7 +50,7 @@
|
||||
* Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
*/
|
||||
|
||||
#include "monero_wallet.h"
|
||||
#include "monero_wallet_model.h"
|
||||
|
||||
#include "utils/gen_utils.h"
|
||||
#include "utils/monero_utils.h"
|
||||
@@ -76,32 +76,99 @@ namespace monero {
|
||||
transfers.push_back(transfer);
|
||||
}
|
||||
|
||||
// ---------------------------- MONERO ACCOUNT ------------------------------
|
||||
// -------------------------- MONERO SYNC RESULT ----------------------------
|
||||
|
||||
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_sync_result::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
monero_utils::addJsonMember("numBlocksFetched", m_num_blocks_fetched, allocator, root, value_num);
|
||||
|
||||
// set bool values
|
||||
monero_utils::addJsonMember("receivedMoney", m_received_money, allocator, root);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
// -------------------------- 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_index != boost::none) monero_utils::addJsonMember("index", m_index.get(), allocator, root, value_num);
|
||||
if (m_balance != boost::none) monero_utils::addJsonMember("balance", m_balance.get(), allocator, root, value_num);
|
||||
if (m_unlocked_balance != boost::none) monero_utils::addJsonMember("unlockedBalance", m_unlocked_balance.get(), allocator, root, value_num);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_primary_address != boost::none) monero_utils::addJsonMember("primaryAddress", m_primary_address.get(), allocator, root, value_str);
|
||||
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);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
// -------------------------- 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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_account_index != boost::none) monero_utils::addJsonMember("accountIndex", m_account_index.get(), allocator, root, value_num);
|
||||
if (m_index != boost::none) monero_utils::addJsonMember("index", m_index.get(), allocator, root, value_num);
|
||||
if (m_balance != boost::none) monero_utils::addJsonMember("balance", m_balance.get(), allocator, root, value_num);
|
||||
if (m_unlocked_balance != boost::none) monero_utils::addJsonMember("unlockedBalance", m_unlocked_balance.get(), allocator, root, value_num);
|
||||
if (m_num_unspent_outputs != boost::none) monero_utils::addJsonMember("numUnspentOutputs", m_num_unspent_outputs.get(), allocator, root, value_num);
|
||||
if (m_num_blocks_to_unlock) monero_utils::addJsonMember("numBlocksToUnlock", m_num_blocks_to_unlock.get(), allocator, root, value_num);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_address != boost::none) monero_utils::addJsonMember("address", m_address.get(), allocator, root, value_str);
|
||||
if (m_label != boost::none) monero_utils::addJsonMember("label", m_label.get(), allocator, root, value_str);
|
||||
|
||||
// set bool values
|
||||
if (m_is_used != boost::none) monero_utils::addJsonMember("isUsed", m_is_used.get(), allocator, root);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
// --------------------------- MONERO TX WALLET -----------------------------
|
||||
@@ -147,21 +214,54 @@ namespace monero {
|
||||
return tgt;
|
||||
};
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
|
||||
// serialize root from superclass
|
||||
rapidjson::Value root = monero_tx::to_json_val(allocator);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_input_sum != boost::none) monero_utils::addJsonMember("inputSum", m_input_sum.get(), allocator, root, value_num);
|
||||
if (m_output_sum != boost::none) monero_utils::addJsonMember("outputSum", m_output_sum.get(), allocator, root, value_num);
|
||||
if (m_change_amount != boost::none) monero_utils::addJsonMember("changeAmount", m_change_amount.get(), allocator, root, value_num);
|
||||
if (m_num_dummy_outputs != boost::none) monero_utils::addJsonMember("numDummyOutputs", m_num_dummy_outputs.get(), allocator, root, value_num);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_note != boost::none) monero_utils::addJsonMember("note", m_note.get(), allocator, root, value_str);
|
||||
if (m_change_address != boost::none) monero_utils::addJsonMember("changeAddress", m_change_address.get(), allocator, root, value_str);
|
||||
if (m_extra_hex != boost::none) monero_utils::addJsonMember("extraHex", m_extra_hex.get(), allocator, root, value_str);
|
||||
|
||||
// set bool values
|
||||
if (m_is_incoming != boost::none) monero_utils::addJsonMember("isIncoming", m_is_incoming.get(), allocator, root);
|
||||
if (m_is_outgoing != boost::none) monero_utils::addJsonMember("isOutgoing", m_is_outgoing.get(), allocator, root);
|
||||
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);
|
||||
|
||||
// set sub-objects
|
||||
if (m_outgoing_transfer != boost::none) root.AddMember("outgoingTransfer", m_outgoing_transfer.get()->to_json_val(allocator), allocator);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_tx_wallet::merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other) {
|
||||
@@ -235,19 +335,47 @@ namespace monero {
|
||||
return tgt;
|
||||
};
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
|
||||
// serialize root from superclass
|
||||
rapidjson::Value root = monero_tx_wallet::to_json_val(allocator);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_height != boost::none) monero_utils::addJsonMember("height", m_height.get(), allocator, root, value_num);
|
||||
if (m_min_height != boost::none) monero_utils::addJsonMember("minHeight", m_min_height.get(), allocator, root, value_num);
|
||||
if (m_max_height != boost::none) monero_utils::addJsonMember("maxHeight", m_max_height.get(), allocator, root, value_num);
|
||||
|
||||
// set bool values
|
||||
if (m_is_outgoing != boost::none) monero_utils::addJsonMember("isOutgoing", m_is_outgoing.get(), allocator, root);
|
||||
if (m_is_incoming != boost::none) monero_utils::addJsonMember("isIncoming", m_is_incoming.get(), allocator, root);
|
||||
if (m_has_payment_id != boost::none) monero_utils::addJsonMember("hasPaymentId", m_has_payment_id.get(), allocator, root);
|
||||
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);
|
||||
|
||||
// set sub-objects
|
||||
if (m_transfer_query != boost::none) root.AddMember("transferQuery", m_transfer_query.get()->to_json_val(allocator), allocator);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
bool monero_tx_query::meets_criteria(monero_tx_wallet* tx) const {
|
||||
@@ -326,22 +454,57 @@ namespace monero {
|
||||
return tgt;
|
||||
};
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_amount != boost::none) monero_utils::addJsonMember("amount", m_amount.get(), allocator, root, value_num);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_address != boost::none) monero_utils::addJsonMember("address", m_address.get(), allocator, root, value_str);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
// ----------------------------- 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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_multisig_tx_hex != boost::none) monero_utils::addJsonMember("multisigTxHex", m_multisig_tx_hex.get(), allocator, root, value_str);
|
||||
if (m_unsigned_tx_hex != boost::none) monero_utils::addJsonMember("unsignedTxHex", m_unsigned_tx_hex.get(), allocator, root, value_str);
|
||||
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);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
// ---------------------------- MONERO TRANSFER -----------------------------
|
||||
@@ -355,12 +518,27 @@ namespace monero {
|
||||
return tgt;
|
||||
}
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_amount != boost::none) monero_utils::addJsonMember("amount", m_amount.get(), allocator, root, value_num);
|
||||
if (m_account_index != boost::none) monero_utils::addJsonMember("accountIndex", m_account_index.get(), allocator, root, value_num);
|
||||
if (m_num_suggested_confirmations != boost::none) monero_utils::addJsonMember("numSuggestedConfirmations", m_num_suggested_confirmations.get(), allocator, root, value_num);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_transfer::merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other) {
|
||||
@@ -394,16 +572,34 @@ namespace monero {
|
||||
}
|
||||
|
||||
shared_ptr<monero_incoming_transfer> monero_incoming_transfer::copy(const shared_ptr<monero_incoming_transfer>& src, const shared_ptr<monero_incoming_transfer>& tgt) const {
|
||||
cout << "monero_incoming_transfer::copy()" << endl;
|
||||
throw runtime_error("monero_incoming_transfer::copy(inTransfer) not implemented");
|
||||
};
|
||||
|
||||
boost::optional<bool> monero_incoming_transfer::is_incoming() const { return true; }
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
|
||||
// serialize root from superclass
|
||||
rapidjson::Value root = monero_transfer::to_json_val(allocator);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_subaddress_index != boost::none) monero_utils::addJsonMember("subaddressIndex", m_subaddress_index.get(), allocator, root, value_num);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_address != boost::none) monero_utils::addJsonMember("address", m_address.get(), allocator, root, value_str);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_incoming_transfer::merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other) {
|
||||
@@ -424,17 +620,32 @@ namespace monero {
|
||||
};
|
||||
|
||||
shared_ptr<monero_outgoing_transfer> monero_outgoing_transfer::copy(const shared_ptr<monero_outgoing_transfer>& src, const shared_ptr<monero_outgoing_transfer>& tgt) const {
|
||||
cout << "monero_outgoing_transfer::copy()" << endl;
|
||||
throw runtime_error("monero_outgoing_transfer::copy(out_transfer) not implemented");
|
||||
};
|
||||
|
||||
boost::optional<bool> monero_outgoing_transfer::is_incoming() const { return false; }
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
|
||||
// serialize root from superclass
|
||||
rapidjson::Value root = monero_transfer::to_json_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);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_outgoing_transfer::merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other) {
|
||||
@@ -480,16 +691,42 @@ 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;
|
||||
// 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;
|
||||
// }
|
||||
|
||||
rapidjson::Value monero_transfer_query::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
|
||||
|
||||
// serialize root from superclass
|
||||
rapidjson::Value root = monero_transfer::to_json_val(allocator);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_subaddress_index != boost::none) monero_utils::addJsonMember("subaddressIndex", m_subaddress_index.get(), allocator, root, value_num);
|
||||
|
||||
// set bool values
|
||||
if (m_is_incoming != boost::none) monero_utils::addJsonMember("isIncoming", m_is_incoming.get(), allocator, root);
|
||||
if (m_has_destinations != boost::none) monero_utils::addJsonMember("hasDestinations", m_has_destinations.get(), allocator, root);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
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);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
bool monero_transfer_query::meets_criteria(monero_transfer* transfer) const {
|
||||
@@ -586,13 +823,32 @@ namespace monero {
|
||||
return tgt;
|
||||
};
|
||||
|
||||
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_frozen != boost::none) node.put("isFrozen", *m_is_frozen);
|
||||
return node;
|
||||
// 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 {
|
||||
|
||||
// serialize root from superclass
|
||||
rapidjson::Value root = monero_output::to_json_val(allocator);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_account_index != boost::none) monero_utils::addJsonMember("accountIndex", m_account_index.get(), allocator, root, value_num);
|
||||
if (m_subaddress_index != boost::none) monero_utils::addJsonMember("subaddressIndex", m_subaddress_index.get(), allocator, root, value_num);
|
||||
|
||||
// set bool values
|
||||
if (m_is_spent != boost::none) monero_utils::addJsonMember("isSpent", m_is_spent.get(), allocator, root);
|
||||
if (m_is_frozen != boost::none) monero_utils::addJsonMember("isFrozen", m_is_frozen.get(), allocator, root);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
void monero_output_wallet::merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other) {
|
||||
@@ -642,10 +898,22 @@ namespace monero {
|
||||
return tgt;
|
||||
};
|
||||
|
||||
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;
|
||||
// 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;
|
||||
// }
|
||||
|
||||
rapidjson::Value monero_output_query::to_json_val(rapidjson::Document::AllocatorType& allocator) const {
|
||||
|
||||
// serialize root from superclass
|
||||
rapidjson::Value root = monero_output_wallet::to_json_val(allocator);
|
||||
|
||||
// set sub-arrays
|
||||
if (!m_subaddress_indices.empty()) root.AddMember("subaddressIndices", monero_utils::to_json_val(allocator, m_subaddress_indices), allocator);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
bool monero_output_query::meets_criteria(monero_output_wallet* output) const {
|
||||
@@ -701,105 +969,198 @@ namespace monero {
|
||||
return monero_send_request(*this);
|
||||
}
|
||||
|
||||
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_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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_priority != boost::none) monero_utils::addJsonMember("priority", m_priority.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_account_index != boost::none) monero_utils::addJsonMember("accountIndex", m_account_index.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_below_amount != boost::none) monero_utils::addJsonMember("belowAmount", m_below_amount.get(), allocator, root, value_num);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_payment_id != boost::none) monero_utils::addJsonMember("paymentId", m_payment_id.get(), allocator, root, value_str);
|
||||
if (m_note != boost::none) monero_utils::addJsonMember("note", m_note.get(), allocator, root, value_str);
|
||||
if (m_recipient_name != boost::none) monero_utils::addJsonMember("recipientName", m_recipient_name.get(), allocator, root, value_str);
|
||||
if (m_key_image != boost::none) monero_utils::addJsonMember("keyImage", m_key_image.get(), allocator, root, value_str);
|
||||
|
||||
// set bool values
|
||||
if (m_can_split != boost::none) monero_utils::addJsonMember("canSplit", m_can_split.get(), allocator, root);
|
||||
if (m_do_not_relay != boost::none) monero_utils::addJsonMember("doNotRelay", m_do_not_relay.get(), allocator, root);
|
||||
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);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
|
||||
// ---------------------- 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;
|
||||
// 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 {
|
||||
cout << "monero_integrated_address::to_json_val()" << endl;
|
||||
throw runtime_error("monero_integrated_address::to_json_val() not implemented");
|
||||
}
|
||||
|
||||
// -------------------- 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;
|
||||
// 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 {
|
||||
cout << "monero_key_image_import_result::to_json_val()" << endl;
|
||||
throw runtime_error("monero_key_image_import_result::to_json_val() not implemented");
|
||||
}
|
||||
|
||||
// ----------------------------- 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;
|
||||
// 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 {
|
||||
cout << "monero_check::to_json_val()" << endl;
|
||||
throw runtime_error("monero_check::to_json_val() not implemented");
|
||||
}
|
||||
|
||||
// --------------------------- 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;
|
||||
// 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 {
|
||||
cout << "monero_check_tx::to_json_val()" << endl;
|
||||
throw runtime_error("monero_check_tx::to_json_val() not implemented");
|
||||
}
|
||||
|
||||
// ------------------------ 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;
|
||||
// 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 {
|
||||
cout << "monero_check_reserve::to_json_val()" << endl;
|
||||
throw runtime_error("monero_check_reserve::to_json_val() not implemented");
|
||||
}
|
||||
|
||||
// --------------------------- 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;
|
||||
// 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 {
|
||||
cout << "monero_multisig_info::to_json_val()" << endl;
|
||||
throw runtime_error("monero_multisig_info::to_json_val() not implemented");
|
||||
}
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
cout << "monero_multisig_init_result::to_json_val()" << endl;
|
||||
throw runtime_error("monero_multisig_init_result::to_json_val() not implemented");
|
||||
}
|
||||
|
||||
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;
|
||||
// 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 {
|
||||
cout << "monero_multisig_sign_result::to_json_val()" << endl;
|
||||
throw runtime_error("monero_multisig_sign_result::to_json_val() not implemented");
|
||||
}
|
||||
|
||||
// -------------------------- 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;
|
||||
// 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 {
|
||||
|
||||
// create root
|
||||
rapidjson::Value root(rapidjson::kObjectType);
|
||||
|
||||
// set num values
|
||||
rapidjson::Value value_num(rapidjson::kNumberType);
|
||||
if (m_index != boost::none) monero_utils::addJsonMember("index", m_index.get(), allocator, root, value_num);
|
||||
|
||||
// set string values
|
||||
rapidjson::Value value_str(rapidjson::kStringType);
|
||||
if (m_address != boost::none) monero_utils::addJsonMember("address", m_address.get(), allocator, root, value_str);
|
||||
if (m_description != boost::none) monero_utils::addJsonMember("description", m_description.get(), allocator, root, value_str);
|
||||
if (m_payment_id != boost::none) monero_utils::addJsonMember("paymentId", m_payment_id.get(), allocator, root, value_str);
|
||||
|
||||
// return root
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,11 +65,13 @@ namespace monero {
|
||||
/**
|
||||
* Models a result of syncing a wallet.
|
||||
*/
|
||||
struct monero_sync_result {
|
||||
struct monero_sync_result : public serializable_struct {
|
||||
uint64_t m_num_blocks_fetched;
|
||||
bool m_received_money;
|
||||
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;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -85,20 +87,9 @@ namespace monero {
|
||||
boost::optional<uint64_t> m_num_unspent_outputs;
|
||||
boost::optional<bool> m_is_used;
|
||||
boost::optional<uint64_t> m_num_blocks_to_unlock;
|
||||
// BEGIN_KV_SERIALIZE_MAP()
|
||||
// KV_SERIALIZE(m_account_index)
|
||||
// KV_SERIALIZE(index)
|
||||
// KV_SERIALIZE(address)
|
||||
// KV_SERIALIZE(label)
|
||||
// KV_SERIALIZE(balance)
|
||||
// KV_SERIALIZE(m_unlocked_balance)
|
||||
// KV_SERIALIZE(m_num_unspent_outputs)
|
||||
// KV_SERIALIZE(m_is_used)
|
||||
// KV_SERIALIZE(m_num_blocks_to_unlock)
|
||||
// END_KV_SERIALIZE_MAP()
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//void merge(const shared_ptr<monero_subaddress>& self, const shared_ptr<monero_subaddress>& other);
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -111,17 +102,19 @@ namespace monero {
|
||||
boost::optional<uint64_t> m_unlocked_balance;
|
||||
boost::optional<string> m_tag;
|
||||
vector<monero_subaddress> m_subaddresses;
|
||||
// BEGIN_KV_SERIALIZE_MAP()
|
||||
// KV_SERIALIZE(index)
|
||||
// KV_SERIALIZE(m_primary_address)
|
||||
// KV_SERIALIZE(label)
|
||||
// KV_SERIALIZE(balance)
|
||||
// KV_SERIALIZE(m_unlocked_balance)
|
||||
// KV_SERIALIZE(tag)
|
||||
// KV_SERIALIZE(subaddresses)
|
||||
// END_KV_SERIALIZE_MAP()
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
|
||||
string serialize_doc() const;
|
||||
rapidjson::Document to_json_doc() const {
|
||||
rapidjson::Document doc;
|
||||
doc.SetObject();
|
||||
rapidjson::Value val = to_json_val(doc);
|
||||
val.Swap(doc);
|
||||
return doc;
|
||||
}
|
||||
rapidjson::Value to_json_val(rapidjson::Document& doc) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -134,7 +127,8 @@ namespace monero {
|
||||
monero_destination() {}
|
||||
monero_destination(const string& address, uint64_t amount) : m_address(address), m_amount(amount) {}
|
||||
shared_ptr<monero_destination> copy(const shared_ptr<monero_destination>& src, const shared_ptr<monero_destination>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
// forward declarations
|
||||
@@ -157,7 +151,8 @@ namespace monero {
|
||||
if (is_incoming() == boost::none) return boost::none;
|
||||
return !(*is_incoming());
|
||||
}
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
|
||||
};
|
||||
|
||||
@@ -171,7 +166,8 @@ namespace monero {
|
||||
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;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
|
||||
void merge(const shared_ptr<monero_incoming_transfer>& self, const shared_ptr<monero_incoming_transfer>& other);
|
||||
};
|
||||
@@ -187,7 +183,8 @@ namespace monero {
|
||||
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;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
void merge(const shared_ptr<monero_transfer>& self, const shared_ptr<monero_transfer>& other);
|
||||
void merge(const shared_ptr<monero_outgoing_transfer>& self, const shared_ptr<monero_outgoing_transfer>& other);
|
||||
};
|
||||
@@ -210,7 +207,8 @@ namespace monero {
|
||||
shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer>& src, const shared_ptr<monero_transfer>& tgt) const;
|
||||
shared_ptr<monero_transfer_query> copy(const shared_ptr<monero_transfer_query>& src, const shared_ptr<monero_transfer_query>& tgt) const;
|
||||
boost::optional<bool> is_incoming() const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
bool meets_criteria(monero_transfer* transfer) const;
|
||||
};
|
||||
|
||||
@@ -225,7 +223,8 @@ namespace monero {
|
||||
|
||||
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;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
void merge(const shared_ptr<monero_output>& self, const shared_ptr<monero_output>& other);
|
||||
void merge(const shared_ptr<monero_output_wallet>& self, const shared_ptr<monero_output_wallet>& other);
|
||||
};
|
||||
@@ -245,7 +244,8 @@ namespace monero {
|
||||
shared_ptr<monero_output_query> copy(const shared_ptr<monero_output>& src, const shared_ptr<monero_output>& tgt) const;
|
||||
shared_ptr<monero_output_query> copy(const shared_ptr<monero_output_wallet>& src, const shared_ptr<monero_output_wallet>& tgt) const;
|
||||
shared_ptr<monero_output_query> copy(const shared_ptr<monero_output_query>& src, const shared_ptr<monero_output_query>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
bool meets_criteria(monero_output_wallet* output) const;
|
||||
|
||||
private:
|
||||
@@ -272,7 +272,8 @@ namespace monero {
|
||||
|
||||
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;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
void merge(const shared_ptr<monero_tx>& self, const shared_ptr<monero_tx>& other);
|
||||
void merge(const shared_ptr<monero_tx_wallet>& self, const shared_ptr<monero_tx_wallet>& other);
|
||||
};
|
||||
@@ -299,7 +300,8 @@ namespace monero {
|
||||
shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx>& src, const shared_ptr<monero_tx>& tgt) const;
|
||||
shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx_wallet>& src, const shared_ptr<monero_tx_wallet>& tgt) const;
|
||||
shared_ptr<monero_tx_query> copy(const shared_ptr<monero_tx_query>& src, const shared_ptr<monero_tx_query>& tgt) const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
bool meets_criteria(monero_tx_wallet* tx) const;
|
||||
};
|
||||
|
||||
@@ -311,13 +313,14 @@ namespace monero {
|
||||
* hex string which is needed in order to sign and submit the multisig
|
||||
* transactions.
|
||||
*/
|
||||
struct monero_tx_set : serializable_struct {
|
||||
struct monero_tx_set : public serializable_struct {
|
||||
vector<shared_ptr<monero_tx_wallet>> m_txs;
|
||||
boost::optional<string> m_signed_tx_hex;
|
||||
boost::optional<string> m_unsigned_tx_hex;
|
||||
boost::optional<string> m_multisig_tx_hex;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -328,7 +331,8 @@ namespace monero {
|
||||
string m_payment_id;
|
||||
string m_integrated_address;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -364,7 +368,8 @@ namespace monero {
|
||||
monero_send_request() {}
|
||||
monero_send_request(const monero_send_request& request);
|
||||
monero_send_request copy() const;
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -375,7 +380,8 @@ namespace monero {
|
||||
boost::optional<uint64_t> m_spent_amount;
|
||||
boost::optional<uint64_t> m_unspent_amount;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -384,7 +390,8 @@ namespace monero {
|
||||
struct monero_check : public serializable_struct {
|
||||
bool m_is_good;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -395,7 +402,8 @@ namespace monero {
|
||||
boost::optional<uint64_t> m_num_confirmations;
|
||||
boost::optional<uint64_t> m_received_amount;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -405,7 +413,8 @@ 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;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -417,7 +426,8 @@ namespace monero {
|
||||
uint32_t m_threshold;
|
||||
uint32_t m_num_participants;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -429,7 +439,8 @@ namespace monero {
|
||||
boost::optional<string> m_address;
|
||||
boost::optional<string> m_multisig_hex;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -439,7 +450,8 @@ namespace monero {
|
||||
boost::optional<string> m_signed_multisig_tx_hex;
|
||||
vector<string> m_tx_ids;
|
||||
|
||||
boost::property_tree::ptree to_property_tree() const;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -453,6 +465,7 @@ 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;
|
||||
//boost::property_tree::ptree to_property_tree() const;
|
||||
rapidjson::Value to_json_val(rapidjson::Document::AllocatorType& allocator) const;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user