diff --git a/modules/net/dap_chain_ledger.c b/modules/net/dap_chain_ledger.c index f820ea26daf39edcfc847066a28394a8fe2a541f..d12edc92b13ecc6837720e679f69a6f6dfaed24a 100644 --- a/modules/net/dap_chain_ledger.c +++ b/modules/net/dap_chain_ledger.c @@ -3229,7 +3229,11 @@ void dap_ledger_addr_get_token_ticker_all(dap_ledger_t *a_ledger, dap_chain_addr } } - +const char *dap_ledger_get_description_by_ticker(dap_ledger_t *a_ledger, const char *a_token_ticker){ + if (!a_ledger || !a_token_ticker) + return NULL; + return s_ledger_find_token(a_ledger, a_token_ticker)->description_token; +} /** * Get transaction in the cache by hash diff --git a/modules/net/dap_chain_node_cli_cmd_tx.c b/modules/net/dap_chain_node_cli_cmd_tx.c index 98887dfa3cf0bd64b04155f8dceaf12268a12b86..7ae6cef70e64263953e9b01d7e72203be6a04839 100644 --- a/modules/net/dap_chain_node_cli_cmd_tx.c +++ b/modules/net/dap_chain_node_cli_cmd_tx.c @@ -106,11 +106,14 @@ static bool s_dap_chain_datum_tx_out_data(dap_chain_datum_tx_t *a_datum, : NULL; if (!l_ticker) return false; + const char *l_description = dap_ledger_get_description_by_ticker(a_ledger, l_ticker); dap_time_to_str_rfc822(l_tmp_buf, DAP_TIME_STR_SIZE, l_ts_create); dap_chain_hash_fast_to_str(a_tx_hash,l_tx_hash_str,sizeof(l_tx_hash_str)); json_object_object_add(json_obj_out, "Datum_tx_hash", json_object_new_string(l_tx_hash_str)); json_object_object_add(json_obj_out, "TS_Created", json_object_new_string(l_tmp_buf)); json_object_object_add(json_obj_out, "Token_ticker", json_object_new_string(l_ticker)); + json_object_object_add(json_obj_out, "Token_description", l_description ? json_object_new_string(l_description) + : json_object_new_null()); json_object* datum_tx = dap_chain_datum_tx_to_json(a_datum,&a_ledger->net->pub.id); json_object_object_add(json_obj_out, "Datum_tx", datum_tx); dap_list_t *l_out_items = dap_chain_datum_tx_items_get(a_datum, TX_ITEM_TYPE_OUT_ALL, NULL); @@ -156,6 +159,7 @@ json_object * dap_db_tx_history_to_json(dap_chain_hash_fast_t* a_tx_hash, bool brief_out) { const char *l_tx_token_ticker = NULL; + const char *l_tx_token_description = NULL; json_object* json_obj_datum = json_object_new_object(); if (!json_obj_datum) { return NULL; @@ -165,6 +169,7 @@ json_object * dap_db_tx_history_to_json(dap_chain_hash_fast_t* a_tx_hash, l_tx_token_ticker = dap_ledger_tx_get_token_ticker_by_hash(l_ledger, a_tx_hash); if (l_tx_token_ticker) { json_object_object_add(json_obj_datum, "status", json_object_new_string("ACCEPTED")); + l_tx_token_description = dap_ledger_get_description_by_ticker(l_ledger, l_tx_token_ticker); *accepted_tx = true; } else { json_object_object_add(json_obj_datum, "status", json_object_new_string("DECLINED")); @@ -185,6 +190,8 @@ json_object * dap_db_tx_history_to_json(dap_chain_hash_fast_t* a_tx_hash, json_object_object_add(json_obj_datum, "token_ticker", l_tx_token_ticker ? json_object_new_string(l_tx_token_ticker) : json_object_new_null()); + json_object_object_add(json_obj_datum, "token_description", l_tx_token_description ? json_object_new_string(l_tx_token_description) + : json_object_new_null()); json_object_object_add(json_obj_datum, "ret_code", json_object_new_int(l_ret_code)); json_object_object_add(json_obj_datum, "ret_code_str", json_object_new_string(dap_ledger_tx_check_err_str(l_ret_code))); diff --git a/modules/net/include/dap_chain_ledger.h b/modules/net/include/dap_chain_ledger.h index 0b1b58d21ac0a2040da1e931acd79ba9686ee668..4d3db2f9060f27a7dad04c0a2c43587dfb5763aa 100644 --- a/modules/net/include/dap_chain_ledger.h +++ b/modules/net/include/dap_chain_ledger.h @@ -267,6 +267,8 @@ void dap_ledger_addr_get_token_ticker_all_depricated(dap_ledger_t *a_ledger, dap void dap_ledger_addr_get_token_ticker_all(dap_ledger_t *a_ledger, dap_chain_addr_t * a_addr, char *** a_tickers, size_t * a_tickers_size); +const char *dap_ledger_get_description_by_ticker(dap_ledger_t *a_ledger, const char *a_token_ticker); + bool dap_ledger_tx_poa_signed(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx); // Checking a new transaction before adding to the cache