From 93ad1f872358ef9619a1e39148ff5d079790aea6 Mon Sep 17 00:00:00 2001 From: binaryFate Date: Fri, 6 Oct 2017 17:55:25 +0200 Subject: Fix #2559: more flexible print_tx daemon command --- src/daemon/command_parser_executor.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/daemon/command_parser_executor.cpp') diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp index af46453cd..9e61e9acd 100644 --- a/src/daemon/command_parser_executor.cpp +++ b/src/daemon/command_parser_executor.cpp @@ -187,9 +187,24 @@ bool t_command_parser_executor::print_block(const std::vector& args bool t_command_parser_executor::print_transaction(const std::vector& args) { + bool include_hex = false; + bool include_json = false; + + // Assumes that optional flags come after mandatory argument + for (unsigned int i = 1; i < args.size(); ++i) { + if (args[i] == "+hex") + include_hex = true; + else if (args[i] == "+json") + include_json = true; + else + { + std::cout << "unexpected argument: " << args[i] << std::endl; + return true; + } + } if (args.empty()) { - std::cout << "expected: print_tx " << std::endl; + std::cout << "expected: print_tx [+hex] [+json]" << std::endl; return true; } @@ -197,7 +212,7 @@ bool t_command_parser_executor::print_transaction(const std::vector crypto::hash tx_hash; if (parse_hash256(str_hash, tx_hash)) { - m_executor.print_transaction(tx_hash); + m_executor.print_transaction(tx_hash, include_hex, include_json); } return true; -- cgit v1.2.3