From 6c28c92ee507e79fd0f34974314375cc7ccb03fb Mon Sep 17 00:00:00 2001 From: Eirik Rye Date: Sat, 21 Apr 2018 05:43:41 +0200 Subject: [PATCH 1/3] Fix stateblock receive account field to be consistent with legacy blocks --- rai/node/rpc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index 4961777cf9..557682ced9 100644 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -1753,7 +1753,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 ()); } } From 528a46dce57889bcb93159e51e1ef81771cbc443 Mon Sep 17 00:00:00 2001 From: Eirik Rye Date: Thu, 26 Apr 2018 17:39:27 +0200 Subject: [PATCH 2/3] Add account field to output of account_history RPC call --- rai/node/rpc.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index 557682ced9..f40343e39b 100644 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -1809,6 +1809,8 @@ void rai::rpc_handler::account_history () boost::property_tree::ptree history; if (!error) { + auto account (node.ledger.account (transaction, hash)); + response_l.put ("account", account.to_account ()); auto block (node.store.block_get (transaction, hash)); while (block != nullptr && count > 0) { From b80aab92cd4c3bdbf95fe83011237089e393dd95 Mon Sep 17 00:00:00 2001 From: Eirik Rye Date: Thu, 26 Apr 2018 19:18:22 +0200 Subject: [PATCH 3/3] Only look up account if it is not provided in account_history RPC call --- rai/node/rpc.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rai/node/rpc.cpp b/rai/node/rpc.cpp index f40343e39b..a2bf556ec9 100644 --- a/rai/node/rpc.cpp +++ b/rai/node/rpc.cpp @@ -1768,6 +1768,7 @@ class history_visitor : public rai::block_visitor 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); @@ -1777,14 +1778,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) @@ -1809,8 +1814,7 @@ void rai::rpc_handler::account_history () boost::property_tree::ptree history; if (!error) { - auto account (node.ledger.account (transaction, hash)); - response_l.put ("account", account.to_account ()); + response_l.put ("account", account_text); auto block (node.store.block_get (transaction, hash)); while (block != nullptr && count > 0) {