diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index d69cb85a27b7da5cf2d98b1b645035383cb1cbd8..4cd02cc2c805548b9b8e0681f627adf1fc1e9b87 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -1750,13 +1750,6 @@ int l_arg_index = 1, l_rc, cmd_num = CMD_NONE; break; } case CMD_WALLET_OUTPUTS: { - if(!l_net) { - dap_json_rpc_error_add(*a_json_arr_reply, DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NET_PARAM_ERR, - "Subcommand info requires parameter '-net'"); - json_object_put(json_arr_out); - return DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NET_PARAM_ERR; - } - if ((l_wallet_name && l_addr_str) || (!l_wallet_name && !l_addr_str)) { dap_json_rpc_error_add(*a_json_arr_reply, DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NAME_ERR, "You should use either the -w or -addr option for the wallet info command."); @@ -1764,6 +1757,12 @@ int l_arg_index = 1, l_rc, cmd_num = CMD_NONE; return DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NAME_ERR; } if(l_wallet_name) { + if(!l_net) { + dap_json_rpc_error_add(*a_json_arr_reply, DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NET_PARAM_ERR, + "Subcommand info requires parameter '-net'"); + json_object_put(json_arr_out); + return DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NET_PARAM_ERR; + } l_wallet = dap_chain_wallet_open(l_wallet_name, c_wallets_path, NULL); if (!l_wallet){ dap_json_rpc_error_add(*a_json_arr_reply, DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NET_PARAM_ERR, @@ -1780,6 +1779,15 @@ int l_arg_index = 1, l_rc, cmd_num = CMD_NONE; } } else { l_addr = dap_chain_addr_from_str(l_addr_str); + if (!l_net) + l_net = dap_chain_net_by_id(l_addr->net_id); + + if(!l_net) { + dap_json_rpc_error_add(*a_json_arr_reply, DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NET_PARAM_ERR, + "Can't get net from wallet addr"); + json_object_put(json_arr_out); + return DAP_CHAIN_NODE_CLI_COM_TX_WALLET_NET_PARAM_ERR; + } } const char* l_token_tiker = NULL; diff --git a/modules/service/xchange/dap_chain_net_srv_xchange.c b/modules/service/xchange/dap_chain_net_srv_xchange.c index 8f4fa81f4685c7f2591d07935499b5f951fe1db3..f49389ff34b96167fce905c36b61f401ce0afa82 100644 --- a/modules/service/xchange/dap_chain_net_srv_xchange.c +++ b/modules/service/xchange/dap_chain_net_srv_xchange.c @@ -1578,16 +1578,19 @@ static int s_cli_srv_xchange_order(int a_argc, char **a_argv, int a_arg_index, j if(l_rc == XCHANGE_ORDER_STATUS_UNKNOWN){ json_object_object_add(l_json_obj_order, "WRONG TX", json_object_new_string(l_tx_hash)); }else{ - json_object_object_add(l_json_obj_order, "history for order", json_object_new_string(l_order_hash_str)); dap_list_t *l_tx_list = dap_chain_net_get_tx_cond_chain(l_net, &l_order_tx_hash, c_dap_chain_net_srv_xchange_uid ); dap_list_t *l_tx_list_temp = l_tx_list; + json_object* l_json_obj_tx_arr = json_object_new_array(); while(l_tx_list_temp ){ + json_object* l_json_obj_cur_tx = json_object_new_object(); dap_chain_datum_tx_t * l_tx_cur = (dap_chain_datum_tx_t*) l_tx_list_temp->data; dap_hash_fast_t l_hash = {}; dap_hash_fast(l_tx_cur, dap_chain_datum_tx_get_size(l_tx_cur), &l_hash); - s_string_append_tx_cond_info_json(l_json_obj_order, l_net, NULL, NULL, l_tx_cur, &l_hash, TX_STATUS_ALL, true, true, false); + s_string_append_tx_cond_info_json(l_json_obj_cur_tx, l_net, NULL, NULL, l_tx_cur, &l_hash, TX_STATUS_ALL, true, true, false); + json_object_array_add(l_json_obj_tx_arr, l_json_obj_cur_tx); l_tx_list_temp = l_tx_list_temp->next; } + json_object_object_add(l_json_obj_order, "history for order", l_json_obj_tx_arr); dap_list_free(l_tx_list); } } @@ -1607,10 +1610,13 @@ static int s_cli_srv_xchange_order(int a_argc, char **a_argv, int a_arg_index, j dap_json_rpc_error_add(*a_json_arr_reply, DAP_CHAIN_NODE_CLI_COM_NET_SRV_XCNGE_ORDRS_HIST_DOES_NO_HISTORY_ERR, "No history"); return -DAP_CHAIN_NODE_CLI_COM_NET_SRV_XCNGE_ORDRS_HIST_DOES_NO_HISTORY_ERR; } + json_object* l_json_obj_tx_arr = json_object_new_array(); while(l_item){ - s_string_append_tx_cond_info_json(l_json_obj_order, l_net, &l_item->seller_addr, + json_object* l_json_obj_cur_tx = json_object_new_object(); + s_string_append_tx_cond_info_json(l_json_obj_cur_tx, l_net, &l_item->seller_addr, l_item->tx_type == TX_TYPE_EXCHANGE ? &l_item->tx_info.exchange_info.buyer_addr : NULL, l_item->tx, &l_item->hash, TX_STATUS_ALL, true, true, false); + json_object_array_add(l_json_obj_tx_arr, l_json_obj_cur_tx); switch(l_item->tx_type){ case TX_TYPE_ORDER:{ l_cur_hash = l_item->tx_info.order_info.next_hash; @@ -1627,6 +1633,7 @@ static int s_cli_srv_xchange_order(int a_argc, char **a_argv, int a_arg_index, j break; HASH_FIND(hh, l_cache->cache, &l_cur_hash, sizeof(dap_hash_fast_t), l_item); } + json_object_object_add(l_json_obj_order, "history for order", l_json_obj_tx_arr); } } json_object_array_add(*a_json_arr_reply, l_json_obj_order); @@ -1888,6 +1895,7 @@ static int s_cli_srv_xchange_order(int a_argc, char **a_argv, int a_arg_index, j json_object_object_add(json_obj_order, "rate", json_object_new_string(l_cp_rate)); json_object_object_add(json_obj_order, "net", json_object_new_string(l_net->pub.name)); + json_object_object_add(json_obj_order, "owner_addr", json_object_new_string(l_owner_addr)); json_object_array_add(*a_json_arr_reply, json_obj_order); DAP_DELETE(l_owner_addr); if ( s_xchange_cache_state != XCHANGE_CACHE_ENABLED ) @@ -2767,6 +2775,7 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, void **a_str_reply) json_object_object_add(json_obj_order, "rate", json_object_new_string(l_cp_rate)); json_object_object_add(json_obj_order, "net", json_object_new_string(l_net->pub.name)); + json_object_object_add(json_obj_order, "owner_addr", json_object_new_string(l_owner_addr)); json_object_array_add(*json_arr_reply, json_obj_order); DAP_DELETE(l_owner_addr); l_printed_orders_count++; @@ -2965,6 +2974,7 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, void **a_str_reply) l_show_tx_nr++; } } + json_object_array_add(*json_arr_reply, json_arr_bl_out); } else { dap_list_t *l_datum_list0 = dap_chain_datum_list(l_net, NULL, s_filter_tx_list, l_time); size_t l_datum_num = dap_list_length(l_datum_list0); @@ -2987,6 +2997,7 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, void **a_str_reply) } l_datum_list = dap_list_next(l_datum_list); } + json_object_array_add(*json_arr_reply, json_arr_bl_out); } dap_list_free_full(l_datum_list0, NULL); }