diff options
author | Riccardo Spagni <ric@spagni.net> | 2015-08-10 20:03:17 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2015-08-10 20:03:21 +0200 |
commit | 5c87469fd1a42242977cf606858897f036f0874b (patch) | |
tree | 9ba309ca02bf11ab222699f38004ba2e06147d1d /src | |
parent | Merge pull request #361 (diff) | |
parent | daemon: omit extra set of <> in error message (diff) | |
download | monero-5c87469fd1a42242977cf606858897f036f0874b.tar.xz |
Merge pull request #362
2634307 daemon: omit extra set of <> in error message (moneromooo-monero)
0822933 daemon: print a decoded tx in print_tx (moneromooo-monero)
1d678b1 daemon: fix print_tx not find transactions (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r-- | src/daemon/rpc_command_executor.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp index 4ba9a5f32..2f3a6b4d5 100644 --- a/src/daemon/rpc_command_executor.cpp +++ b/src/daemon/rpc_command_executor.cpp @@ -482,6 +482,7 @@ bool t_rpc_command_executor::print_transaction(crypto::hash transaction_hash) { } else { + req.txs_hashes.push_back(epee::string_tools::pod_to_hex(transaction_hash)); if (!m_rpc_server->on_get_transactions(req, res)) { tools::fail_msg_writer() << fail_message.c_str(); @@ -491,11 +492,29 @@ bool t_rpc_command_executor::print_transaction(crypto::hash transaction_hash) { if (1 == res.txs_as_hex.size()) { + // first as hex tools::success_msg_writer() << res.txs_as_hex.front(); + + // then as json + crypto::hash tx_hash, tx_prefix_hash; + cryptonote::transaction tx; + cryptonote::blobdata blob; + if (!string_tools::parse_hexstr_to_binbuff(res.txs_as_hex.front(), blob)) + { + tools::fail_msg_writer() << "Failed to parse tx"; + } + else if (!cryptonote::parse_and_validate_tx_from_blob(blob, tx, tx_hash, tx_prefix_hash)) + { + tools::fail_msg_writer() << "Failed to parse tx blob"; + } + else + { + tools::success_msg_writer() << cryptonote::obj_to_json_str(tx) << std::endl; + } } else { - tools::fail_msg_writer() << "transaction wasn't found: <" << transaction_hash << '>' << std::endl; + tools::fail_msg_writer() << "transaction wasn't found: " << transaction_hash << std::endl; } return true; |