1467 {
1468 auto get_transaction_id = actionRoot->
add_subcommand(
"transaction_id",
localized(
"Get transaction id given transaction object"));
1470
1471 get_transaction_id->callback([&] {
1472 try {
1476
1478 if( vo["actions"].is_array() ) {
1480 fc::variants& action_variants = mvo[
"actions"].get_array();
1481 for( auto& action_v : action_variants ) {
1482 if( !action_v.is_object() ) {
1483 std::cerr << "Empty 'action' in transaction" << endl;
1484 return;
1485 }
1489 maction_vo["data"] = maction_vo["hex_data"];
1490 action_vo = maction_vo;
1491 vo = mvo;
1492 }
else if( action_vo.
contains(
"data" ) ) {
1493 if( !action_vo["data"].is_string() ) {
1494 std::cerr << "get transaction_id only supports un-exploded 'data' (hex form)" << std::endl;
1495 return;
1496 }
1497 }
1498 }
1499 } else {
1500 std::cerr << "transaction JSON 'actions' is not an array" << std::endl;
1501 return;
1502 }
1503 } else {
1504 std::cerr << "transaction JSON does not include 'actions'" << std::endl;
1505 return;
1506 }
1510 std::cerr << "file/string does not represent a transaction" << std::endl;
1511 } else {
1512 std::cout <<
string(
id ) << std::endl;
1513 }
1514 } else {
1515 std::cerr << "file/string does not represent a transaction" << std::endl;
1516 }
1518 });
1519 }
#define SYS_RETHROW_EXCEPTIONS(exception_type, FORMAT,...)
App * add_subcommand(std::string subcommand_name="", std::string subcommand_description="")
Add a subcommand. Inherits INHERITABLE and OptionDefaults, and help flag.
Option * add_option(std::string option_name, callback_t option_callback, std::string option_description="", bool defaulted=false, std::function< std::string()> func={})
CRTP * required(bool value=true)
Set the option as required.
An order-preserving dictionary of variants.
An order-preserving dictionary of variants.
bool contains(const char *key) const
stores null, int64, uint64, double, bool, string, std::vector<variant>, and variant_object's.
variant_object & get_object()
#define localized(str,...)
std::vector< fc::variant > variants
fc::variant json_from_file_or_string(const string &file_or_str, fc::json::parse_type ptype=fc::json::parse_type::legacy_parser)