Improve wallet_history consistency with other RPC (#1654)
wallet_account --> block_account And prevent history for change blocks
This commit is contained in:
parent
6f6506c259
commit
598e8a3145
2 changed files with 8 additions and 5 deletions
|
@ -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<std::string> ("type"), i->second.get<std::string> ("account"), i->second.get<std::string> ("amount"), i->second.get<std::string> ("hash"), i->second.get<std::string> ("wallet_account"), i->second.get<std::string> ("local_timestamp")));
|
||||
history_l.push_back (std::make_tuple (i->second.get<std::string> ("type"), i->second.get<std::string> ("account"), i->second.get<std::string> ("amount"), i->second.get<std::string> ("hash"), i->second.get<std::string> ("block_account"), i->second.get<std::string> ("local_timestamp")));
|
||||
}
|
||||
ASSERT_EQ (4, history_l.size ());
|
||||
ASSERT_EQ ("send", std::get<0> (history_l[0]));
|
||||
|
|
|
@ -3519,12 +3519,15 @@ void nano::rpc_handler::wallet_history ()
|
|||
if (block != nullptr && timestamp >= modified_since && timestamp != std::numeric_limits<uint64_t>::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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue