Skip to content
Snippets Groups Projects
Commit 6e774eea authored by Aleksandr Lysikov's avatar Aleksandr Lysikov
Browse files

fixed some error

parent 0cbb3ec6
No related branches found
No related tags found
No related merge requests found
...@@ -142,6 +142,22 @@ dap_chain_net_t * dap_chain_net_new(const char * a_id, const char * a_name , ...@@ -142,6 +142,22 @@ dap_chain_net_t * dap_chain_net_new(const char * a_id, const char * a_name ,
PVT(ret)->node_role.enums = ROOT; PVT(ret)->node_role.enums = ROOT;
log_it (L_NOTICE, "Node role \"root\" selected"); log_it (L_NOTICE, "Node role \"root\" selected");
} }
else if(strcmp(a_node_role, "master") == 0) {
PVT(ret)->node_role.enums = MASTER;
log_it(L_NOTICE, "Node role \"root\" selected");
}
else if(strcmp(a_node_role, "archive") == 0) {
PVT(ret)->node_role.enums = ARCHIVE;
log_it(L_NOTICE, "Node role \"root\" selected");
}
else if(strcmp(a_node_role, "full") == 0) {
PVT(ret)->node_role.enums = FULL;
log_it(L_NOTICE, "Node role \"root\" selected");
}
else if(strcmp(a_node_role, "ligth") == 0) {
PVT(ret)->node_role.enums = LIGHT;
log_it(L_NOTICE, "Node role \"root\" selected");
}
} else { } else {
log_it (L_ERROR, "Wrong id format (\"%s\"). Must be like \"0x0123456789ABCDE\"" , a_id ); log_it (L_ERROR, "Wrong id format (\"%s\"). Must be like \"0x0123456789ABCDE\"" , a_id );
} }
...@@ -186,13 +202,17 @@ int dap_chain_net_init() ...@@ -186,13 +202,17 @@ int dap_chain_net_init()
case ROOT: case ROOT:
case ARCHIVE: case ARCHIVE:
l_utxo_flags |= DAP_CHAIN_UTXO_CHECK_TOKEN_EMISSION; l_utxo_flags |= DAP_CHAIN_UTXO_CHECK_TOKEN_EMISSION;
break;
case MASTER: case MASTER:
l_utxo_flags |= DAP_CHAIN_UTXO_CHECK_CELLS_DS; l_utxo_flags |= DAP_CHAIN_UTXO_CHECK_CELLS_DS;
break;
case CELL_MASTER: case CELL_MASTER:
l_utxo_flags |= DAP_CHAIN_UTXO_CHECK_TOKEN_EMISSION; l_utxo_flags |= DAP_CHAIN_UTXO_CHECK_TOKEN_EMISSION;
break;
case FULL: case FULL:
case LIGHT: case LIGHT:
l_utxo_flags |= DAP_CHAIN_UTXO_CHECK_LOCAL_DS; l_utxo_flags |= DAP_CHAIN_UTXO_CHECK_LOCAL_DS;
break;
} }
dap_chain_utxo_init(l_utxo_flags); dap_chain_utxo_init(l_utxo_flags);
......
...@@ -413,6 +413,7 @@ void dap_chain_node_cli_cmd_item_create(const char * a_name, cmdfunc_t *a_func, ...@@ -413,6 +413,7 @@ void dap_chain_node_cli_cmd_item_create(const char * a_name, cmdfunc_t *a_func,
snprintf(l_cmd_item->name,sizeof (l_cmd_item->name),"%s",a_name); snprintf(l_cmd_item->name,sizeof (l_cmd_item->name),"%s",a_name);
l_cmd_item->doc = strdup( a_doc); l_cmd_item->doc = strdup( a_doc);
l_cmd_item->doc_ex = strdup( a_doc_ex); l_cmd_item->doc_ex = strdup( a_doc_ex);
l_cmd_item->func = a_func;
HASH_ADD_STR(s_commands,name,l_cmd_item); HASH_ADD_STR(s_commands,name,l_cmd_item);
log_it(L_DEBUG,"Added command %s",l_cmd_item->name); log_it(L_DEBUG,"Added command %s",l_cmd_item->name);
} }
......
...@@ -8,19 +8,19 @@ ...@@ -8,19 +8,19 @@
This file is part of DAP (Deus Applications Prototypes) the open source project This file is part of DAP (Deus Applications Prototypes) the open source project
DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify DAP (Deus Applicaions Prototypes) is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
DAP is distributed in the hope that it will be useful, DAP is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with any DAP based project. If not, see <http://www.gnu.org/licenses/>. along with any DAP based project. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -61,7 +61,6 @@ ...@@ -61,7 +61,6 @@
#define LOG_TAG "chain_node_cli_cmd" #define LOG_TAG "chain_node_cli_cmd"
/** /**
* Convert string to digit * Convert string to digit
*/ */
...@@ -212,7 +211,8 @@ static dap_chain_node_info_t* dap_chain_node_info_read(dap_chain_node_addr_t *ad ...@@ -212,7 +211,8 @@ static dap_chain_node_info_t* dap_chain_node_info_read(dap_chain_node_addr_t *ad
} }
size_t node_info_size_must_be = dap_chain_node_info_get_size(node_info); size_t node_info_size_must_be = dap_chain_node_info_get_size(node_info);
if(node_info_size_must_be != node_info_size) { if(node_info_size_must_be != node_info_size) {
dap_chain_node_cli_set_reply_text(str_reply, "node has bad size in base=%u (must be %u)", node_info_size, node_info_size_must_be); dap_chain_node_cli_set_reply_text(str_reply, "node has bad size in base=%u (must be %u)", node_info_size,
node_info_size_must_be);
DAP_DELETE(node_info); DAP_DELETE(node_info);
DAP_DELETE(l_key); DAP_DELETE(l_key);
return NULL; return NULL;
...@@ -745,25 +745,32 @@ int com_global_db(int argc, const char ** argv, char **str_reply) ...@@ -745,25 +745,32 @@ int com_global_db(int argc, const char ** argv, char **str_reply)
int arg_index_n = ++arg_index; int arg_index_n = ++arg_index;
// find command (add, delete, etc) as second parameter only // find command (add, delete, etc) as second parameter only
int cmd_num = CMD_NONE; int cmd_num = CMD_NONE;
if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "add", NULL)) != 0) { if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "add", NULL))
!= 0) {
cmd_num = CMD_ADD; cmd_num = CMD_ADD;
} }
else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "del", NULL)) != 0) { else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "del", NULL))
!= 0) {
cmd_num = CMD_DEL; cmd_num = CMD_DEL;
} }
else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "link", NULL)) != 0) { else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "link", NULL))
!= 0) {
cmd_num = CMD_LINK; cmd_num = CMD_LINK;
} }
else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "dump", NULL)) != 0) { else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "dump", NULL))
!= 0) {
cmd_num = CMD_DUMP; cmd_num = CMD_DUMP;
} }
else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "get", NULL)) != 0) { else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "get", NULL))
!= 0) {
cmd_num = CMD_GET; cmd_num = CMD_GET;
} }
else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "set", NULL)) != 0) { else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "set", NULL))
!= 0) {
cmd_num = CMD_SET; cmd_num = CMD_SET;
} }
else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "remote_set", NULL)) != 0) { else if((arg_index_n = dap_chain_node_cli_find_option_val(argv, arg_index, min(argc, arg_index + 1), "remote_set",
NULL)) != 0) {
cmd_num = CMD_REMOTE_SET; cmd_num = CMD_REMOTE_SET;
} }
if(cmd_num == CMD_NONE) { if(cmd_num == CMD_NONE) {
...@@ -968,7 +975,7 @@ int com_node(int argc, const char ** argv, char **str_reply) ...@@ -968,7 +975,7 @@ int com_node(int argc, const char ** argv, char **str_reply)
uint8_t l_ch_id = dap_stream_ch_chain_net_get_id(); // Channel id for global_db sync uint8_t l_ch_id = dap_stream_ch_chain_net_get_id(); // Channel id for global_db sync
res = dap_chain_node_client_send_chain_net_request(client, l_ch_id, res = dap_chain_node_client_send_chain_net_request(client, l_ch_id,
STREAM_CH_CHAIN_NET_PKT_TYPE_GLOBAL_DB_REQUEST_SYNC, l_data_send, l_data_send_len); //, NULL); STREAM_CH_CHAIN_NET_PKT_TYPE_GLOBAL_DB_REQUEST_SYNC, l_data_send, l_data_send_len); //, NULL);
DAP_DELETE(l_data_send); DAP_DELETE(l_data_send);
if(res != 1) { if(res != 1) {
dap_chain_node_cli_set_reply_text(str_reply, "no request sent"); dap_chain_node_cli_set_reply_text(str_reply, "no request sent");
...@@ -1074,7 +1081,8 @@ int com_traceroute(int argc, const char** argv, char **str_reply) ...@@ -1074,7 +1081,8 @@ int com_traceroute(int argc, const char** argv, char **str_reply)
iputils_set_verbose(); iputils_set_verbose();
int res = (addr) ? traceroute_util(addr, &hops, &time_usec) : -EADDRNOTAVAIL; int res = (addr) ? traceroute_util(addr, &hops, &time_usec) : -EADDRNOTAVAIL;
if(res >= 0) { if(res >= 0) {
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s hops=%d time=%.1lf ms", addr, hops, time_usec * 1. / 1000); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s hops=%d time=%.1lf ms", addr, hops,
time_usec * 1. / 1000);
} }
else { else {
if(str_reply) { if(str_reply) {
...@@ -1085,19 +1093,23 @@ int com_traceroute(int argc, const char** argv, char **str_reply) ...@@ -1085,19 +1093,23 @@ int com_traceroute(int argc, const char** argv, char **str_reply)
(addr) ? "Name or service not known" : "Host not defined"); (addr) ? "Name or service not known" : "Host not defined");
break; break;
case 2: case 2:
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "Unknown traceroute module"); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr,
"Unknown traceroute module");
break; break;
case 3: case 3:
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "first hop out of range"); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "first hop out of range");
break; break;
case 4: case 4:
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "max hops cannot be more than 255"); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr,
"max hops cannot be more than 255");
break; break;
case 5: case 5:
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "no more than 10 probes per hop"); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr,
"no more than 10 probes per hop");
break; break;
case 6: case 6:
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "bad wait specifications"); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr,
"bad wait specifications");
break; break;
case 7: case 7:
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "too big packetlen "); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "too big packetlen ");
...@@ -1119,10 +1131,12 @@ int com_traceroute(int argc, const char** argv, char **str_reply) ...@@ -1119,10 +1131,12 @@ int com_traceroute(int argc, const char** argv, char **str_reply)
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "parse cmdline"); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "parse cmdline");
break; break;
case 13: case 13:
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr, "trace method's init failed"); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error: %s", addr,
"trace method's init failed");
break; break;
default: default:
dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error(%d) %s", addr, res, "trace not found"); dap_chain_node_cli_set_reply_text(str_reply, "traceroute %s error(%d) %s", addr, res,
"trace not found");
} }
} }
} }
...@@ -1144,7 +1158,8 @@ int com_tracepath(int argc, const char** argv, char **str_reply) ...@@ -1144,7 +1158,8 @@ int com_tracepath(int argc, const char** argv, char **str_reply)
int res = (addr) ? tracepath_util(addr, &hops, &time_usec) : -EADDRNOTAVAIL; int res = (addr) ? tracepath_util(addr, &hops, &time_usec) : -EADDRNOTAVAIL;
if(res >= 0) { if(res >= 0) {
if(str_reply) if(str_reply)
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s hops=%d time=%.1lf ms", addr, hops, time_usec * 1. / 1000); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s hops=%d time=%.1lf ms", addr, hops,
time_usec * 1. / 1000);
} }
else { else {
if(str_reply) { if(str_reply) {
...@@ -1158,28 +1173,35 @@ int com_tracepath(int argc, const char** argv, char **str_reply) ...@@ -1158,28 +1173,35 @@ int com_tracepath(int argc, const char** argv, char **str_reply)
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't create socket"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't create socket");
break; break;
case 2: case 2:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IPV6_MTU_DISCOVER"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr,
"Can't setsockopt IPV6_MTU_DISCOVER");
break; break;
case 3: case 3:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IPV6_RECVERR"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr,
"Can't setsockopt IPV6_RECVERR");
break; break;
case 4: case 4:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IPV6_HOPLIMIT"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr,
"Can't setsockopt IPV6_HOPLIMIT");
break; break;
case 5: case 5:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IP_MTU_DISCOVER"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr,
"Can't setsockopt IP_MTU_DISCOVER");
break; break;
case 6: case 6:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IP_RECVERR"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr,
"Can't setsockopt IP_RECVERR");
break; break;
case 7: case 7:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IP_RECVTTL"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr,
"Can't setsockopt IP_RECVTTL");
break; break;
case 8: case 8:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "malloc"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "malloc");
break; break;
case 9: case 9:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IPV6_UNICAST_HOPS"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr,
"Can't setsockopt IPV6_UNICAST_HOPS");
break; break;
case 10: case 10:
dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IP_TTL"); dap_chain_node_cli_set_reply_text(str_reply, "tracepath %s error: %s", addr, "Can't setsockopt IP_TTL");
...@@ -1257,7 +1279,7 @@ int com_help(int argc, const char ** argv, char **str_reply) ...@@ -1257,7 +1279,7 @@ int com_help(int argc, const char ** argv, char **str_reply)
{ {
if(argc > 1) { if(argc > 1) {
dap_chain_node_cmd_item_t *l_cmd = dap_chain_node_cli_cmd_find(argv[1]); dap_chain_node_cmd_item_t *l_cmd = dap_chain_node_cli_cmd_find(argv[1]);
if(l_cmd){ if(l_cmd) {
dap_chain_node_cli_set_reply_text(str_reply, "%s:\n%s", l_cmd->doc, l_cmd->doc_ex); dap_chain_node_cli_set_reply_text(str_reply, "%s:\n%s", l_cmd->doc, l_cmd->doc_ex);
return 1; return 1;
} }
...@@ -1296,7 +1318,8 @@ int com_tx_wallet(int argc, const char ** argv, char **str_reply) ...@@ -1296,7 +1318,8 @@ int com_tx_wallet(int argc, const char ** argv, char **str_reply)
} }
arg_index++; arg_index++;
if(cmd_num == CMD_NONE) { if(cmd_num == CMD_NONE) {
dap_chain_node_cli_set_reply_text(str_reply, "format of command: wallet [list | info -addr <addr> -w <wallet_name>]"); dap_chain_node_cli_set_reply_text(str_reply,
"format of command: wallet [list | info -addr <addr> -w <wallet_name>]");
return -1; return -1;
} }
...@@ -1358,7 +1381,7 @@ int com_tx_wallet(int argc, const char ** argv, char **str_reply) ...@@ -1358,7 +1381,7 @@ int com_tx_wallet(int argc, const char ** argv, char **str_reply)
size_t l_addr_tokens_size = 0; size_t l_addr_tokens_size = 0;
char **l_addr_tokens = NULL; char **l_addr_tokens = NULL;
dap_chain_utxo_addr_get_token_ticker_all(l_addr, &l_addr_tokens, &l_addr_tokens_size); dap_chain_utxo_addr_get_token_ticker_all(l_addr, &l_addr_tokens, &l_addr_tokens_size);
if(l_addr_tokens_size>0) if(l_addr_tokens_size > 0)
dap_string_append_printf(l_string_ret, "balance:\n"); dap_string_append_printf(l_string_ret, "balance:\n");
else else
dap_string_append_printf(l_string_ret, "balance: 0\n"); dap_string_append_printf(l_string_ret, "balance: 0\n");
...@@ -1454,16 +1477,11 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply) ...@@ -1454,16 +1477,11 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply)
char * l_certs_str_dup = strdup(l_certs_str); char * l_certs_str_dup = strdup(l_certs_str);
char *l_cert_str = strtok_r(l_certs_str_dup, ",", &l_certs_tmp_ptrs); char *l_cert_str = strtok_r(l_certs_str_dup, ",", &l_certs_tmp_ptrs);
//debug //debug
{ /* {
const char * l_wallets_path = dap_config_get_item_str(g_config, "general", "wallets_path"); dap_chain_cert_t *l_cert1 = dap_chain_cert_generate("cert_b","/tmp/cert_b.dcert",DAP_ENC_KEY_TYPE_SIG_BLISS);
dap_chain_net_id_t a_net_id; dap_chain_cert_t *l_cert2 = dap_chain_cert_generate("cert_p","/tmp/cert_p.dcert",DAP_ENC_KEY_TYPE_SIG_PICNIC);
a_net_id.uint64 = 0x123; dap_chain_cert_t *l_cert3 = dap_chain_cert_generate("cert_t","/tmp/cert_t.dcert",DAP_ENC_KEY_TYPE_SIG_TESLA);
dap_chain_sign_type_t l_type; }*/
l_type.type = 0x0003;// SIG_TYPE_TESLA=0x0003
dap_chain_wallet_t *wallet1 = dap_chain_wallet_create("tesla_first", l_wallets_path, a_net_id, l_type);
dap_chain_wallet_t *wallet2 = dap_chain_wallet_create("tesla_second", l_wallets_path, a_net_id, l_type);
wallet1 = NULL;
}
// First we just calc items // First we just calc items
while(l_cert_str) { while(l_cert_str) {
...@@ -1532,7 +1550,7 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply) ...@@ -1532,7 +1550,7 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply)
, dap_config_get_item_str_default(g_config, "mempool", "gdb_group", "datum-pool"))) { , dap_config_get_item_str_default(g_config, "mempool", "gdb_group", "datum-pool"))) {
str_reply_tmp = dap_strdup_printf("datum emission %s is placed in datum pool ", l_key_str); str_reply_tmp = dap_strdup_printf("datum emission %s is placed in datum pool ", l_key_str);
} }
else{ else {
dap_chain_node_cli_set_reply_text(str_reply, "datum emission %s is not placed in datum pool ", l_key_str); dap_chain_node_cli_set_reply_text(str_reply, "datum emission %s is not placed in datum pool ", l_key_str);
return -1; return -1;
} }
...@@ -1553,8 +1571,13 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply) ...@@ -1553,8 +1571,13 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply)
dap_chain_datum_tx_add_item(&l_tx, (const uint8_t*) l_out); dap_chain_datum_tx_add_item(&l_tx, (const uint8_t*) l_out);
// Sign all that we have with certs // Sign all that we have with certs
for(size_t i = 0; i < l_certs_size; i++) for(size_t i = 0; i < l_certs_size; i++) {
dap_chain_datum_tx_add_sign_item(&l_tx, l_certs[i]->enc_key); if(dap_chain_datum_tx_add_sign_item(&l_tx, l_certs[i]->enc_key) < 0) {
dap_chain_node_cli_set_reply_text(str_reply, "No private key for certificate=%s",
l_certs[i]->name);
return -3;
}
}
DAP_DELETE(l_certs); DAP_DELETE(l_certs);
DAP_DELETE(l_tx_token); DAP_DELETE(l_tx_token);
...@@ -1568,18 +1591,21 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply) ...@@ -1568,18 +1591,21 @@ int com_token_emit(int argc, const char ** argv, char ** str_reply)
size_t l_datum_tx_size = dap_chain_datum_size(l_datum_tx); size_t l_datum_tx_size = dap_chain_datum_size(l_datum_tx);
// use l_tx hash for compatible with utho hash // use l_tx hash for compatible with utho hash
dap_hash_fast(l_tx, l_tx_size, &l_key_hash);//dap_hash_fast(l_datum_tx, l_datum_tx_size, &l_key_hash); dap_hash_fast(l_tx, l_tx_size, &l_key_hash); //dap_hash_fast(l_datum_tx, l_datum_tx_size, &l_key_hash);
l_key_str = dap_chain_hash_fast_to_str_new(&l_key_hash); l_key_str = dap_chain_hash_fast_to_str_new(&l_key_hash);
DAP_DELETE(l_tx); DAP_DELETE(l_tx);
// Add to mempool emission token // Add to mempool emission token
if(dap_chain_global_db_gr_set(l_key_str, (uint8_t *) l_datum_tx, l_datum_tx_size if(dap_chain_global_db_gr_set(l_key_str, (uint8_t *) l_datum_tx, l_datum_tx_size
, dap_config_get_item_str_default(g_config, "mempool", "gdb_group", "datum-pool"))) { , dap_config_get_item_str_default(g_config, "mempool", "gdb_group", "datum-pool"))) {
dap_chain_node_cli_set_reply_text(str_reply, "%s\ndatum tx %s is placed in datum pool ", str_reply_tmp, l_key_str); dap_chain_node_cli_set_reply_text(str_reply, "%s\ndatum tx %s is placed in datum pool ", str_reply_tmp,
dap_chain_utxo_tx_add((dap_chain_datum_tx_t*)l_datum_tx->data); l_key_str);
dap_chain_utxo_tx_add((dap_chain_datum_tx_t*) l_datum_tx->data);
} }
else{ else {
dap_chain_node_cli_set_reply_text(str_reply, "%s\ndatum tx %s is not placed in datum pool ", str_reply_tmp, l_key_str); dap_chain_node_cli_set_reply_text(str_reply, "%s\ndatum tx %s is not placed in datum pool ", str_reply_tmp,
l_key_str);
return -2; return -2;
} }
DAP_DELETE(str_reply_tmp); DAP_DELETE(str_reply_tmp);
...@@ -1601,28 +1627,35 @@ int com_tx_cond_create(int argc, const char ** argv, char **str_reply) ...@@ -1601,28 +1627,35 @@ int com_tx_cond_create(int argc, const char ** argv, char **str_reply)
const char *c_wallet_name_from = "w_tesla"; // where to take coins for service const char *c_wallet_name_from = "w_tesla"; // where to take coins for service
const char *c_wallet_name_cond = "w_picnic"; // who will be use service, usually the same address (addr_from) const char *c_wallet_name_cond = "w_picnic"; // who will be use service, usually the same address (addr_from)
uint64_t l_value = 50; uint64_t l_value = 50;
//debug
{
dap_chain_wallet_t * l_wallet_tesla = dap_chain_wallet_open("w_picnic", c_wallets_path);
const dap_chain_addr_t *l_addr_tesla = dap_chain_wallet_get_addr(l_wallet_tesla);
char *addr = dap_chain_addr_to_str(l_addr_tesla);
addr = 0;
}
dap_chain_wallet_t *l_wallet_from = dap_chain_wallet_open(c_wallet_name_from, c_wallets_path); dap_chain_wallet_t *l_wallet_from = dap_chain_wallet_open(c_wallet_name_from, c_wallets_path);
dap_enc_key_t *l_key = dap_chain_wallet_get_key(l_wallet_from, 0); dap_enc_key_t *l_key = dap_chain_wallet_get_key(l_wallet_from, 0);
dap_chain_wallet_t *l_wallet_cond = dap_chain_wallet_open(c_wallet_name_cond, c_wallets_path); dap_chain_wallet_t *l_wallet_cond = dap_chain_wallet_open(c_wallet_name_cond, c_wallets_path);
dap_enc_key_t *l_key_cond = dap_chain_wallet_get_key(l_wallet_from, 0); dap_enc_key_t *l_key_cond = dap_chain_wallet_get_key(l_wallet_cond, 0);
// where to take coins for service // where to take coins for service
const dap_chain_addr_t *addr_from = dap_chain_wallet_get_addr(l_wallet_from); const dap_chain_addr_t *addr_from = dap_chain_wallet_get_addr(l_wallet_from);
// who will be use service, usually the same address (addr_from) // who will be use service, usually the same address (addr_from)
const dap_chain_addr_t *addr_cond = dap_chain_wallet_get_addr(l_wallet_cond); const dap_chain_addr_t *addr_cond = dap_chain_wallet_get_addr(l_wallet_cond);
dap_chain_net_srv_abstract_t l_cond; dap_chain_net_srv_abstract_t l_cond;
l_cond.price = l_value; dap_chain_net_srv_abstract_set(&l_cond, SERV_CLASS_PERMANENT, SERV_ID_VPN, l_value, SERV_UNIT_MB,
"test vpn service");
int res = dap_chain_mempool_tx_create_cond(l_key, l_key_cond, addr_from, int res = dap_chain_mempool_tx_create_cond(l_key, l_key_cond, addr_from,
addr_cond, addr_cond,
NULL, l_token_ticker, l_value, 0, (const void*) &l_cond, sizeof(dap_chain_net_srv_abstract_t)); NULL, l_token_ticker, l_value, 0, (const void*) &l_cond, sizeof(dap_chain_net_srv_abstract_t));
dap_chain_wallet_close(l_wallet_from); dap_chain_wallet_close(l_wallet_from);
dap_chain_wallet_close(l_wallet_cond); dap_chain_wallet_close(l_wallet_cond);
dap_chain_node_cli_set_reply_text(str_reply, "tx_cond_create res=%d", res); dap_chain_node_cli_set_reply_text(str_reply, "cond create=%s\n",
if(res == 1) (res == 0) ? "Ok" : (res == -2) ? "False, not enough funds for service fee" : "False");
return 0; return res;
return -1;
} }
/** /**
...@@ -1678,13 +1711,6 @@ int com_tx_create(int argc, const char ** argv, char **str_reply) ...@@ -1678,13 +1711,6 @@ int com_tx_create(int argc, const char ** argv, char **str_reply)
dap_chain_node_cli_set_reply_text(str_reply, "wallet %s does not exist", l_from_wallet_name); dap_chain_node_cli_set_reply_text(str_reply, "wallet %s does not exist", l_from_wallet_name);
return -1; return -1;
} }
/* //debug
{
dap_chain_wallet_t * l_wallet_tesla = dap_chain_wallet_open("w_tesla", c_wallets_path);
const dap_chain_addr_t *l_addr_tesla = dap_chain_wallet_get_addr(l_wallet_tesla);
char *addr = dap_chain_addr_to_str(l_addr_tesla);
addr = 0;
}*/
const dap_chain_addr_t *addr_from = (const dap_chain_addr_t *) dap_chain_wallet_get_addr(l_wallet); const dap_chain_addr_t *addr_from = (const dap_chain_addr_t *) dap_chain_wallet_get_addr(l_wallet);
dap_chain_addr_t *addr_to = dap_chain_str_to_addr(addr_base58_to); dap_chain_addr_t *addr_to = dap_chain_str_to_addr(addr_base58_to);
dap_chain_addr_t *addr_fee = dap_chain_str_to_addr(addr_base58_fee); dap_chain_addr_t *addr_fee = dap_chain_str_to_addr(addr_base58_fee);
...@@ -1708,7 +1734,8 @@ int com_tx_create(int argc, const char ** argv, char **str_reply) ...@@ -1708,7 +1734,8 @@ int com_tx_create(int argc, const char ** argv, char **str_reply)
int res = dap_chain_mempool_tx_create(dap_chain_wallet_get_key(l_wallet, 0), addr_from, addr_to, addr_fee, int res = dap_chain_mempool_tx_create(dap_chain_wallet_get_key(l_wallet, 0), addr_from, addr_to, addr_fee,
l_token_ticker, value, value_fee); l_token_ticker, value, value_fee);
dap_string_append_printf(string_ret, "transfer=%s\n", (res == 0) ? "Ok" : (res==-2)? "False, not enough funds for transfer" : "False"); dap_string_append_printf(string_ret, "transfer=%s\n",
(res == 0) ? "Ok" : (res == -2) ? "False, not enough funds for transfer" : "False");
char *str_ret_tmp = dap_string_free(string_ret, false); char *str_ret_tmp = dap_string_free(string_ret, false);
char *str_ret = strdup(str_ret_tmp); char *str_ret = strdup(str_ret_tmp);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment