未验证 提交 4731ebec 编写于 作者: K Kevin Heifner 提交者: GitHub

Merge pull request #4892 from EOSIO/3238

Add API and cleos command to get transaction id given transaction
......@@ -94,6 +94,7 @@ void chain_api_plugin::plugin_startup() {
CHAIN_RO_CALL(abi_json_to_bin, 200),
CHAIN_RO_CALL(abi_bin_to_json, 200),
CHAIN_RO_CALL(get_required_keys, 200),
CHAIN_RO_CALL(get_transaction_id, 200),
CHAIN_RW_CALL_ASYNC(push_block, chain_apis::read_write::push_block_results, 202),
CHAIN_RW_CALL_ASYNC(push_transaction, chain_apis::read_write::push_transaction_results, 202),
CHAIN_RW_CALL_ASYNC(push_transactions, chain_apis::read_write::push_transactions_results, 202)
......
......@@ -1609,6 +1609,10 @@ read_only::get_required_keys_result read_only::get_required_keys( const get_requ
return result;
}
read_only::get_transaction_id_result read_only::get_transaction_id( const read_only::get_transaction_id_params& params)const {
return params.id();
}
} // namespace chain_apis
} // namespace eosio
......@@ -29,6 +29,8 @@ namespace eosio {
using chain::name;
using chain::uint128_t;
using chain::public_key_type;
using chain::transaction;
using chain::transaction_id_type;
using fc::optional;
using boost::container::flat_set;
using chain::asset;
......@@ -206,6 +208,10 @@ public:
get_required_keys_result get_required_keys( const get_required_keys_params& params)const;
using get_transaction_id_params = transaction;
using get_transaction_id_result = transaction_id_type;
get_transaction_id_result get_transaction_id( const get_transaction_id_params& params)const;
struct get_block_params {
string block_num_or_id;
......
......@@ -1117,6 +1117,23 @@ struct get_schedule_subcommand {
}
};
struct get_transaction_id_subcommand {
string trx_to_check;
get_transaction_id_subcommand(CLI::App* actionRoot) {
auto get_transaction_id = actionRoot->add_subcommand("transaction_id", localized("Get transaction id given transaction object"));
get_transaction_id->add_option("transaction", trx_to_check, localized("The JSON string or filename defining the transaction which transaction id we want to retrieve"))->required();
get_transaction_id->set_callback([&] {
try {
auto trx_var = json_from_file_or_string(trx_to_check);
auto trx = trx_var.as<transaction>();
std::cout << string(trx.id()) << std::endl;
} EOS_RETHROW_EXCEPTIONS(transaction_type_exception, "Fail to parse transaction JSON '${data}'", ("data",trx_to_check))
});
}
};
struct delegate_bandwidth_subcommand {
string from_str;
string receiver_str;
......@@ -2052,7 +2069,8 @@ int main( int argc, char** argv ) {
});
auto getSchedule = get_schedule_subcommand{get};
auto getTransactionId = get_transaction_id_subcommand{get};
/*
auto getTransactions = get->add_subcommand("transactions", localized("Retrieve all transactions with specific account name referenced in their scope"), false);
getTransactions->add_option("account_name", account_name, localized("name of account to query on"))->required();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册