Skip to content

Commit

Permalink
Fix stateblock receive account field to be consistent with legacy blo…
Browse files Browse the repository at this point in the history
…cks (nanocurrency#820)

* Fix stateblock receive account field to be consistent with legacy blocks

* Add account field to output of account_history RPC call

* Only look up account if it is not provided in account_history RPC call
  • Loading branch information
eirikrye authored and PlasmaPower committed May 10, 2018
1 parent fbaac75 commit f48597f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rai/node/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,7 @@ class history_visitor : public rai::block_visitor
{
tree.put ("type", "receive");
}
tree.put ("account", block_a.hashables.account.to_account ());
tree.put ("account", handler.node.ledger.account (transaction, block_a.hashables.link).to_account ());
tree.put ("amount", (balance - previous_balance).convert_to<std::string> ());
}
}
Expand All @@ -1815,6 +1815,7 @@ class history_visitor : public rai::block_visitor

void rai::rpc_handler::account_history ()
{
std::string account_text;
std::string count_text (request.get<std::string> ("count"));
bool output_raw (request.get_optional<bool> ("raw") == true);
auto error (false);
Expand All @@ -1824,14 +1825,18 @@ void rai::rpc_handler::account_history ()
if (head_str)
{
error = hash.decode_hex (*head_str);
if (error)
if (!error)
{
account_text = node.ledger.account (transaction, hash).to_account ();
}
else
{
error_response (response, "Invalid block hash");
}
}
else
{
std::string account_text (request.get<std::string> ("account"));
account_text = request.get<std::string> ("account");
rai::uint256_union account;
error = account.decode_account (account_text);
if (!error)
Expand All @@ -1856,6 +1861,7 @@ void rai::rpc_handler::account_history ()
boost::property_tree::ptree history;
if (!error)
{
response_l.put ("account", account_text);
auto block (node.store.block_get (transaction, hash));
while (block != nullptr && count > 0)
{
Expand Down

0 comments on commit f48597f

Please sign in to comment.