diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index 5956b8b1925825b09071cb971108f3f7b7232472..b7c8acd6c168edb8ceddef854bc1dc708089d5ca 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -6392,10 +6392,12 @@ int com_tx_history(int a_argc, char ** a_argv, void **a_str_reply) } dap_chain_hash_fast_t l_tx_hash; - if (l_tx_hash_str && dap_chain_hash_fast_from_str(l_tx_hash_str, &l_tx_hash) < 0) { + if (l_tx_hash_str && dap_chain_hash_fast_from_str(l_tx_hash_str, &l_tx_hash) != 0) { + dap_json_rpc_error_add(DAP_CHAIN_NODE_CLI_COM_TX_HISTORY_HASH_REC_ERR, "tx hash not recognized"); return DAP_CHAIN_NODE_CLI_COM_TX_HISTORY_HASH_REC_ERR; } + // Select chain network if (!l_addr_base58 && l_net_str) { l_net = dap_chain_net_by_name(l_net_str); @@ -6484,12 +6486,18 @@ int com_tx_history(int a_argc, char ** a_argv, void **a_str_reply) } } else if (l_is_tx_all) { // history all + const char * l_brief_type = NULL; + bool l_brief_out = false; + if (dap_cli_server_cmd_find_option_val(a_argv, arg_index, a_argc, "-brief", &l_brief_type)) + l_brief_out = true; + + json_object * json_obj_summary = json_object_new_object(); if (!json_obj_summary) { return DAP_CHAIN_NODE_CLI_COM_TX_HISTORY_MEMORY_ERR; } - json_object* json_arr_history_all = dap_db_history_tx_all(l_chain, l_net, l_hash_out_type, json_obj_summary); + json_object* json_arr_history_all = dap_db_history_tx_all(l_chain, l_net, l_hash_out_type, json_obj_summary, l_brief_out); if (!json_arr_history_all) { dap_json_rpc_error_add(DAP_CHAIN_NODE_CLI_COM_TX_HISTORY_DAP_DB_HISTORY_ALL_ERR, "something went wrong in tx_history"); diff --git a/modules/net/dap_chain_node_cli_cmd_tx.c b/modules/net/dap_chain_node_cli_cmd_tx.c index d6047738a96ef4cdb2ee130123373fb0ccbf2134..a5ce09d4e758b456e420c530eb3dba948de1b5ec 100644 --- a/modules/net/dap_chain_node_cli_cmd_tx.c +++ b/modules/net/dap_chain_node_cli_cmd_tx.c @@ -152,7 +152,8 @@ json_object * dap_db_tx_history_to_json(dap_chain_hash_fast_t* a_tx_hash, const char *a_hash_out_type, dap_chain_net_t * l_net, int l_ret_code, - bool *accepted_tx) + bool *accepted_tx, + bool brief_out) { const char *l_tx_token_ticker = NULL; json_object* json_obj_datum = json_object_new_object(); @@ -195,9 +196,12 @@ json_object * dap_db_tx_history_to_json(dap_chain_hash_fast_t* a_tx_hash, } json_object *l_obj_ts_created = json_object_new_string(l_time_str); json_object_object_add(json_obj_datum, "tx_created", l_obj_ts_created); - - json_object* datum_tx = dap_chain_datum_tx_to_json(l_tx,&a_chain->net_id); - json_object_object_add(json_obj_datum, "items", datum_tx); + + if(!brief_out) + { + json_object* datum_tx = dap_chain_datum_tx_to_json(l_tx,&a_chain->net_id); + json_object_object_add(json_obj_datum, "items", datum_tx); + } return json_obj_datum; } @@ -222,7 +226,7 @@ json_object * dap_db_history_tx(dap_chain_hash_fast_t* a_tx_hash, (dap_chain_datum_tx_t *)l_datum->data : NULL; if (l_tx) { - return dap_db_tx_history_to_json(a_tx_hash, &l_atom_hash,l_tx, a_chain, a_hash_out_type, l_net, l_ret_code, &accepted_tx); + return dap_db_tx_history_to_json(a_tx_hash, &l_atom_hash,l_tx, a_chain, a_hash_out_type, l_net, l_ret_code, &accepted_tx, false); } else { char *l_tx_hash_str = dap_strcmp(a_hash_out_type, "hex") ? dap_enc_base58_encode_hash_to_str_static(a_tx_hash) @@ -585,7 +589,7 @@ json_object* dap_db_history_addr(dap_chain_addr_t *a_addr, dap_chain_t *a_chain, return json_obj_datum; } -json_object* dap_db_history_tx_all(dap_chain_t *l_chain, dap_chain_net_t* l_net, const char *l_hash_out_type, json_object * json_obj_summary) { +json_object* dap_db_history_tx_all(dap_chain_t *l_chain, dap_chain_net_t* l_net, const char *l_hash_out_type, json_object * json_obj_summary, bool out_brief) { log_it(L_DEBUG, "Start getting tx from chain"); size_t l_tx_count = 0; size_t l_tx_ledger_accepted = 0; @@ -608,7 +612,7 @@ json_object* dap_db_history_tx_all(dap_chain_t *l_chain, dap_chain_net_t* l_net, dap_hash_fast_t l_ttx_hash = {0}; dap_hash_fast(l_tx, l_datums[i]->header.data_size, &l_ttx_hash); bool accepted_tx; - json_object* json_obj_datum = dap_db_tx_history_to_json(&l_ttx_hash, NULL, l_tx, l_chain, l_hash_out_type, l_net, 0, &accepted_tx); + json_object* json_obj_datum = dap_db_tx_history_to_json(&l_ttx_hash, NULL, l_tx, l_chain, l_hash_out_type, l_net, 0, &accepted_tx, out_brief); if (!json_obj_datum) { log_it(L_CRITICAL, "Memory allocation error"); return NULL; diff --git a/modules/net/include/dap_chain_node_cli_cmd_tx.h b/modules/net/include/dap_chain_node_cli_cmd_tx.h index ed0ef2d1f2e9e3b8b302468b7fba49e174612e7b..8c203515b3130d3988b1d3bd84a55c6829f6fd4c 100644 --- a/modules/net/include/dap_chain_node_cli_cmd_tx.h +++ b/modules/net/include/dap_chain_node_cli_cmd_tx.h @@ -48,8 +48,9 @@ json_object * dap_db_tx_history_to_json(dap_chain_hash_fast_t* a_tx_hash, const char *a_hash_out_type, dap_chain_net_t * l_net, int l_ret_code, - bool *accepted_tx); -json_object* dap_db_history_tx_all(dap_chain_t *l_chain, dap_chain_net_t* l_net, const char *l_hash_out_type, json_object * json_obj_summary); + bool *accepted_tx, + bool out_brief); +json_object* dap_db_history_tx_all(dap_chain_t *l_chain, dap_chain_net_t* l_net, const char *l_hash_out_type, json_object * json_obj_summary, bool out_brief); /** * ledger command