From fb0fea46af38a8ba1f3e598063dc956dffe6318d Mon Sep 17 00:00:00 2001
From: "daniil.frolov" <daniil.frolov@demlabs.net>
Date: Tue, 25 Jun 2024 11:02:39 +0000
Subject: [PATCH] hotfix-12109

---
 modules/net/dap_chain_ledger.c         |  5 +++--
 modules/net/dap_chain_node_cli_cmd.c   | 15 +++++++++++++++
 modules/net/include/dap_chain_ledger.h |  2 +-
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/modules/net/dap_chain_ledger.c b/modules/net/dap_chain_ledger.c
index fda57f4916..40ccfc136e 100644
--- a/modules/net/dap_chain_ledger.c
+++ b/modules/net/dap_chain_ledger.c
@@ -3772,7 +3772,7 @@ bool dap_ledger_tx_service_info(dap_ledger_t *a_ledger, dap_hash_fast_t *a_tx_ha
 }
 
 
-bool dap_ledger_deduct_tx_tag(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_net_srv_uid_t *a_tag, dap_chain_tx_tag_action_type_t *a_action)
+bool dap_ledger_deduct_tx_tag(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, char **a_service_name, dap_chain_net_srv_uid_t *a_tag, dap_chain_tx_tag_action_type_t *a_action)
 {
     dap_ledger_service_info_t *l_sinfo_current, *l_sinfo_tmp;
 
@@ -3789,6 +3789,7 @@ bool dap_ledger_deduct_tx_tag(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx
         if (l_sinfo_current->callback && l_sinfo_current->callback(a_ledger, a_tx, &l_items_groups, &action)){
             if (a_tag) *a_tag =  l_sinfo_current->service_uid;
             if (a_action) *a_action =  action;
+            if (a_service_name) *a_service_name = l_sinfo_current->tag_str;
             l_res = true;
             l_deductions_ok ++;
         }
@@ -3901,7 +3902,7 @@ int dap_ledger_tx_cache_check(dap_ledger_t *a_ledger,
     bool l_girdled_ems_used = false;
     uint256_t l_taxed_value = {};
     
-    if(a_tag) dap_ledger_deduct_tx_tag(a_ledger, a_tx, a_tag, a_action);
+    if(a_tag) dap_ledger_deduct_tx_tag(a_ledger, a_tx, NULL, a_tag, a_action);
 
     // find all previous transactions
     for (dap_list_t *it = l_list_in; it; it = it->next) {
diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c
index 3e221a308e..d6b35ecd5b 100644
--- a/modules/net/dap_chain_node_cli_cmd.c
+++ b/modules/net/dap_chain_node_cli_cmd.c
@@ -2751,6 +2751,21 @@ void s_com_mempool_list_print_for_chain(dap_chain_net_t * a_net, dap_chain_t * a
                         json_object_object_add(l_jobj_datum, "main_ticker", l_jobj_main_ticker);
                         json_object_object_add(l_jobj_datum, "ledger_rc", l_jobj_ledger_rc);
 
+                        dap_chain_net_srv_uid_t uid;
+                        char *service_name;
+                        dap_chain_tx_tag_action_type_t action;
+                        if (dap_ledger_deduct_tx_tag(a_net->pub.ledger, l_tx, &service_name, &uid, &action))
+                        {
+                            json_object_object_add(l_jobj_datum, "service", json_object_new_string(service_name));
+                            json_object_object_add(l_jobj_datum, "action", json_object_new_string(dap_ledger_tx_action_str(action)));
+                        }
+                        else
+                        {   
+                            json_object_object_add(l_jobj_datum, "service", json_object_new_string("UNKNOWN"));
+                            json_object_object_add(l_jobj_datum, "action", json_object_new_string("UNKNOWN"));
+                        }
+
+
                         dap_list_t *l_list_sig_item = dap_chain_datum_tx_items_get(l_tx, TX_ITEM_TYPE_SIG, NULL);
                         dap_list_t *l_list_in_ems = dap_chain_datum_tx_items_get(l_tx, TX_ITEM_TYPE_IN_EMS, NULL);
                         if (!l_list_sig_item) {
diff --git a/modules/net/include/dap_chain_ledger.h b/modules/net/include/dap_chain_ledger.h
index 5b9104f462..777e259835 100644
--- a/modules/net/include/dap_chain_ledger.h
+++ b/modules/net/include/dap_chain_ledger.h
@@ -303,7 +303,7 @@ const char *dap_ledger_get_description_by_ticker(dap_ledger_t *a_ledger, const c
 bool dap_ledger_tx_poa_signed(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx);
 
 //TX service-tags
-bool dap_ledger_deduct_tx_tag(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, dap_chain_net_srv_uid_t *uid, dap_chain_tx_tag_action_type_t *action);
+bool dap_ledger_deduct_tx_tag(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, char **a_service_name, dap_chain_net_srv_uid_t *uid, dap_chain_tx_tag_action_type_t *action);
 const char *dap_ledger_tx_action_str(dap_chain_tx_tag_action_type_t a_tag);
 dap_chain_tx_tag_action_type_t dap_ledger_tx_action_str_to_action_t(const char *a_str);
 
-- 
GitLab