diff --git a/modules/chain/dap_chain_ledger.c b/modules/chain/dap_chain_ledger.c index af718cfa099ec5072fea50bbb884a70de83e673d..31c96901aa2315b07341d6a2eeef7f1077b51ab7 100644 --- a/modules/chain/dap_chain_ledger.c +++ b/modules/chain/dap_chain_ledger.c @@ -235,7 +235,7 @@ typedef struct dap_chain_ledger_tx_bound { dap_chain_tx_in_t *tx_cur_in; dap_chain_tx_in_cond_t *tx_cur_in_cond; dap_chain_tx_in_ems_t *tx_cur_in_ems; - } in; + } in; union { dap_chain_tx_out_old_t *tx_prev_out; // 256 @@ -2290,7 +2290,7 @@ static void s_load_cache_gdb_loaded_spent_txs_callback(dap_global_db_context_t * return; } dap_chain_hash_fast_from_str(a_values[i].key, &l_tx_spent_item->tx_hash_fast); - l_tx_spent_item->cache_data = *(typeof(((dap_chain_ledger_tx_spent_item_t*)0)->cache_data)*)a_values[i].value; + l_tx_spent_item->cache_data = *(typeof(l_tx_spent_item->cache_data)*)a_values[i].value; HASH_ADD(hh, l_ledger_pvt->spent_items, tx_hash_fast, sizeof(dap_chain_hash_fast_t), l_tx_spent_item); } @@ -3371,7 +3371,7 @@ dap_hash_fast_t *dap_chain_ledger_get_final_chain_tx_hash(dap_ledger_t *a_ledger /** * Check whether used 'out' items (local function) */ -static bool s_ledger_tx_hash_is_used_out_item(dap_chain_ledger_tx_item_t *a_item, int a_idx_out) +static bool s_ledger_tx_hash_is_used_out_item(dap_chain_ledger_tx_item_t *a_item, int a_idx_out, dap_hash_fast_t *a_out_spender_hash) { if (!a_item || !a_item->cache_data.n_outs) { //log_it(L_DEBUG, "list_cached_item is NULL"); @@ -3383,10 +3383,10 @@ static bool s_ledger_tx_hash_is_used_out_item(dap_chain_ledger_tx_item_t *a_item } assert(a_idx_out < MAX_OUT_ITEMS); // if there are used 'out' items - if(a_item->cache_data.n_outs_used > 0) { - dap_hash_fast_t *l_hash_used = &(a_item->cache_data.tx_hash_spent_fast[a_idx_out]); - if(!dap_hash_fast_is_blank(l_hash_used)) - return true; + if ((a_item->cache_data.n_outs_used > 0) && !dap_hash_fast_is_blank(&(a_item->cache_data.tx_hash_spent_fast[a_idx_out]))) { + if (a_out_spender_hash) + *a_out_spender_hash = a_item->cache_data.tx_hash_spent_fast[a_idx_out]; + return true; } return false; } @@ -3591,7 +3591,7 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t log_it(L_ERROR, "Memory allocation error in %s, line %d", __PRETTY_FUNCTION__, __LINE__); if ( l_list_bound_items ) dap_list_free_full(l_list_bound_items, NULL); - if (l_list_tx_out) + if (l_list_tx_out) dap_list_free(l_list_tx_out); HASH_ITER(hh, l_values_from_prev_tx, l_value_cur, l_tmp) { HASH_DEL(l_values_from_prev_tx, l_value_cur); @@ -3817,8 +3817,12 @@ int dap_chain_ledger_tx_cache_check(dap_ledger_t *a_ledger, dap_chain_datum_tx_t // 2. Check if out in previous transaction has spent int l_idx = (l_cond_type == TX_ITEM_TYPE_IN) ? l_tx_in->header.tx_out_prev_idx : l_tx_in_cond->header.tx_out_prev_idx; - if (s_ledger_tx_hash_is_used_out_item(l_item_out, l_idx)) { + dap_hash_fast_t l_spender; + if (s_ledger_tx_hash_is_used_out_item(l_item_out, l_idx, &l_spender)) { l_err_num = DAP_CHAIN_LEDGER_TX_CACHE_CHECK_OUT_ITEM_ALREADY_USED; + char l_hash[DAP_CHAIN_HASH_FAST_STR_SIZE]; + dap_chain_hash_fast_to_str(&l_spender, l_hash, sizeof(l_hash)); + debug_if(s_debug_more, L_INFO, "'Out' item of previous tx %s already spent by %s", l_tx_prev_hash_str, l_hash); break; } @@ -4561,7 +4565,7 @@ static inline int s_tx_add(dap_ledger_t *a_ledger, dap_chain_datum_tx_t *a_tx, d size_t l_tx_size = dap_chain_datum_tx_get_size(l_prev_item_out->tx); size_t l_tx_cache_sz = l_tx_size + sizeof(l_prev_item_out->cache_data); uint8_t *l_tx_cache = DAP_NEW_Z_SIZE(uint8_t, l_tx_cache_sz); - memcpy(l_tx_cache, &l_prev_item_out->cache_data, sizeof(l_prev_item_out->cache_data)); + *(typeof(l_prev_item_out->cache_data)*)l_tx_cache = l_prev_item_out->cache_data; memcpy(l_tx_cache + sizeof(l_prev_item_out->cache_data), l_prev_item_out->tx, l_tx_size); char *l_tx_i_hash = dap_chain_hash_fast_to_str_new(&l_prev_item_out->tx_hash_fast); l_cache_used_outs[i] = (dap_store_obj_t) { @@ -5075,12 +5079,12 @@ size_t dap_chain_ledger_count_tps(dap_ledger_t *a_ledger, struct timespec *a_ts_ /** * Check whether used 'out' items */ -bool dap_chain_ledger_tx_hash_is_used_out_item(dap_ledger_t *a_ledger, dap_chain_hash_fast_t *a_tx_hash, int a_idx_out) +bool dap_chain_ledger_tx_hash_is_used_out_item(dap_ledger_t *a_ledger, dap_chain_hash_fast_t *a_tx_hash, int a_idx_out, dap_hash_fast_t *a_out_spender) { dap_chain_ledger_tx_item_t *l_item_out = NULL; //dap_chain_datum_tx_t *l_tx = s_find_datum_tx_by_hash(a_ledger, a_tx_hash, &l_item_out); - return s_ledger_tx_hash_is_used_out_item(l_item_out, a_idx_out); + return s_ledger_tx_hash_is_used_out_item(l_item_out, a_idx_out, a_out_spender); } /** @@ -5159,7 +5163,7 @@ uint256_t dap_chain_ledger_calc_balance_full(dap_ledger_t *a_ledger, const dap_c { // if transaction has the out item with requested addr if (!memcmp(a_addr, &l_tx_out->addr, sizeof(dap_chain_addr_t))) { // if 'out' item not used & transaction is valid - if(!s_ledger_tx_hash_is_used_out_item(l_iter_current, l_out_idx_tmp) && + if(!s_ledger_tx_hash_is_used_out_item(l_iter_current, l_out_idx_tmp, NULL) && dap_chain_datum_tx_verify_sign(l_cur_tx)) { // uint128_t l_add = dap_chain_uint128_from(l_tx_out->header.value); // balance = dap_uint128_add(balance, l_add); @@ -5177,7 +5181,7 @@ uint256_t dap_chain_ledger_calc_balance_full(dap_ledger_t *a_ledger, const dap_c { // if transaction has the out item with requested addr if (!memcmp(a_addr, &l_tx_out->addr, sizeof(dap_chain_addr_t))) { // if 'out' item not used & transaction is valid - if(!s_ledger_tx_hash_is_used_out_item(l_iter_current, l_out_idx_tmp) && + if(!s_ledger_tx_hash_is_used_out_item(l_iter_current, l_out_idx_tmp, NULL) && dap_chain_datum_tx_verify_sign(l_cur_tx)) { SUM_256_256(balance, l_tx_out->header.value, &balance); } @@ -5192,7 +5196,7 @@ uint256_t dap_chain_ledger_calc_balance_full(dap_ledger_t *a_ledger, const dap_c { // if transaction has the out item with requested addr if (!memcmp(a_addr, &l_tx_out->addr, sizeof(dap_chain_addr_t))) { // if 'out' item not used & transaction is valid - if(!s_ledger_tx_hash_is_used_out_item(l_iter_current, l_out_idx_tmp) && + if(!s_ledger_tx_hash_is_used_out_item(l_iter_current, l_out_idx_tmp, NULL) && dap_chain_datum_tx_verify_sign(l_cur_tx)) { SUM_256_256(balance, l_tx_out->header.value, &balance); } @@ -5524,7 +5528,7 @@ dap_list_t *dap_chain_ledger_get_list_tx_outs_with_val(dap_ledger_t *a_ledger, c continue; } // Check whether used 'out' items - if (!dap_chain_ledger_tx_hash_is_used_out_item (a_ledger, &l_tx_cur_hash, l_out_idx_tmp)) { + if (!dap_chain_ledger_tx_hash_is_used_out_item (a_ledger, &l_tx_cur_hash, l_out_idx_tmp, NULL)) { dap_chain_tx_used_out_item_t *l_item = DAP_NEW_Z(dap_chain_tx_used_out_item_t); if ( !l_item ) { if (l_list_used_out) @@ -5573,7 +5577,7 @@ int dap_chain_ledger_verificator_add(dap_chain_tx_out_cond_subtype_t a_subtype, l_new_verificator = DAP_NEW(dap_chain_ledger_verificator_t); if ( !l_new_verificator ) { log_it(L_ERROR, "Memory allocation error in %s, line %d", __PRETTY_FUNCTION__, __LINE__); - return -1; + return -1; } l_new_verificator->subtype = (int)a_subtype; l_new_verificator->callback = a_callback; diff --git a/modules/chain/include/dap_chain_ledger.h b/modules/chain/include/dap_chain_ledger.h index 54426f5ad4f036bc13b194ba16a8f85891d674ac..1237447ab25ea09d679a8c8c259d77e73dd82842 100644 --- a/modules/chain/include/dap_chain_ledger.h +++ b/modules/chain/include/dap_chain_ledger.h @@ -290,7 +290,7 @@ void dap_chain_ledger_set_tps_start_time(dap_ledger_t *a_ledger); /** * Check whether used 'out' items */ -bool dap_chain_ledger_tx_hash_is_used_out_item(dap_ledger_t *a_ledger, dap_chain_hash_fast_t *a_tx_hash, int a_idx_out); +bool dap_chain_ledger_tx_hash_is_used_out_item(dap_ledger_t *a_ledger, dap_chain_hash_fast_t *a_tx_hash, int a_idx_out, dap_hash_fast_t *a_out_spender); /** * Calculate balance of addr diff --git a/modules/net/dap_chain_net_tx.c b/modules/net/dap_chain_net_tx.c index da3e6beef32bdc331233aa4705b8192c906f6f92..e88bb9ba56dd71cce3fc6d4e64d192135244ff07 100644 --- a/modules/net/dap_chain_net_tx.c +++ b/modules/net/dap_chain_net_tx.c @@ -636,7 +636,7 @@ dap_chain_datum_tx_t *dap_chain_net_get_tx_by_hash(dap_chain_net_t *a_net, dap_c case TX_SEARCH_TYPE_NET_UNSPENT: case TX_SEARCH_TYPE_CELL_UNSPENT: return dap_chain_ledger_tx_find_by_hash(l_ledger, a_tx_hash); - default:; + default: break; } return NULL; } diff --git a/modules/net/dap_chain_node_cli_cmd_tx.c b/modules/net/dap_chain_node_cli_cmd_tx.c index 94222ad44cc5185df4639ea4b668d609bf72cfa0..c19532858ae61bf590a0414f6eeda7aeba7f181b 100644 --- a/modules/net/dap_chain_node_cli_cmd_tx.c +++ b/modules/net/dap_chain_node_cli_cmd_tx.c @@ -99,13 +99,36 @@ static bool s_dap_chain_datum_tx_out_data(dap_chain_datum_tx_t *a_datum, const char *a_hash_out_type, dap_chain_hash_fast_t *a_tx_hash) { - const char *l_ticker = NULL; - if (a_ledger) { - l_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger, a_tx_hash); - if (!l_ticker) - return false; - } + const char *l_ticker = a_ledger + ? dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger, a_tx_hash) + : NULL; + if (!l_ticker) + return false; dap_chain_datum_dump_tx(a_datum, l_ticker, a_str_out, a_hash_out_type, a_tx_hash); + dap_list_t *l_out_items = dap_chain_datum_tx_items_get(a_datum, TX_ITEM_TYPE_OUT_ALL, NULL); + int l_out_idx = 0; + dap_string_append_printf(a_str_out, "Spenders:\r\n"); + bool l_spent = false; + for (dap_list_t *l_item = l_out_items; l_item; l_item = l_item->next, ++l_out_idx) { + switch (*(dap_chain_tx_item_type_t*)l_item->data) { + case TX_ITEM_TYPE_OUT: + case TX_ITEM_TYPE_OUT_OLD: + case TX_ITEM_TYPE_OUT_EXT: { + dap_hash_fast_t l_spender = { }; + if ((l_spent = dap_chain_ledger_tx_hash_is_used_out_item(a_ledger, a_tx_hash, l_out_idx, &l_spender))) { + char l_hash_str[DAP_CHAIN_HASH_FAST_STR_SIZE] = { '\0' }; + dap_hash_fast_to_str(&l_spender, l_hash_str, sizeof(l_hash_str)); + dap_string_append_printf(a_str_out, + "\tout item %d is spent by tx %s\r\n", + l_out_idx, l_hash_str); + } + break; + } + default: + break; + } + } + dap_string_append_printf(a_str_out, l_spent ? "\r\n\r\n" : "\tall yet unspent\r\n\r\n"); return true; } @@ -749,13 +772,11 @@ int com_ledger(int a_argc, char ** a_argv, char **a_str_reply) dap_list_t *l_txs_list = dap_chain_ledger_get_txs(l_ledger, l_tx_count, 1, true); for (dap_list_t *iter = l_txs_list; iter; iter = dap_list_next(iter)) { dap_chain_datum_tx_t *l_tx = iter->data; - size_t l_tx_size = dap_chain_datum_tx_get_size(l_tx); - dap_hash_fast_t l_tx_hash = {0}; - dap_hash_fast(l_tx, l_tx_size, &l_tx_hash); - const char *l_tx_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(l_ledger, &l_tx_hash); - dap_chain_datum_dump_tx(l_tx, l_tx_ticker, l_str_ret, l_hash_out_type, &l_tx_hash); + dap_hash_fast_t l_tx_hash = { }; + dap_hash_fast(l_tx, dap_chain_datum_tx_get_size(l_tx), &l_tx_hash); + s_dap_chain_datum_tx_out_data(l_tx, l_ledger, l_str_ret, l_hash_out_type, &l_tx_hash); } - dap_list_free1(l_txs_list); + dap_list_free(l_txs_list); } } else { if(l_addr) @@ -769,10 +790,9 @@ int com_ledger(int a_argc, char ** a_argv, char **a_str_reply) dap_chain_datum_tx_t *l_tx = dap_chain_ledger_tx_find_by_hash(l_ledger,&l_tx_hash); if(l_tx){ size_t l_tx_size = dap_chain_datum_tx_get_size(l_tx); - dap_hash_fast_t l_tx_hash = {0}; + dap_hash_fast_t l_tx_hash = { }; dap_hash_fast(l_tx, l_tx_size, &l_tx_hash); - const char *l_tx_ticker = dap_chain_ledger_tx_get_token_ticker_by_hash(l_ledger, &l_tx_hash); - dap_chain_datum_dump_tx(l_tx,l_tx_ticker,l_str_ret,l_hash_out_type,&l_tx_hash); + s_dap_chain_datum_tx_out_data(l_tx, l_ledger, l_str_ret, l_hash_out_type, &l_tx_hash); dap_string_append_printf(l_str_ret, "history for tx hash %s:\n%s\n", l_tx_hash_str, l_str_out ? l_str_out : " empty"); } diff --git a/modules/service/stake/dap_chain_net_srv_stake_lock.c b/modules/service/stake/dap_chain_net_srv_stake_lock.c index 825b38db34b569a3f00e3e0472c2d00ced363891..2b01281942e0997574f6d853b75db883855499aa 100644 --- a/modules/service/stake/dap_chain_net_srv_stake_lock.c +++ b/modules/service/stake/dap_chain_net_srv_stake_lock.c @@ -405,7 +405,7 @@ static enum error_code s_cli_take(int a_argc, char **a_argv, int a_arg_index, da if (l_tx_out_cond->header.subtype != DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_STAKE_LOCK) return NO_VALID_SUBTYPE_ERROR; - if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, &l_tx_hash, l_prev_cond_idx)) { + if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, &l_tx_hash, l_prev_cond_idx, NULL)) { return IS_USED_OUT_ERROR; } diff --git a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c index 667cb00c7158666cc624b6099c45ab773acedd87..7bb6e3d805698f932bbd02ea2d253bcb5bd7fbcf 100644 --- a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c +++ b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c @@ -539,8 +539,11 @@ dap_chain_datum_decree_t *dap_chain_net_srv_stake_decree_approve(dap_chain_net_t log_it(L_WARNING, "Requested conditional transaction has no requires conditional output"); return NULL; } - if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, a_stake_tx_hash, l_prev_cond_idx)) { - log_it(L_WARNING, "Requested conditional transaction is already used out"); + dap_hash_fast_t l_spender_hash = { }; + if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, a_stake_tx_hash, l_prev_cond_idx, &l_spender_hash)) { + char l_hash_str[DAP_CHAIN_HASH_FAST_STR_SIZE]; + dap_chain_hash_fast_to_str(&l_spender_hash, l_hash_str, sizeof(l_hash_str)); + log_it(L_WARNING, "Requested conditional transaction is already used out by %s", l_hash_str); return NULL; } char l_delegated_ticker[DAP_CHAIN_TICKER_SIZE_MAX]; @@ -704,8 +707,11 @@ static dap_chain_datum_tx_t *s_stake_tx_invalidate(dap_chain_net_t *a_net, dap_h log_it(L_WARNING, "Requested conditional transaction has no requires conditional output"); return NULL; } - if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, a_tx_hash, l_prev_cond_idx)) { - log_it(L_WARNING, "Requested conditional transaction is already used out"); + dap_hash_fast_t l_spender_hash = { }; + if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, a_tx_hash, l_prev_cond_idx, &l_spender_hash)) { + char l_hash_str[DAP_CHAIN_HASH_FAST_STR_SIZE]; + dap_chain_hash_fast_to_str(&l_spender_hash, l_hash_str, sizeof(l_hash_str)); + log_it(L_WARNING, "Requested conditional transaction is already used out by %s", l_hash_str); return NULL; } // Get sign item @@ -1274,7 +1280,7 @@ static void s_get_tx_filter_callback(dap_chain_net_t* a_net, dap_chain_datum_tx_ &l_out_idx_tmp))) { dap_hash_fast(a_tx, dap_chain_datum_tx_get_size(a_tx), &l_datum_hash); - if (!dap_chain_ledger_tx_hash_is_used_out_item(a_net->pub.ledger, &l_datum_hash, l_out_idx_tmp)) { + if (!dap_chain_ledger_tx_hash_is_used_out_item(a_net->pub.ledger, &l_datum_hash, l_out_idx_tmp, NULL)) { dap_chain_net_srv_stake_item_t *l_stake = NULL; HASH_FIND(ht, s_srv_stake->tx_itemlist, &l_datum_hash, sizeof(dap_hash_fast_t), l_stake); if(!l_stake){ diff --git a/modules/service/xchange/dap_chain_net_srv_xchange.c b/modules/service/xchange/dap_chain_net_srv_xchange.c index b293315120a3bfe07b7c886a56e02f1de3864b46..3266cd644301ba1b84bed2f5b4a76c9612ee0a1a 100644 --- a/modules/service/xchange/dap_chain_net_srv_xchange.c +++ b/modules/service/xchange/dap_chain_net_srv_xchange.c @@ -593,7 +593,7 @@ static dap_chain_datum_tx_t *s_xchange_tx_create_exchange(dap_chain_net_srv_xcha log_it(L_WARNING, "Requested transaction has no conditional output"); return NULL; } - if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, &a_price->tx_hash, l_prev_cond_idx)) { + if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, &a_price->tx_hash, l_prev_cond_idx, NULL)) { log_it(L_WARNING, "Requested conditional transaction is already used out"); return NULL; } @@ -788,7 +788,7 @@ static bool s_xchange_tx_invalidate(dap_chain_net_srv_xchange_price_t *a_price, int l_prev_cond_idx = 0; dap_chain_tx_out_cond_t *l_tx_out_cond = dap_chain_datum_tx_out_cond_get(l_cond_tx, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_XCHANGE, &l_prev_cond_idx); - if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, &a_price->tx_hash, l_prev_cond_idx)) { + if (dap_chain_ledger_tx_hash_is_used_out_item(l_ledger, &a_price->tx_hash, l_prev_cond_idx, NULL)) { log_it(L_WARNING, "Requested conditional transaction is already used out"); dap_chain_datum_tx_delete(l_tx); return false; @@ -1483,7 +1483,7 @@ static int s_tx_check_for_open_close(dap_chain_net_t * a_net, dap_chain_datum_tx dap_chain_tx_out_cond_t *l_out_cond_item = dap_chain_datum_tx_out_cond_get(a_tx, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_XCHANGE, &l_cond_idx); if (l_out_cond_item) { - if(dap_chain_ledger_tx_hash_is_used_out_item(a_net->pub.ledger, &l_tx_hash, l_cond_idx)) + if(dap_chain_ledger_tx_hash_is_used_out_item(a_net->pub.ledger, &l_tx_hash, l_cond_idx, NULL)) return 1; // If its SRV_XCHANGE and spent its closed else return 2; // If its SRV_XCHANGE and not spent its open @@ -1522,7 +1522,7 @@ static void s_string_append_tx_cond_info( dap_string_t * a_reply_str, dap_chain_ bool l_is_cond_out = false; if ( l_out_cond_item && (l_out_cond_item->header.subtype == DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_XCHANGE) ) { - bool l_is_closed = dap_chain_ledger_tx_hash_is_used_out_item(a_net->pub.ledger, &l_tx_hash, l_cond_idx); + bool l_is_closed = dap_chain_ledger_tx_hash_is_used_out_item(a_net->pub.ledger, &l_tx_hash, l_cond_idx, NULL); uint256_t l_value_from = l_out_cond_item->header.value; uint256_t l_value_to = l_out_cond_item->subtype.srv_xchange.buy_value; @@ -1614,7 +1614,7 @@ dap_chain_tx_out_cond_t *l_out_cond_item; if (a_opt_status) /* 1 - closed, 2 - open */ { - l_rc = dap_chain_ledger_tx_hash_is_used_out_item(a_net->pub.ledger, &l_hash, l_item_idx); + l_rc = dap_chain_ledger_tx_hash_is_used_out_item(a_net->pub.ledger, &l_hash, l_item_idx, NULL); if ( a_opt_status ) { @@ -1941,7 +1941,7 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, char **a_str_reply) char *l_value_to_str = dap_chain_balance_to_coins(l_value_to); char *l_value_from_str = dap_chain_balance_to_coins(l_value_from); - l_rc = dap_chain_ledger_tx_hash_is_used_out_item(l_net->pub.ledger, &l_tx_hash, l_prev_cond_idx); + l_rc = dap_chain_ledger_tx_hash_is_used_out_item(l_net->pub.ledger, &l_tx_hash, l_prev_cond_idx, NULL); if ((l_opt_status == 1 && !l_rc) || /* Select close only */ (l_opt_status == 2 && l_rc)) /* Select open only */ @@ -2065,7 +2065,7 @@ static int s_cli_srv_xchange(int a_argc, char **a_argv, char **a_str_reply) dap_chain_tx_out_cond_t *l_out_cond_item = dap_chain_datum_tx_out_cond_get(l_tx, DAP_CHAIN_TX_OUT_COND_SUBTYPE_SRV_XCHANGE, &l_cond_idx); if (l_out_cond_item && - dap_chain_ledger_tx_hash_is_used_out_item(l_net->pub.ledger, l_tx_hash, l_cond_idx)) { + dap_chain_ledger_tx_hash_is_used_out_item(l_net->pub.ledger, l_tx_hash, l_cond_idx, NULL)) { uint256_t l_value_sell = l_out_cond_item->header.value; uint256_t l_value_buy = l_out_cond_item->subtype.srv_xchange.buy_value; if( l_direction == 1){ diff --git a/modules/type/blocks/dap_chain_block_cache.c b/modules/type/blocks/dap_chain_block_cache.c index cb8641e52b4e90853d1c395cf6a6acc40e364089..c37ee74624b2ce759739ee40971e3fe9d89998e5 100644 --- a/modules/type/blocks/dap_chain_block_cache.c +++ b/modules/type/blocks/dap_chain_block_cache.c @@ -177,7 +177,7 @@ dap_list_t * dap_chain_block_get_list_tx_cond_outs_with_val(dap_ledger_t *a_ledg //Check whether used 'out' items dap_hash_fast_t *l_tx_hash = a_block_cache->datum_hash + i; - if (!dap_chain_ledger_tx_hash_is_used_out_item (a_ledger, l_tx_hash, l_out_idx_tmp)) { + if (!dap_chain_ledger_tx_hash_is_used_out_item (a_ledger, l_tx_hash, l_out_idx_tmp, NULL)) { dap_chain_tx_used_out_item_t *l_item = DAP_NEW_Z(dap_chain_tx_used_out_item_t); if (!l_item) { log_it(L_ERROR, "Memory allocation error in %s, line %d", __PRETTY_FUNCTION__, __LINE__); diff --git a/modules/type/blocks/dap_chain_cs_blocks.c b/modules/type/blocks/dap_chain_cs_blocks.c index ce284dcacc474dd9057d52596f44eab7bbb11a4d..8d1dfcb481ac7341129b086310bbf0580b2d4ec9 100644 --- a/modules/type/blocks/dap_chain_cs_blocks.c +++ b/modules/type/blocks/dap_chain_cs_blocks.c @@ -674,7 +674,7 @@ static int s_cli_blocks(int a_argc, char ** a_argv, char **a_str_reply) int l_out_idx_tmp = 0; if (NULL == dap_chain_datum_tx_out_cond_get(l_tx, DAP_CHAIN_TX_OUT_COND_SUBTYPE_FEE, &l_out_idx_tmp)) continue; - if (!dap_chain_ledger_tx_hash_is_used_out_item(l_net->pub.ledger, l_block_cache->datum_hash + i, l_out_idx_tmp)) { + if (!dap_chain_ledger_tx_hash_is_used_out_item(l_net->pub.ledger, l_block_cache->datum_hash + i, l_out_idx_tmp, NULL)) { fl_found = true; break; }