From 15d40cd97ba1dd77a5c86faf9c823fc82f3b2872 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Fri, 28 Aug 2026 15:21:39 +0200 Subject: [PATCH] data model: implement deserialize method * Implement template gen_utils::deserialize * Normalize monero_rpc_connection::from_property_tree * Implement deserialize methods for all public data structures * breaking change: now monero_tx_set::deseriliaze returns a std::shared_ptr --- src/common/monero_rpc_connection.cpp | 9 +- src/common/monero_rpc_connection.h | 3 +- src/daemon/monero_daemon_model.cpp | 132 ++++++++++++++++++++++ src/daemon/monero_daemon_model.h | 33 ++++++ src/utils/gen_utils.h | 9 ++ src/wallet/monero_wallet_model.cpp | 158 +++++++++++++++++---------- src/wallet/monero_wallet_model.h | 25 ++++- 7 files changed, 307 insertions(+), 62 deletions(-) diff --git a/src/common/monero_rpc_connection.cpp b/src/common/monero_rpc_connection.cpp index 37c953ca..0b3c32e9 100644 --- a/src/common/monero_rpc_connection.cpp +++ b/src/common/monero_rpc_connection.cpp @@ -424,8 +424,7 @@ namespace monero { else deserialize_rpc_response(result, response, uri, request.m_method.get()); } - std::shared_ptr monero_rpc_connection::from_property_tree(const boost::property_tree::ptree& node) { - std::shared_ptr connection = std::make_shared(); + void monero_rpc_connection::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& connection) { for (boost::property_tree::ptree::const_iterator it = node.begin(); it != node.end(); ++it) { std::string key = it->first; if (key == std::string("uri")) connection->m_uri = it->second.data(); @@ -436,6 +435,10 @@ namespace monero { else if (key == std::string("priority")) connection->m_priority = it->second.get_value(); else if (key == std::string("timeoutMs")) connection->m_timeout_ms = it->second.get_value(); } - return connection; } + + std::shared_ptr monero_rpc_connection::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + } diff --git a/src/common/monero_rpc_connection.h b/src/common/monero_rpc_connection.h index 94e8d8c2..c6b48e19 100644 --- a/src/common/monero_rpc_connection.h +++ b/src/common/monero_rpc_connection.h @@ -118,7 +118,8 @@ namespace monero { boost::optional m_response_time; // automatically set by calling check_connection() int m_priority; // priority relative to other connections where 1 is highest, then 2, etc, and 0 is lowest (default) - static std::shared_ptr from_property_tree(const boost::property_tree::ptree& node); + static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& connection); + static std::shared_ptr deserialize(const std::string& json); /** * Checks RPC connection priority order. diff --git a/src/daemon/monero_daemon_model.cpp b/src/daemon/monero_daemon_model.cpp index 74b97c3d..698553a4 100644 --- a/src/daemon/monero_daemon_model.cpp +++ b/src/daemon/monero_daemon_model.cpp @@ -117,6 +117,10 @@ namespace monero { } } + std::shared_ptr monero_version::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + // --------------------------- SSL OPTIONS --------------------------- rapidjson::Value ssl_options::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { @@ -149,6 +153,10 @@ namespace monero { } } + std::shared_ptr ssl_options::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + // ------------------------- MONERO BLOCK HEADER ---------------------------- rapidjson::Value monero_block_header::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { @@ -214,6 +222,10 @@ namespace monero { } } + std::shared_ptr monero_block_header::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_block_header::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { if (this != src.get()) throw std::runtime_error("this block header != src"); tgt->m_hash = src->m_hash; @@ -314,6 +326,10 @@ namespace monero { } } + std::shared_ptr monero_block::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_block::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { if (this != src.get()) throw std::runtime_error("this block != src"); monero_block_header::copy(std::static_pointer_cast(src), std::static_pointer_cast(tgt)); @@ -501,6 +517,10 @@ namespace monero { } } + std::shared_ptr monero_tx::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_tx::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { MTRACE("monero_tx::copy(const std::shared_ptr& src, const std::shared_ptr& tgt)"); tgt->m_hash = src->m_hash; @@ -690,6 +710,10 @@ namespace monero { } } + std::shared_ptr monero_key_image::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::vector> monero_key_image::deserialize_key_images(const std::string& key_images_json) { // deserialize json to property node @@ -776,6 +800,10 @@ namespace monero { } } + std::shared_ptr monero_output::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_output::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { if (this != src.get()) throw std::runtime_error("this != src"); tgt->m_tx = src->m_tx; // reference same parent tx by default @@ -818,6 +846,10 @@ namespace monero { } } + std::shared_ptr monero_rpc_payment_info::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_rpc_payment_info::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -850,6 +882,10 @@ namespace monero { } } + std::shared_ptr monero_alt_chain::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_alt_chain::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -884,6 +920,10 @@ namespace monero { } } + std::shared_ptr monero_ban::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_ban::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -914,6 +954,10 @@ namespace monero { } } + std::shared_ptr monero_prune_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_prune_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -947,6 +991,10 @@ namespace monero { } } + std::shared_ptr monero_mining_status::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_mining_status::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -980,6 +1028,10 @@ namespace monero { } } + std::shared_ptr monero_miner_tx_sum::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_miner_tx_sum::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1014,6 +1066,10 @@ namespace monero { } } + std::shared_ptr monero_block_template::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_block_template::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1063,6 +1119,10 @@ namespace monero { } } + std::shared_ptr monero_miner_data::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_miner_data::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root = monero_rpc_payment_info::to_rapidjson_val(allocator); @@ -1097,6 +1157,10 @@ namespace monero { } } + std::shared_ptr monero_auxiliary_pow::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_auxiliary_pow::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1131,6 +1195,10 @@ namespace monero { } } + std::shared_ptr monero_add_auxiliary_pow_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_add_auxiliary_pow_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root = monero_rpc_payment_info::to_rapidjson_val(allocator); @@ -1167,6 +1235,10 @@ namespace monero { } } + std::shared_ptr monero_connection_span::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_connection_span::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1232,6 +1304,10 @@ namespace monero { } } + std::shared_ptr monero_peer::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_peer::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1298,6 +1374,10 @@ namespace monero { } } + std::shared_ptr monero_submit_tx_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_submit_tx_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root = monero_rpc_payment_info::to_rapidjson_val(allocator); @@ -1341,6 +1421,10 @@ namespace monero { } } + std::shared_ptr monero_output_distribution_entry::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_output_distribution_entry::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1370,6 +1454,10 @@ namespace monero { } } + std::shared_ptr monero_output_histogram_entry::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_output_histogram_entry::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1410,6 +1498,10 @@ namespace monero { } } + std::shared_ptr monero_tx_pool_stats::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_tx_pool_stats::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1455,6 +1547,10 @@ namespace monero { } } + std::shared_ptr monero_daemon_update_check_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_daemon_update_check_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1484,6 +1580,10 @@ namespace monero { } } + std::shared_ptr monero_daemon_update_download_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_daemon_update_download_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root = monero_daemon_update_check_result::to_rapidjson_val(allocator); @@ -1513,6 +1613,10 @@ namespace monero { } } + std::shared_ptr monero_fee_estimate::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_fee_estimate::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1579,6 +1683,10 @@ namespace monero { } } + std::shared_ptr monero_daemon_info::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_daemon_info::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root = monero_rpc_payment_info::to_rapidjson_val(allocator); @@ -1657,6 +1765,10 @@ namespace monero { } } + std::shared_ptr monero_daemon_sync_info::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_daemon_sync_info::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root = monero_rpc_payment_info::to_rapidjson_val(allocator); @@ -1694,6 +1806,10 @@ namespace monero { } } + std::shared_ptr monero_daemon_network_stats::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_daemon_network_stats::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root = monero_rpc_payment_info::to_rapidjson_val(allocator); @@ -1728,6 +1844,10 @@ namespace monero { } } + std::shared_ptr monero_hard_fork_info::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_hard_fork_info::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root = monero_rpc_payment_info::to_rapidjson_val(allocator); @@ -1761,6 +1881,10 @@ namespace monero { } } + std::shared_ptr monero_generate_blocks_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_generate_blocks_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1786,6 +1910,10 @@ namespace monero { } } + std::shared_ptr monero_get_blocks_by_hash_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_get_blocks_by_hash_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1814,6 +1942,10 @@ namespace monero { } } + std::shared_ptr monero_get_block_hashes_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_get_block_hashes_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); diff --git a/src/daemon/monero_daemon_model.h b/src/daemon/monero_daemon_model.h index 914089b0..97d33cb0 100644 --- a/src/daemon/monero_daemon_model.h +++ b/src/daemon/monero_daemon_model.h @@ -99,6 +99,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& options); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -144,6 +145,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& version); + static std::shared_ptr deserialize(const std::string& json); }; // forward declarations @@ -179,6 +181,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& header); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; virtual void merge(const std::shared_ptr& self, const std::shared_ptr& other); }; @@ -194,6 +197,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& block); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; void merge(const std::shared_ptr& self, const std::shared_ptr& other); void merge(const std::shared_ptr& self, const std::shared_ptr& other); @@ -248,6 +252,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, std::shared_ptr tx); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; virtual void merge(const std::shared_ptr& self, const std::shared_ptr& other); boost::optional get_height() const; @@ -262,6 +267,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& key_image); + static std::shared_ptr deserialize(const std::string& json); static std::vector> deserialize_key_images(const std::string& key_images_json); // TODO: remove this specialty util used once std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; void merge(const std::shared_ptr& self, const std::shared_ptr& other); @@ -281,6 +287,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& output); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; virtual void merge(const std::shared_ptr& self, const std::shared_ptr& other); }; @@ -303,6 +310,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& rpc_payment_info); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -318,6 +326,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& alt_chain); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -331,6 +340,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& ban); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -341,6 +351,7 @@ namespace monero { boost::optional m_pruning_seed; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& result); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -355,6 +366,7 @@ namespace monero { boost::optional m_num_threads; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& status); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -368,6 +380,7 @@ namespace monero { boost::optional m_fee_sum_high; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& sum); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -388,6 +401,7 @@ namespace monero { boost::optional m_seed_height; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& tmplt); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -406,6 +420,7 @@ namespace monero { std::vector> m_tx_pool_backlog; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& data); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -420,6 +435,7 @@ namespace monero { monero_auxiliary_pow(const std::string& id, const std::string& hash): m_id(id), m_hash(hash) { } static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& aux_pow); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -434,6 +450,7 @@ namespace monero { std::vector> m_aux_pow; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& result); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -450,6 +467,7 @@ namespace monero { boost::optional m_start_height; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& span); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -485,6 +503,7 @@ namespace monero { boost::optional m_connection_type; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& peer); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -508,6 +527,7 @@ namespace monero { boost::optional m_reason; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& result); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -528,6 +548,7 @@ namespace monero { boost::optional m_start_height; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& entry); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -541,6 +562,7 @@ namespace monero { boost::optional m_recent_instances; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& entry); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -564,6 +586,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& stats); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -577,6 +600,7 @@ namespace monero { boost::optional m_user_uri; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& check); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -587,6 +611,7 @@ namespace monero { boost::optional m_download_path; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& check); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -599,6 +624,7 @@ namespace monero { std::vector m_fees; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& estimate); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -642,6 +668,7 @@ namespace monero { boost::optional m_is_regtest; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& info); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -657,6 +684,7 @@ namespace monero { std::vector> m_spans; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& info); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -671,6 +699,7 @@ namespace monero { boost::optional m_total_bytes_out; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& stats); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -688,6 +717,7 @@ namespace monero { boost::optional m_voting; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& info); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -699,6 +729,7 @@ namespace monero { boost::optional m_height; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& result); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -710,6 +741,7 @@ namespace monero { boost::optional m_current_height; // the daemon's chain height at request time static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& result); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; @@ -722,6 +754,7 @@ namespace monero { boost::optional m_current_height; // the daemon's chain height at request time static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& result); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; }; diff --git a/src/utils/gen_utils.h b/src/utils/gen_utils.h index c749407d..5062e503 100644 --- a/src/utils/gen_utils.h +++ b/src/utils/gen_utils.h @@ -108,6 +108,15 @@ namespace gen_utils std::string serialize(const boost::property_tree::ptree& node); void deserialize(const std::string& json, boost::property_tree::ptree& root); + template + std::shared_ptr deserialize(const std::string& json) { + boost::property_tree::ptree root; + gen_utils::deserialize(json, root); + std::shared_ptr obj = std::make_shared(); + T::from_property_tree(root, obj); + return obj; + } + // ------------------------- VALUE RECONCILATION ---------------------------- // TODO: refactor common template code diff --git a/src/wallet/monero_wallet_model.cpp b/src/wallet/monero_wallet_model.cpp index ad1c7961..b225ac2c 100644 --- a/src/wallet/monero_wallet_model.cpp +++ b/src/wallet/monero_wallet_model.cpp @@ -169,7 +169,10 @@ namespace monero { else if (network_type_num == 2) config->m_network_type = monero_network_type::STAGENET; else throw std::runtime_error("Invalid network type, expected 0-2: " + std::to_string(network_type_num)); } - else if (key == std::string("server")) config->m_server = monero_rpc_connection::from_property_tree(it->second); + else if (key == std::string("server")) { + config->m_server = std::make_shared(); + monero_rpc_connection::from_property_tree(it->second, config->m_server); + } else if (key == std::string("isTrustedDaemon")) config->m_is_trusted_daemon = it->second.get_value(); else if (key == std::string("seed")) config->m_seed = it->second.data(); else if (key == std::string("seedOffset")) config->m_seed_offset = it->second.data(); @@ -187,16 +190,7 @@ namespace monero { } std::shared_ptr monero_wallet_config::deserialize(const std::string& config_json) { - - // deserialize config json to property node - std::istringstream iss = config_json.empty() ? std::istringstream() : std::istringstream(config_json); - boost::property_tree::ptree node; - boost::property_tree::read_json(iss, node); - - // convert config property tree to monero_wallet_config - std::shared_ptr config = std::make_shared(); - from_property_tree(node, config); - return config; + return gen_utils::deserialize(config_json); } // -------------------------- MONERO SYNC RESULT ---------------------------- @@ -225,6 +219,10 @@ namespace monero { } } + std::shared_ptr monero_sync_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + // -------------------------- MONERO ACCOUNT ----------------------------- void monero_account::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& account) { @@ -245,6 +243,10 @@ namespace monero { } } + std::shared_ptr monero_account::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_account::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root @@ -285,6 +287,10 @@ namespace monero { } } + std::shared_ptr monero_subaddress::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_subaddress::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root @@ -384,6 +390,10 @@ namespace monero { } } + std::shared_ptr monero_tx_wallet::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_tx_wallet::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { return monero_tx_wallet::copy(std::static_pointer_cast(src), std::static_pointer_cast(tgt)); }; @@ -638,6 +648,10 @@ namespace monero { } } + std::shared_ptr monero_tx_query::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_tx_query::deserialize_from_block(const std::string& tx_query_json) { // deserialize tx query std::string to property rooted at block @@ -813,6 +827,10 @@ namespace monero { } } + std::shared_ptr monero_destination::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_destination::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { if (this != src.get()) throw std::runtime_error("this destination!= src"); tgt->m_address = src->m_address; @@ -840,32 +858,8 @@ namespace monero { return root; } - monero_tx_set monero_tx_set::deserialize(const std::string& tx_set_json) { - - // deserialize tx set to property - std::istringstream iss = tx_set_json.empty() ? std::istringstream() : std::istringstream(tx_set_json); - boost::property_tree::ptree tx_set_node; - boost::property_tree::read_json(iss, tx_set_node); - - // initialize tx_set from property node - monero_tx_set tx_set; - for (boost::property_tree::ptree::const_iterator it = tx_set_node.begin(); it != tx_set_node.end(); ++it) { - std::string key = it->first; - if (key == std::string("unsignedTxHex")) tx_set.m_unsigned_tx_hex = it->second.data(); - else if (key == std::string("multisigTxHex")) tx_set.m_multisig_tx_hex = it->second.data(); - else if (key == std::string("signedTxHex")) tx_set.m_signed_tx_hex = it->second.data(); - else if (key == std::string("txs")) { - boost::property_tree::ptree txs_node = it->second; - for (boost::property_tree::ptree::const_iterator it2 = txs_node.begin(); it2 != txs_node.end(); ++it2) { - std::shared_ptr tx_wallet = std::make_shared(); - monero_tx_wallet::from_property_tree(it2->second, tx_wallet); - tx_set.m_txs.push_back(tx_wallet); - } - } - else throw std::runtime_error("monero_utils::deserialize_tx_set() field '" + key + "' not supported"); - } - - return tx_set; + std::shared_ptr monero_tx_set::deserialize(const std::string& tx_set_json) { + return gen_utils::deserialize(tx_set_json); } void monero_tx_set::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& set) { @@ -971,6 +965,10 @@ namespace monero { } } + std::shared_ptr monero_incoming_transfer::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_incoming_transfer::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { return copy(std::static_pointer_cast(src), std::static_pointer_cast(tgt)); } @@ -1035,6 +1033,10 @@ namespace monero { } } + std::shared_ptr monero_outgoing_transfer::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_outgoing_transfer::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { return copy(std::static_pointer_cast(src), std::static_pointer_cast(tgt)); }; @@ -1128,6 +1130,10 @@ namespace monero { } } + std::shared_ptr monero_transfer_query::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_transfer_query::deserialize_from_block(const std::string& transfer_query_json) { // deserialize transfer query std::string to property rooted at block @@ -1294,6 +1300,10 @@ namespace monero { } } + std::shared_ptr monero_output_wallet::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_output_wallet::copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const { MTRACE("monero_output_wallet::copy(output)"); return monero_output_wallet::copy(std::static_pointer_cast(src), std::static_pointer_cast(tgt)); @@ -1365,6 +1375,10 @@ namespace monero { } } + std::shared_ptr monero_output_query::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + std::shared_ptr monero_output_query::deserialize_from_block(const std::string& output_query_json) { // deserialize output query string to property rooted at block @@ -1552,16 +1566,7 @@ namespace monero { } std::shared_ptr monero_tx_config::deserialize(const std::string& config_json) { - - // deserialize config json to property node - std::istringstream iss = config_json.empty() ? std::istringstream() : std::istringstream(config_json); - boost::property_tree::ptree node; - boost::property_tree::read_json(iss, node); - - // convert config property tree to monero_tx_config - std::shared_ptr config = std::make_shared(); - from_property_tree(node, config); - return config; + return gen_utils::deserialize(config_json); } std::vector> monero_tx_config::get_normalized_destinations() const { @@ -1604,6 +1609,10 @@ namespace monero { } } + std::shared_ptr monero_integrated_address::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + // -------------------- MONERO KEY IMAGE EXPORT RESULT ---------------------- rapidjson::Value monero_key_image_export_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { @@ -1637,16 +1646,7 @@ namespace monero { } std::shared_ptr monero_key_image_export_result::deserialize(const std::string& result_json) { - - // deserialize json to property node - std::istringstream iss = result_json.empty() ? std::istringstream() : std::istringstream(result_json); - boost::property_tree::ptree node; - boost::property_tree::read_json(iss, node); - - // convert property tree to export result - std::shared_ptr result = std::make_shared(); - from_property_tree(node, result); - return result; + return gen_utils::deserialize(result_json); } // -------------------- MONERO KEY IMAGE IMPORT RESULT ---------------------- @@ -1660,6 +1660,10 @@ namespace monero { } } + std::shared_ptr monero_key_image_import_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_key_image_import_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root @@ -1692,6 +1696,10 @@ namespace monero { } } + std::shared_ptr monero_message_signature_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_message_signature_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root @@ -1734,6 +1742,10 @@ namespace monero { } } + std::shared_ptr monero_check::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + // --------------------------- MONERO CHECK TX ------------------------------ void monero_check_tx::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& check) { @@ -1746,6 +1758,10 @@ namespace monero { } } + std::shared_ptr monero_check_tx::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_check_tx::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // serialize root from superclass @@ -1788,6 +1804,10 @@ namespace monero { } } + std::shared_ptr monero_check_reserve::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + // --------------------------- MONERO MULTISIG ------------------------------ void monero_multisig_info::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& info) { @@ -1800,6 +1820,10 @@ namespace monero { } } + std::shared_ptr monero_multisig_info::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_multisig_info::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root @@ -1826,6 +1850,10 @@ namespace monero { } } + std::shared_ptr monero_multisig_init_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_multisig_init_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root @@ -1852,6 +1880,10 @@ namespace monero { } } + std::shared_ptr monero_multisig_sign_result::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_multisig_sign_result::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); @@ -1899,6 +1931,10 @@ namespace monero { } } + std::shared_ptr monero_address_book_entry::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + // -------------------------- MONERO COMPARATORS --------------------------- bool monero_tx_height_comparator::operator()(const std::shared_ptr& tx1, const std::shared_ptr& tx2) const { @@ -2012,6 +2048,10 @@ namespace monero { } } + std::shared_ptr monero_decoded_address::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + // --------------------------- MONERO ACCOUNT TAG --------------------------- void monero_account_tag::from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& account_tag) { @@ -2027,6 +2067,10 @@ namespace monero { } } + std::shared_ptr monero_account_tag::deserialize(const std::string& json) { + return gen_utils::deserialize(json); + } + rapidjson::Value monero_account_tag::to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const { // create root rapidjson::Value root(rapidjson::kObjectType); diff --git a/src/wallet/monero_wallet_model.h b/src/wallet/monero_wallet_model.h index 5d95f21a..f1ee3c0e 100644 --- a/src/wallet/monero_wallet_model.h +++ b/src/wallet/monero_wallet_model.h @@ -103,6 +103,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& result); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -121,6 +122,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& subaddress); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -136,6 +138,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& account); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -148,6 +151,7 @@ namespace monero { monero_destination(boost::optional address = boost::none, boost::optional amount = boost::none) : m_address(address), m_amount(amount) {} rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& destination); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; }; @@ -188,6 +192,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& transfer); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; boost::optional is_incoming() const; @@ -205,6 +210,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& transfer); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; boost::optional is_incoming() const; @@ -229,6 +235,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& transfer_query); + static std::shared_ptr deserialize(const std::string& json); static std::shared_ptr deserialize_from_block(const std::string& transfer_query_json); static bool is_contextual(const monero_transfer_query& query); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; @@ -248,6 +255,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& output_wallet); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; void merge(const std::shared_ptr& self, const std::shared_ptr& other); @@ -269,6 +277,7 @@ namespace monero { //boost::property_tree::ptree to_property_tree() const; rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& output_query); + static std::shared_ptr deserialize(const std::string& json); static std::shared_ptr deserialize_from_block(const std::string& output_query_json); static bool is_contextual(const monero_output_query& query); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; @@ -296,6 +305,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& tx_wallet); + static std::shared_ptr deserialize(const std::string& json); std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; std::shared_ptr copy(const std::shared_ptr& src, const std::shared_ptr& tgt) const; void merge(const std::shared_ptr& self, const std::shared_ptr& other); @@ -332,6 +342,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& tx_query); + static std::shared_ptr deserialize(const std::string& json); static std::shared_ptr deserialize_from_block(const std::string& tx_query_json); /** @@ -366,7 +377,7 @@ namespace monero { static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& set); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; - static monero_tx_set deserialize(const std::string& tx_set_json); + static std::shared_ptr deserialize(const std::string& tx_set_json); }; /** @@ -379,6 +390,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& subaddress); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -444,6 +456,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& result); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -465,6 +478,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr result); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -475,6 +489,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& check); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -487,6 +502,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& check); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -498,6 +514,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& check); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -511,6 +528,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& info); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -524,6 +542,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& res); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -535,6 +554,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& res); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -551,6 +571,7 @@ namespace monero { monero_address_book_entry(uint64_t index, const std::string& address, const std::string& description, const std::string& payment_id) : m_index(index), m_address(address), m_description(description), m_payment_id(payment_id) {} static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& entry); + static std::shared_ptr deserialize(const std::string& json); rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const; }; @@ -598,6 +619,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& address); + static std::shared_ptr deserialize(const std::string& json); }; /** @@ -615,6 +637,7 @@ namespace monero { rapidjson::Value to_rapidjson_val(rapidjson::Document::AllocatorType& allocator) const override; static void from_property_tree(const boost::property_tree::ptree& node, const std::shared_ptr& account_tag); + static std::shared_ptr deserialize(const std::string& json); }; }