Merge pull request #6095
7ba31191
daemon: add +meta print_tx parameter (moneromooo-monero)
This commit is contained in:
commit
b8e5c769c7
@ -243,12 +243,15 @@ bool t_command_parser_executor::print_block(const std::vector<std::string>& args
|
|||||||
|
|
||||||
bool t_command_parser_executor::print_transaction(const std::vector<std::string>& args)
|
bool t_command_parser_executor::print_transaction(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
|
bool include_metadata = false;
|
||||||
bool include_hex = false;
|
bool include_hex = false;
|
||||||
bool include_json = false;
|
bool include_json = false;
|
||||||
|
|
||||||
// Assumes that optional flags come after mandatory argument <transaction_hash>
|
// Assumes that optional flags come after mandatory argument <transaction_hash>
|
||||||
for (unsigned int i = 1; i < args.size(); ++i) {
|
for (unsigned int i = 1; i < args.size(); ++i) {
|
||||||
if (args[i] == "+hex")
|
if (args[i] == "+meta")
|
||||||
|
include_metadata = true;
|
||||||
|
else if (args[i] == "+hex")
|
||||||
include_hex = true;
|
include_hex = true;
|
||||||
else if (args[i] == "+json")
|
else if (args[i] == "+json")
|
||||||
include_json = true;
|
include_json = true;
|
||||||
@ -260,7 +263,7 @@ bool t_command_parser_executor::print_transaction(const std::vector<std::string>
|
|||||||
}
|
}
|
||||||
if (args.empty())
|
if (args.empty())
|
||||||
{
|
{
|
||||||
std::cout << "expected: print_tx <transaction_hash> [+hex] [+json]" << std::endl;
|
std::cout << "expected: print_tx <transaction_hash> [+meta] [+hex] [+json]" << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +271,7 @@ bool t_command_parser_executor::print_transaction(const std::vector<std::string>
|
|||||||
crypto::hash tx_hash;
|
crypto::hash tx_hash;
|
||||||
if (parse_hash256(str_hash, tx_hash))
|
if (parse_hash256(str_hash, tx_hash))
|
||||||
{
|
{
|
||||||
m_executor.print_transaction(tx_hash, include_hex, include_json);
|
m_executor.print_transaction(tx_hash, include_metadata, include_hex, include_json);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -940,6 +940,7 @@ bool t_rpc_command_executor::print_block_by_height(uint64_t height, bool include
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool t_rpc_command_executor::print_transaction(crypto::hash transaction_hash,
|
bool t_rpc_command_executor::print_transaction(crypto::hash transaction_hash,
|
||||||
|
bool include_metadata,
|
||||||
bool include_hex,
|
bool include_hex,
|
||||||
bool include_json) {
|
bool include_json) {
|
||||||
cryptonote::COMMAND_RPC_GET_TRANSACTIONS::request req;
|
cryptonote::COMMAND_RPC_GET_TRANSACTIONS::request req;
|
||||||
@ -982,6 +983,29 @@ bool t_rpc_command_executor::print_transaction(crypto::hash transaction_hash,
|
|||||||
const std::string &as_hex = (1 == res.txs.size()) ? res.txs.front().as_hex : res.txs_as_hex.front();
|
const std::string &as_hex = (1 == res.txs.size()) ? res.txs.front().as_hex : res.txs_as_hex.front();
|
||||||
const std::string &pruned_as_hex = (1 == res.txs.size()) ? res.txs.front().pruned_as_hex : "";
|
const std::string &pruned_as_hex = (1 == res.txs.size()) ? res.txs.front().pruned_as_hex : "";
|
||||||
const std::string &prunable_as_hex = (1 == res.txs.size()) ? res.txs.front().prunable_as_hex : "";
|
const std::string &prunable_as_hex = (1 == res.txs.size()) ? res.txs.front().prunable_as_hex : "";
|
||||||
|
// Print metadata if requested
|
||||||
|
if (include_metadata)
|
||||||
|
{
|
||||||
|
if (!res.txs.front().in_pool)
|
||||||
|
{
|
||||||
|
tools::msg_writer() << "Block timestamp: " << res.txs.front().block_timestamp << " (" << tools::get_human_readable_timestamp(res.txs.front().block_timestamp) << ")";
|
||||||
|
}
|
||||||
|
cryptonote::blobdata blob;
|
||||||
|
if (epee::string_tools::parse_hexstr_to_binbuff(pruned_as_hex + prunable_as_hex, blob))
|
||||||
|
{
|
||||||
|
cryptonote::transaction tx;
|
||||||
|
if (cryptonote::parse_and_validate_tx_from_blob(blob, tx))
|
||||||
|
{
|
||||||
|
tools::msg_writer() << "Size: " << blob.size();
|
||||||
|
tools::msg_writer() << "Weight: " << cryptonote::get_transaction_weight(tx);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tools::fail_msg_writer() << "Error parsing transaction blob";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tools::fail_msg_writer() << "Error parsing transaction from hex";
|
||||||
|
}
|
||||||
|
|
||||||
// Print raw hex if requested
|
// Print raw hex if requested
|
||||||
if (include_hex)
|
if (include_hex)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ public:
|
|||||||
|
|
||||||
bool print_block_by_height(uint64_t height, bool include_hex);
|
bool print_block_by_height(uint64_t height, bool include_hex);
|
||||||
|
|
||||||
bool print_transaction(crypto::hash transaction_hash, bool include_hex, bool include_json);
|
bool print_transaction(crypto::hash transaction_hash, bool include_metadata, bool include_hex, bool include_json);
|
||||||
|
|
||||||
bool is_key_image_spent(const crypto::key_image &ki);
|
bool is_key_image_spent(const crypto::key_image &ki);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user