From 598e8a3145597ae2e30d3276f9dbf7884fe75d47 Mon Sep 17 00:00:00 2001 From: Sergey Kroshnin Date: Mon, 28 Jan 2019 20:28:04 +0300 Subject: [PATCH] Improve wallet_history consistency with other RPC (#1654) wallet_account --> block_account And prevent history for change blocks --- nano/core_test/rpc.cpp | 2 +- nano/node/rpc.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/nano/core_test/rpc.cpp b/nano/core_test/rpc.cpp index 2e896c0e..caed4360 100644 --- a/nano/core_test/rpc.cpp +++ b/nano/core_test/rpc.cpp @@ -4221,7 +4221,7 @@ TEST (rpc, wallet_history) auto & history_node (response.json.get_child ("history")); for (auto i (history_node.begin ()), n (history_node.end ()); i != n; ++i) { - history_l.push_back (std::make_tuple (i->second.get ("type"), i->second.get ("account"), i->second.get ("amount"), i->second.get ("hash"), i->second.get ("wallet_account"), i->second.get ("local_timestamp"))); + history_l.push_back (std::make_tuple (i->second.get ("type"), i->second.get ("account"), i->second.get ("amount"), i->second.get ("hash"), i->second.get ("block_account"), i->second.get ("local_timestamp"))); } ASSERT_EQ (4, history_l.size ()); ASSERT_EQ ("send", std::get<0> (history_l[0])); diff --git a/nano/node/rpc.cpp b/nano/node/rpc.cpp index 543ddd83..1f26f297 100644 --- a/nano/node/rpc.cpp +++ b/nano/node/rpc.cpp @@ -3519,12 +3519,15 @@ void nano::rpc_handler::wallet_history () if (block != nullptr && timestamp >= modified_since && timestamp != std::numeric_limits::max ()) { boost::property_tree::ptree entry; - entry.put ("wallet_account", account.to_account ()); - entry.put ("hash", hash.to_string ()); history_visitor visitor (*this, false, block_transaction, entry, hash); block->visit (visitor); - entry.put ("local_timestamp", std::to_string (timestamp)); - entries.insert (std::make_pair (timestamp, entry)); + if (!entry.empty ()) + { + entry.put ("block_account", account.to_account ()); + entry.put ("hash", hash.to_string ()); + entry.put ("local_timestamp", std::to_string (timestamp)); + entries.insert (std::make_pair (timestamp, entry)); + } hash = block->previous (); } else