Skip to content
Snippets Groups Projects
Commit 47e99396 authored by Constantin P.'s avatar Constantin P. 💬
Browse files

Merge branch 'hotfix-15065' into 'master'

hotfix-15065

See merge request !2069
parents 7f40888c 2d905af6
No related branches found
No related tags found
1 merge request!2069hotfix-15065
Pipeline #51124 failed with stage
in 13 minutes and 52 seconds
...@@ -617,18 +617,20 @@ void dap_chain_net_srv_order_dump_to_json(const dap_chain_net_srv_order_t *a_ord ...@@ -617,18 +617,20 @@ void dap_chain_net_srv_order_dump_to_json(const dap_chain_net_srv_order_t *a_ord
DAP_DELETE(l_region); DAP_DELETE(l_region);
l_hash_str = dap_strcmp(a_hash_out_type, "hex") if (!dap_hash_fast_is_blank(&a_order->tx_cond_hash)){
l_hash_str = dap_strcmp(a_hash_out_type, "hex")
? dap_enc_base58_encode_hash_to_str_static(&a_order->tx_cond_hash) ? dap_enc_base58_encode_hash_to_str_static(&a_order->tx_cond_hash)
: dap_chain_hash_fast_to_str_static(&a_order->tx_cond_hash); : dap_chain_hash_fast_to_str_static(&a_order->tx_cond_hash);
json_object_object_add(a_json_obj_out, "tx_cond_hash", json_object_new_string(l_hash_str)); json_object_object_add(a_json_obj_out, "tx_cond_hash", json_object_new_string(l_hash_str));
if (a_order->ext_size) { }
char *l_ext_out = DAP_NEW_Z_SIZE(char, a_order->ext_size * 2 + 3); json_object_object_add(a_json_obj_out, "ext_size", json_object_new_uint64(a_order->ext_size));
dap_strncpy(l_ext_out, "0x", 2); // if (a_order->ext_size) {
dap_bin2hex(l_ext_out + 2, a_order->ext_n_sign, a_order->ext_size); // char *l_ext_out = DAP_NEW_Z_SIZE(char, a_order->ext_size * 2 + 3);
json_object_object_add(a_json_obj_out, "ext", json_object_new_string(l_ext_out)); // dap_strncpy(l_ext_out, "0x", 2);
DAP_DELETE(l_ext_out); // dap_bin2hex(l_ext_out + 2, a_order->ext_n_sign, a_order->ext_size);
} else //
json_object_object_add(a_json_obj_out, "ext", json_object_new_string("0x0")); // DAP_DELETE(l_ext_out);
// }
dap_sign_t *l_sign = (dap_sign_t*)((byte_t*)a_order->ext_n_sign + a_order->ext_size); dap_sign_t *l_sign = (dap_sign_t*)((byte_t*)a_order->ext_n_sign + a_order->ext_size);
dap_hash_fast_t l_sign_pkey = {0}; dap_hash_fast_t l_sign_pkey = {0};
dap_sign_get_pkey_hash(l_sign, &l_sign_pkey); dap_sign_get_pkey_hash(l_sign, &l_sign_pkey);
......
...@@ -81,6 +81,8 @@ static const mode_t s_fileprot = ( S_IREAD | S_IWRITE) | (S_IREAD >> 3) | (S_IR ...@@ -81,6 +81,8 @@ static const mode_t s_fileprot = ( S_IREAD | S_IWRITE) | (S_IREAD >> 3) | (S_IR
#endif #endif
static char const s_wallet_ext [] = ".dwallet", *s_wallets_path = NULL; static char const s_wallet_ext [] = ".dwallet", *s_wallets_path = NULL;
static bool s_debug_more = false;
static pthread_rwlock_t s_wallet_n_pass_lock = PTHREAD_RWLOCK_INITIALIZER; /* Coordinate access to the hash-table */ static pthread_rwlock_t s_wallet_n_pass_lock = PTHREAD_RWLOCK_INITIALIZER; /* Coordinate access to the hash-table */
static dap_chain_wallet_n_pass_t *s_wallet_n_pass; /* A hash table to keep passwords for wallets */ static dap_chain_wallet_n_pass_t *s_wallet_n_pass; /* A hash table to keep passwords for wallets */
static dap_list_t *s_wallet_open_notificators = NULL; static dap_list_t *s_wallet_open_notificators = NULL;
...@@ -356,6 +358,8 @@ int dap_chain_wallet_init() ...@@ -356,6 +358,8 @@ int dap_chain_wallet_init()
dap_chain_wallet_t *l_wallet = NULL; dap_chain_wallet_t *l_wallet = NULL;
size_t l_len = 0; size_t l_len = 0;
s_debug_more = dap_config_get_item_bool_default(g_config,"wallet","debug_more", s_debug_more);
if ( !(c_wallets_path = (char *) dap_chain_wallet_get_path(g_config)) ) /* No path to wallets - nothing to do */ if ( !(c_wallets_path = (char *) dap_chain_wallet_get_path(g_config)) ) /* No path to wallets - nothing to do */
return -1; return -1;
...@@ -819,7 +823,7 @@ uint32_t l_csum = CRC32C_INIT, l_csum2 = CRC32C_INIT; ...@@ -819,7 +823,7 @@ uint32_t l_csum = CRC32C_INIT, l_csum2 = CRC32C_INIT;
} }
if ( (l_file_hdr.version == DAP_WALLET$K_VER_2) && (!l_pass) ) { if ( (l_file_hdr.version == DAP_WALLET$K_VER_2) && (!l_pass) ) {
log_it(L_DEBUG, "Wallet (%s) version 2 cannot be processed w/o password", a_file_name); debug_if(s_debug_more, L_DEBUG, "Wallet (%s) version 2 cannot be processed w/o password", a_file_name);
dap_fileclose(l_fh); dap_fileclose(l_fh);
if ( a_out_stat ) if ( a_out_stat )
*a_out_stat = 4; *a_out_stat = 4;
...@@ -850,7 +854,7 @@ uint32_t l_csum = CRC32C_INIT, l_csum2 = CRC32C_INIT; ...@@ -850,7 +854,7 @@ uint32_t l_csum = CRC32C_INIT, l_csum2 = CRC32C_INIT;
l_csum = crc32c(l_csum, &l_file_hdr, sizeof(l_file_hdr) ); /* Compute check sum of the Wallet file header */ l_csum = crc32c(l_csum, &l_file_hdr, sizeof(l_file_hdr) ); /* Compute check sum of the Wallet file header */
l_csum = crc32c(l_csum, l_wallet_name, l_file_hdr.wallet_len); l_csum = crc32c(l_csum, l_wallet_name, l_file_hdr.wallet_len);
log_it(L_DEBUG, "Wallet file: %s, Wallet[Version: %d, type: %d, name: '%.*s']", debug_if(s_debug_more, L_DEBUG, "Wallet file: %s, Wallet[Version: %d, type: %d, name: '%.*s']",
a_file_name, l_file_hdr.version, l_file_hdr.type, l_file_hdr.wallet_len, l_wallet_name); a_file_name, l_file_hdr.version, l_file_hdr.type, l_file_hdr.wallet_len, l_wallet_name);
/* First run - count certs in file */ /* First run - count certs in file */
......
...@@ -111,6 +111,7 @@ typedef struct dap_atom_notify_arg { ...@@ -111,6 +111,7 @@ typedef struct dap_atom_notify_arg {
static dap_s_wallets_cache_type_t s_wallets_cache_type = DAP_WALLET_CACHE_TYPE_LOCAL; static dap_s_wallets_cache_type_t s_wallets_cache_type = DAP_WALLET_CACHE_TYPE_LOCAL;
static dap_wallet_cache_t *s_wallets_cache = NULL; static dap_wallet_cache_t *s_wallets_cache = NULL;
static pthread_rwlock_t s_wallet_cache_rwlock; static pthread_rwlock_t s_wallet_cache_rwlock;
static bool s_debug_more = false;
static int s_save_tx_cache_for_addr(dap_chain_t *a_chain, dap_chain_addr_t *a_addr, dap_chain_datum_tx_t *a_tx, static int s_save_tx_cache_for_addr(dap_chain_t *a_chain, dap_chain_addr_t *a_addr, dap_chain_datum_tx_t *a_tx,
dap_hash_fast_t *a_tx_hash, dap_hash_fast_t *a_atom_hash, int a_ret_code, char* a_main_token_ticker, dap_hash_fast_t *a_tx_hash, dap_hash_fast_t *a_atom_hash, int a_ret_code, char* a_main_token_ticker,
...@@ -151,8 +152,10 @@ int dap_chain_wallet_cache_init() ...@@ -151,8 +152,10 @@ int dap_chain_wallet_cache_init()
} }
} }
s_debug_more = dap_config_get_item_bool_default(g_config,"wallet","debug_more", s_debug_more);
if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){ if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){
log_it( L_WARNING, "Wallet cache is disabled."); debug_if(s_debug_more, L_DEBUG, "Wallet cache is disabled.");
return 0; return 0;
} }
...@@ -191,7 +194,7 @@ int dap_chain_wallet_cache_init() ...@@ -191,7 +194,7 @@ int dap_chain_wallet_cache_init()
l_wallet_item = DAP_NEW_Z(dap_wallet_cache_t); l_wallet_item = DAP_NEW_Z(dap_wallet_cache_t);
memcpy (&l_wallet_item->wallet_addr, l_addr, sizeof(dap_chain_addr_t)); memcpy (&l_wallet_item->wallet_addr, l_addr, sizeof(dap_chain_addr_t));
HASH_ADD(hh, s_wallets_cache, wallet_addr, sizeof(dap_chain_addr_t), l_wallet_item); HASH_ADD(hh, s_wallets_cache, wallet_addr, sizeof(dap_chain_addr_t), l_wallet_item);
log_it(L_DEBUG, "Wallet %s saved.", dap_chain_addr_to_str_static(l_addr)); debug_if(s_debug_more, L_DEBUG, "Wallet %s saved.", dap_chain_addr_to_str_static(l_addr));
} }
} }
pthread_rwlock_unlock(&s_wallet_cache_rwlock); pthread_rwlock_unlock(&s_wallet_cache_rwlock);
...@@ -213,13 +216,14 @@ int dap_chain_wallet_cache_tx_find(dap_chain_addr_t *a_addr, char *a_token, dap_ ...@@ -213,13 +216,14 @@ int dap_chain_wallet_cache_tx_find(dap_chain_addr_t *a_addr, char *a_token, dap_
dap_wallet_cache_t *l_wallet_item = NULL; dap_wallet_cache_t *l_wallet_item = NULL;
if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){ if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){
debug_if(s_debug_more, L_DEBUG, "Wallet cache is disabled.");
return -101; return -101;
} }
pthread_rwlock_rdlock(&s_wallet_cache_rwlock); pthread_rwlock_rdlock(&s_wallet_cache_rwlock);
HASH_FIND(hh, s_wallets_cache, a_addr, sizeof(dap_chain_addr_t), l_wallet_item); HASH_FIND(hh, s_wallets_cache, a_addr, sizeof(dap_chain_addr_t), l_wallet_item);
if (!l_wallet_item || l_wallet_item->is_loading){ if (!l_wallet_item || l_wallet_item->is_loading){
log_it(L_ERROR, "Can't find wallet with address %s", dap_chain_addr_to_str_static(a_addr)); log_it(L_INFO, "Can't find wallet with address %s", dap_chain_addr_to_str_static(a_addr));
pthread_rwlock_unlock(&s_wallet_cache_rwlock); pthread_rwlock_unlock(&s_wallet_cache_rwlock);
return -101; return -101;
} }
...@@ -228,7 +232,7 @@ int dap_chain_wallet_cache_tx_find(dap_chain_addr_t *a_addr, char *a_token, dap_ ...@@ -228,7 +232,7 @@ int dap_chain_wallet_cache_tx_find(dap_chain_addr_t *a_addr, char *a_token, dap_
// find start transaction // find start transaction
HASH_FIND(hh, l_wallet_item->wallet_txs, a_tx_hash_curr, sizeof(dap_chain_hash_fast_t), l_current_wallet_tx); HASH_FIND(hh, l_wallet_item->wallet_txs, a_tx_hash_curr, sizeof(dap_chain_hash_fast_t), l_current_wallet_tx);
if (!l_current_wallet_tx){ if (!l_current_wallet_tx){
log_it(L_ERROR, "Can't find tx %s for address %s", dap_hash_fast_to_str_static(a_tx_hash_curr), dap_chain_addr_to_str_static(a_addr)); debug_if(s_debug_more, L_DEBUG, "Can't find tx %s for address %s", dap_hash_fast_to_str_static(a_tx_hash_curr), dap_chain_addr_to_str_static(a_addr));
pthread_rwlock_unlock(&s_wallet_cache_rwlock); pthread_rwlock_unlock(&s_wallet_cache_rwlock);
return 0; return 0;
} }
...@@ -298,6 +302,7 @@ int dap_chain_wallet_cache_tx_find_in_history(dap_chain_addr_t *a_addr, char **a ...@@ -298,6 +302,7 @@ int dap_chain_wallet_cache_tx_find_in_history(dap_chain_addr_t *a_addr, char **a
dap_wallet_cache_t *l_wallet_item = NULL; dap_wallet_cache_t *l_wallet_item = NULL;
if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){ if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){
debug_if(s_debug_more, L_DEBUG, "Wallet cache is disabled.");
return -101; return -101;
} }
...@@ -307,7 +312,7 @@ int dap_chain_wallet_cache_tx_find_in_history(dap_chain_addr_t *a_addr, char **a ...@@ -307,7 +312,7 @@ int dap_chain_wallet_cache_tx_find_in_history(dap_chain_addr_t *a_addr, char **a
pthread_rwlock_rdlock(&s_wallet_cache_rwlock); pthread_rwlock_rdlock(&s_wallet_cache_rwlock);
HASH_FIND(hh, s_wallets_cache, a_addr, sizeof(dap_chain_addr_t), l_wallet_item); HASH_FIND(hh, s_wallets_cache, a_addr, sizeof(dap_chain_addr_t), l_wallet_item);
if (!l_wallet_item || l_wallet_item->is_loading){ if (!l_wallet_item || l_wallet_item->is_loading){
log_it(L_ERROR, "Can't find wallet with address %s", dap_chain_addr_to_str_static(a_addr)); debug_if(s_debug_more, L_DEBUG, "Can't find wallet with address %s", dap_chain_addr_to_str_static(a_addr));
pthread_rwlock_unlock(&s_wallet_cache_rwlock); pthread_rwlock_unlock(&s_wallet_cache_rwlock);
return -101; return -101;
} }
...@@ -389,7 +394,7 @@ int dap_chain_wallet_cache_tx_find_outs(dap_chain_net_t *a_net, const char *a_to ...@@ -389,7 +394,7 @@ int dap_chain_wallet_cache_tx_find_outs(dap_chain_net_t *a_net, const char *a_to
pthread_rwlock_rdlock(&s_wallet_cache_rwlock); pthread_rwlock_rdlock(&s_wallet_cache_rwlock);
HASH_FIND(hh, s_wallets_cache, a_addr, sizeof(dap_chain_addr_t), l_wallet_item); HASH_FIND(hh, s_wallets_cache, a_addr, sizeof(dap_chain_addr_t), l_wallet_item);
if (!l_wallet_item|| l_wallet_item->is_loading){ if (!l_wallet_item|| l_wallet_item->is_loading){
log_it(L_ERROR, "Can't find wallet with address %s", dap_chain_addr_to_str_static(a_addr)); debug_if(s_debug_more, L_DEBUG, "Can't find wallet with address %s", dap_chain_addr_to_str_static(a_addr));
pthread_rwlock_unlock(&s_wallet_cache_rwlock); pthread_rwlock_unlock(&s_wallet_cache_rwlock);
return -101; return -101;
} }
...@@ -452,6 +457,7 @@ int dap_chain_wallet_cache_tx_find_outs_with_val(dap_chain_net_t *a_net, const c ...@@ -452,6 +457,7 @@ int dap_chain_wallet_cache_tx_find_outs_with_val(dap_chain_net_t *a_net, const c
dap_chain_datum_tx_t *l_tx; dap_chain_datum_tx_t *l_tx;
if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){ if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){
debug_if(s_debug_more, L_DEBUG, "Wallet cache is disabled.");
return -101; return -101;
} }
...@@ -479,7 +485,7 @@ int dap_chain_wallet_cache_tx_find_outs_with_val(dap_chain_net_t *a_net, const c ...@@ -479,7 +485,7 @@ int dap_chain_wallet_cache_tx_find_outs_with_val(dap_chain_net_t *a_net, const c
pthread_rwlock_rdlock(&s_wallet_cache_rwlock); pthread_rwlock_rdlock(&s_wallet_cache_rwlock);
HASH_FIND(hh, s_wallets_cache, a_addr, sizeof(dap_chain_addr_t), l_wallet_item); HASH_FIND(hh, s_wallets_cache, a_addr, sizeof(dap_chain_addr_t), l_wallet_item);
if (!l_wallet_item || l_wallet_item->is_loading){ if (!l_wallet_item || l_wallet_item->is_loading){
log_it(L_ERROR, "Can't find wallet with address %s", dap_chain_addr_to_str_static(a_addr)); debug_if(s_debug_more, L_DEBUG, "Can't find wallet with address %s", dap_chain_addr_to_str_static(a_addr));
pthread_rwlock_unlock(&s_wallet_cache_rwlock); pthread_rwlock_unlock(&s_wallet_cache_rwlock);
return -101; return -101;
} }
......
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