diff --git a/modules/net/srv/dap_chain_net_srv_order.c b/modules/net/srv/dap_chain_net_srv_order.c index aaccef0c4fe43196416a0a11a530a4b62a152145..66ff78bd4a47a2e9150c7e9fdfd646af4d003c5b 100644 --- a/modules/net/srv/dap_chain_net_srv_order.c +++ b/modules/net/srv/dap_chain_net_srv_order.c @@ -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); - 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_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)); - if (a_order->ext_size) { - char *l_ext_out = DAP_NEW_Z_SIZE(char, a_order->ext_size * 2 + 3); - dap_strncpy(l_ext_out, "0x", 2); - dap_bin2hex(l_ext_out + 2, a_order->ext_n_sign, a_order->ext_size); - json_object_object_add(a_json_obj_out, "ext", json_object_new_string(l_ext_out)); - DAP_DELETE(l_ext_out); - } else - json_object_object_add(a_json_obj_out, "ext", json_object_new_string("0x0")); + : 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, "ext_size", json_object_new_uint64(a_order->ext_size)); + // if (a_order->ext_size) { + // char *l_ext_out = DAP_NEW_Z_SIZE(char, a_order->ext_size * 2 + 3); + // dap_strncpy(l_ext_out, "0x", 2); + // dap_bin2hex(l_ext_out + 2, a_order->ext_n_sign, a_order->ext_size); + // + // 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_hash_fast_t l_sign_pkey = {0}; dap_sign_get_pkey_hash(l_sign, &l_sign_pkey); diff --git a/modules/wallet/dap_chain_wallet.c b/modules/wallet/dap_chain_wallet.c index 8851d31c0f5c1433a50d31e8ad378a0452dc2aef..9072beaf610110c70611043e203bb0d9b8977b24 100644 --- a/modules/wallet/dap_chain_wallet.c +++ b/modules/wallet/dap_chain_wallet.c @@ -81,6 +81,8 @@ static const mode_t s_fileprot = ( S_IREAD | S_IWRITE) | (S_IREAD >> 3) | (S_IR #endif 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 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; @@ -356,6 +358,8 @@ int dap_chain_wallet_init() dap_chain_wallet_t *l_wallet = NULL; 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 */ return -1; @@ -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) ) { - 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); if ( a_out_stat ) *a_out_stat = 4; @@ -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_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); /* First run - count certs in file */ diff --git a/modules/wallet/dap_chain_wallet_cache.c b/modules/wallet/dap_chain_wallet_cache.c index 789cba9e96b25e38e45ebb0ce7bf207123ad5aa7..7dbc8737d154e9b5e3bad4d6687ce7f8758d8f7c 100644 --- a/modules/wallet/dap_chain_wallet_cache.c +++ b/modules/wallet/dap_chain_wallet_cache.c @@ -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_wallet_cache_t *s_wallets_cache = NULL; 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, 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() } } + 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){ - log_it( L_WARNING, "Wallet cache is disabled."); + debug_if(s_debug_more, L_DEBUG, "Wallet cache is disabled."); return 0; } @@ -191,7 +194,7 @@ int dap_chain_wallet_cache_init() l_wallet_item = DAP_NEW_Z(dap_wallet_cache_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); - 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); @@ -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; if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){ + debug_if(s_debug_more, L_DEBUG, "Wallet cache is disabled."); return -101; } pthread_rwlock_rdlock(&s_wallet_cache_rwlock); 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){ - 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); return -101; } @@ -228,7 +232,7 @@ int dap_chain_wallet_cache_tx_find(dap_chain_addr_t *a_addr, char *a_token, dap_ // 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); 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); return 0; } @@ -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; if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){ + debug_if(s_debug_more, L_DEBUG, "Wallet cache is disabled."); return -101; } @@ -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); 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){ - 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); return -101; } @@ -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); 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){ - 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); return -101; } @@ -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; if (s_wallets_cache_type == DAP_WALLET_CACHE_TYPE_DISABLED){ + debug_if(s_debug_more, L_DEBUG, "Wallet cache is disabled."); return -101; } @@ -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); 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){ - 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); return -101; }