Merge pull request #6815

ef4325f wallet2: fix tx sanity check triggering on pre-rct outputs (monermooo-monero)
This commit is contained in:
luigi1111 2020-09-14 11:47:06 -05:00
commit 9bba1a24ea
2 changed files with 9 additions and 4 deletions

View file

@ -8052,13 +8052,16 @@ std::pair<std::set<uint64_t>, size_t> outs_unique(const std::vector<std::vector<
return std::make_pair(std::move(unique), total); return std::make_pair(std::move(unique), total);
} }
void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count) void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count, bool rct)
{ {
std::vector<uint64_t> rct_offsets; std::vector<uint64_t> rct_offsets;
for (size_t attempts = 3; attempts > 0; --attempts) for (size_t attempts = 3; attempts > 0; --attempts)
{ {
get_outs(outs, selected_transfers, fake_outputs_count, rct_offsets); get_outs(outs, selected_transfers, fake_outputs_count, rct_offsets);
if (!rct)
return;
const auto unique = outs_unique(outs); const auto unique = outs_unique(outs);
if (tx_sanity_check(unique.first, unique.second, rct_offsets.empty() ? 0 : rct_offsets.back())) if (tx_sanity_check(unique.first, unique.second, rct_offsets.empty() ? 0 : rct_offsets.back()))
{ {
@ -8696,7 +8699,7 @@ void wallet2::transfer_selected(const std::vector<cryptonote::tx_destination_ent
THROW_WALLET_EXCEPTION_IF(subaddr_account != m_transfers[*i].m_subaddr_index.major, error::wallet_internal_error, "the tx uses funds from multiple accounts"); THROW_WALLET_EXCEPTION_IF(subaddr_account != m_transfers[*i].m_subaddr_index.major, error::wallet_internal_error, "the tx uses funds from multiple accounts");
if (outs.empty()) if (outs.empty())
get_outs(outs, selected_transfers, fake_outputs_count); // may throw get_outs(outs, selected_transfers, fake_outputs_count, false); // may throw
//prepare inputs //prepare inputs
LOG_PRINT_L2("preparing outputs"); LOG_PRINT_L2("preparing outputs");
@ -8897,10 +8900,12 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
MDEBUG("We will create " << n_multisig_txes << " txes"); MDEBUG("We will create " << n_multisig_txes << " txes");
} }
bool all_rct = true;
uint64_t found_money = 0; uint64_t found_money = 0;
for(size_t idx: selected_transfers) for(size_t idx: selected_transfers)
{ {
found_money += m_transfers[idx].amount(); found_money += m_transfers[idx].amount();
all_rct &= m_transfers[idx].is_rct();
} }
LOG_PRINT_L2("wanted " << print_money(needed_money) << ", found " << print_money(found_money) << ", fee " << print_money(fee)); LOG_PRINT_L2("wanted " << print_money(needed_money) << ", found " << print_money(found_money) << ", fee " << print_money(fee));
@ -8911,7 +8916,7 @@ void wallet2::transfer_selected_rct(std::vector<cryptonote::tx_destination_entry
THROW_WALLET_EXCEPTION_IF(subaddr_account != m_transfers[*i].m_subaddr_index.major, error::wallet_internal_error, "the tx uses funds from multiple accounts"); THROW_WALLET_EXCEPTION_IF(subaddr_account != m_transfers[*i].m_subaddr_index.major, error::wallet_internal_error, "the tx uses funds from multiple accounts");
if (outs.empty()) if (outs.empty())
get_outs(outs, selected_transfers, fake_outputs_count); // may throw get_outs(outs, selected_transfers, fake_outputs_count, all_rct); // may throw
//prepare inputs //prepare inputs
LOG_PRINT_L2("preparing outputs"); LOG_PRINT_L2("preparing outputs");

View file

@ -1605,7 +1605,7 @@ private:
void set_unspent(size_t idx); void set_unspent(size_t idx);
bool is_spent(const transfer_details &td, bool strict = true) const; bool is_spent(const transfer_details &td, bool strict = true) const;
bool is_spent(size_t idx, bool strict = true) const; bool is_spent(size_t idx, bool strict = true) const;
void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count); void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count, bool rct);
void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count, std::vector<uint64_t> &rct_offsets); void get_outs(std::vector<std::vector<get_outs_entry>> &outs, const std::vector<size_t> &selected_transfers, size_t fake_outputs_count, std::vector<uint64_t> &rct_offsets);
bool tx_add_fake_output(std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, uint64_t global_index, const crypto::public_key& tx_public_key, const rct::key& mask, uint64_t real_index, bool unlocked) const; bool tx_add_fake_output(std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, uint64_t global_index, const crypto::public_key& tx_public_key, const rct::key& mask, uint64_t real_index, bool unlocked) const;
bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector<size_t> &unused_transfers_indices, const std::vector<size_t> &unused_dust_indices) const; bool should_pick_a_second_output(bool use_rct, size_t n_transfers, const std::vector<size_t> &unused_transfers_indices, const std::vector<size_t> &unused_dust_indices) const;