Merge pull request #136

bb2b606 fix incorrect error message (obvious cut and paste bug from upstream) (iamsmooth)
6b77e83 Change wallet to not try to extract tx public key when tx has no outputs (fixes 202612 tx format messages and is otherwise correct) (iamsmooth)
08205f0 output rng fix from boolberry (iamsmooth)
This commit is contained in:
Riccardo Spagni 2014-09-13 10:22:13 +02:00
commit 9c56b38b16
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
3 changed files with 51 additions and 48 deletions

View File

@ -1006,7 +1006,6 @@ size_t blockchain_storage::find_end_of_allowed_index(const std::vector<std::pair
//------------------------------------------------------------------ //------------------------------------------------------------------
bool blockchain_storage::get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res) bool blockchain_storage::get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res)
{ {
srand(static_cast<unsigned int>(time(NULL)));
CRITICAL_REGION_LOCAL(m_blockchain_lock); CRITICAL_REGION_LOCAL(m_blockchain_lock);
BOOST_FOREACH(uint64_t amount, req.amounts) BOOST_FOREACH(uint64_t amount, req.amounts)
{ {
@ -1029,7 +1028,7 @@ bool blockchain_storage::get_random_outs_for_amounts(const COMMAND_RPC_GET_RANDO
size_t try_count = 0; size_t try_count = 0;
for(uint64_t j = 0; j != req.outs_count && try_count < up_index_limit;) for(uint64_t j = 0; j != req.outs_count && try_count < up_index_limit;)
{ {
size_t i = rand()%up_index_limit; size_t i = crypto::rand<size_t>()%up_index_limit;
if(used.count(i)) if(used.count(i))
continue; continue;
bool added = add_out_to_get_random_outs(amount_outs, result_outs, amount, i); bool added = add_out_to_get_random_outs(amount_outs, result_outs, amount, i);

View File

@ -257,7 +257,7 @@ namespace cryptonote
//check if tx use different key images //check if tx use different key images
if(!check_tx_inputs_keyimages_diff(tx)) if(!check_tx_inputs_keyimages_diff(tx))
{ {
LOG_PRINT_RED_L1("tx is too large " << get_object_blobsize(tx) << ", expected not bigger than " << m_blockchain_storage.get_current_comulative_blocksize_limit() - CRYPTONOTE_COINBASE_BLOB_RESERVED_SIZE); LOG_PRINT_RED_L1("tx uses a single key image more than once");
return false; return false;
} }

View File

@ -109,6 +109,9 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_
LOG_PRINT_L0("Transaction extra has unsupported format: " << get_transaction_hash(tx)); LOG_PRINT_L0("Transaction extra has unsupported format: " << get_transaction_hash(tx));
} }
// Don't try to extract tx public key if tx has no ouputs
if (!tx.vout.empty())
{
tx_extra_pub_key pub_key_field; tx_extra_pub_key pub_key_field;
if(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field)) if(!find_tx_extra_field_by_type(tx_extra_fields, pub_key_field))
{ {
@ -160,6 +163,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_
m_callback->on_money_received(height, td.m_tx, td.m_internal_output_index); m_callback->on_money_received(height, td.m_tx, td.m_internal_output_index);
} }
} }
}
uint64_t tx_money_spent_in_ins = 0; uint64_t tx_money_spent_in_ins = 0;
// check all outputs for spending (compare key images) // check all outputs for spending (compare key images)