Merge pull request #3332

6b40ea93 simplewallet: fix print_ring_members printing wrong heights (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2018-03-05 19:12:59 +02:00
commit 61ac5b0471
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -3692,14 +3692,25 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
const tools::wallet2::tx_construction_data& construction_data = ptx_vector[n].construction_data; const tools::wallet2::tx_construction_data& construction_data = ptx_vector[n].construction_data;
ostr << boost::format(tr("\nTransaction %llu/%llu: txid=%s")) % (n + 1) % ptx_vector.size() % cryptonote::get_transaction_hash(tx); ostr << boost::format(tr("\nTransaction %llu/%llu: txid=%s")) % (n + 1) % ptx_vector.size() % cryptonote::get_transaction_hash(tx);
// for each input // for each input
std::vector<int> spent_key_height(tx.vin.size()); std::vector<uint64_t> spent_key_height(tx.vin.size());
std::vector<crypto::hash> spent_key_txid (tx.vin.size()); std::vector<crypto::hash> spent_key_txid (tx.vin.size());
for (size_t i = 0; i < tx.vin.size(); ++i) for (size_t i = 0; i < tx.vin.size(); ++i)
{ {
if (tx.vin[i].type() != typeid(cryptonote::txin_to_key)) if (tx.vin[i].type() != typeid(cryptonote::txin_to_key))
continue; continue;
const cryptonote::txin_to_key& in_key = boost::get<cryptonote::txin_to_key>(tx.vin[i]); const cryptonote::txin_to_key& in_key = boost::get<cryptonote::txin_to_key>(tx.vin[i]);
const cryptonote::tx_source_entry& source = construction_data.sources[i]; const tools::wallet2::transfer_details &td = m_wallet->get_transfer_details(construction_data.selected_transfers[i]);
const cryptonote::tx_source_entry *sptr = NULL;
for (const auto &src: construction_data.sources)
if (src.outputs[src.real_output].second.dest == td.get_public_key())
sptr = &src;
if (!sptr)
{
fail_msg_writer() << tr("failed to find construction data for tx input");
return false;
}
const cryptonote::tx_source_entry& source = *sptr;
ostr << boost::format(tr("\nInput %llu/%llu: amount=%s")) % (i + 1) % tx.vin.size() % print_money(source.amount); ostr << boost::format(tr("\nInput %llu/%llu: amount=%s")) % (i + 1) % tx.vin.size() % print_money(source.amount);
// convert relative offsets of ring member keys into absolute offsets (indices) associated with the amount // convert relative offsets of ring member keys into absolute offsets (indices) associated with the amount
std::vector<uint64_t> absolute_offsets = cryptonote::relative_output_offsets_to_absolute(in_key.key_offsets); std::vector<uint64_t> absolute_offsets = cryptonote::relative_output_offsets_to_absolute(in_key.key_offsets);
@ -3753,7 +3764,7 @@ bool simple_wallet::print_ring_members(const std::vector<tools::wallet2::pending
{ {
if (spent_key_txid[i] == spent_key_txid[j]) if (spent_key_txid[i] == spent_key_txid[j])
are_keys_from_same_tx = true; are_keys_from_same_tx = true;
if (std::abs(spent_key_height[i] - spent_key_height[j]) < 5) if (std::abs((int64_t)(spent_key_height[i] - spent_key_height[j])) < (int64_t)5)
are_keys_from_close_height = true; are_keys_from_close_height = true;
} }
} }