diff --git a/nano/node/json_handler.cpp b/nano/node/json_handler.cpp index ca5815993..710311341 100644 --- a/nano/node/json_handler.cpp +++ b/nano/node/json_handler.cpp @@ -2134,7 +2134,8 @@ public: } else { - if (should_ignore_account (block_a.hashables.link)) + auto account (handler.node.ledger.account (transaction, block_a.hashables.link)); + if (should_ignore_account (account)) { tree.clear (); return; @@ -2147,7 +2148,7 @@ public: { tree.put ("type", "receive"); } - tree.put ("account", handler.node.ledger.account (transaction, block_a.hashables.link).to_account ()); + tree.put ("account", account.to_account ()); tree.put ("amount", (balance - previous_balance).convert_to ()); } } diff --git a/nano/rpc_test/rpc.cpp b/nano/rpc_test/rpc.cpp index 17b7b1e14..8115b8ffc 100644 --- a/nano/rpc_test/rpc.cpp +++ b/nano/rpc_test/rpc.cpp @@ -1558,6 +1558,7 @@ TEST (rpc, account_history) ASSERT_NE (nullptr, send2); auto receive2 (system.wallet (0)->receive_action (*send2, account2, system.nodes[0]->config.receive_minimum.number ())); scoped_thread_name_io.renew (); + // Test filter for send blocks ASSERT_NE (nullptr, receive2); { boost::property_tree::ptree request; @@ -1577,6 +1578,26 @@ TEST (rpc, account_history) auto history_node (response.json.get_child ("history")); ASSERT_EQ (history_node.size (), 1); } + // Test filter for receive blocks + ASSERT_NE (nullptr, receive2); + { + boost::property_tree::ptree request; + request.put ("action", "account_history"); + request.put ("account", account2.to_account ()); + boost::property_tree::ptree other_account; + other_account.put ("", nano::test_genesis_key.pub.to_account ()); + boost::property_tree::ptree filtered_accounts; + filtered_accounts.push_back (std::make_pair ("", other_account)); + request.add_child ("account_filter", filtered_accounts); + request.put ("count", 100); + test_response response (request, rpc.config.port, system.io_ctx); + while (response.status == 0) + { + ASSERT_NO_ERROR (system.poll ()); + } + auto history_node (response.json.get_child ("history")); + ASSERT_EQ (history_node.size (), 1); + } } TEST (rpc, history_count)