From f48597fe7481caa871bcf96e646b36d6e6e21ac0 Mon Sep 17 00:00:00 2001 From: Eirik Rye Date: Thu, 10 May 2018 20:47:41 +0200 Subject: [PATCH] Fix stateblock receive account field to be consistent with legacy blocks (#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 --- rai/node/rpc.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index 76ab4e4e..ef092567 100644 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -1800,7 +1800,7 @@ public: { 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 ()); } } @@ -1815,6 +1815,7 @@ public: void rai::rpc_handler::account_history () { + std::string account_text; std::string count_text (request.get ("count")); bool output_raw (request.get_optional ("raw") == true); auto error (false); @@ -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 ("account")); + account_text = request.get ("account"); rai::uint256_union account; error = account.decode_account (account_text); if (!error) @@ -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) {