wallet2: force using output distribution for ringct outs
Co-authored-by: j-berman <justinberman@protonmail.com>
This commit is contained in:
parent
9750e1fa10
commit
db8181adf8
|
@ -8049,8 +8049,13 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||||
has_rct = true;
|
has_rct = true;
|
||||||
max_rct_index = std::max(max_rct_index, m_transfers[idx].m_global_output_index);
|
max_rct_index = std::max(max_rct_index, m_transfers[idx].m_global_output_index);
|
||||||
}
|
}
|
||||||
const bool has_rct_distribution = has_rct && (!rct_offsets.empty() || get_rct_distribution(rct_start_height, rct_offsets));
|
|
||||||
if (has_rct_distribution)
|
if (has_rct && rct_offsets.empty()) {
|
||||||
|
THROW_WALLET_EXCEPTION_IF(!get_rct_distribution(rct_start_height, rct_offsets),
|
||||||
|
error::get_output_distribution, "Could not obtain output distribution.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_rct)
|
||||||
{
|
{
|
||||||
// check we're clear enough of rct start, to avoid corner cases below
|
// check we're clear enough of rct start, to avoid corner cases below
|
||||||
THROW_WALLET_EXCEPTION_IF(rct_offsets.size() <= CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE,
|
THROW_WALLET_EXCEPTION_IF(rct_offsets.size() <= CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE,
|
||||||
|
@ -8062,11 +8067,11 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||||
// get histogram for the amounts we need
|
// get histogram for the amounts we need
|
||||||
cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request req_t = AUTO_VAL_INIT(req_t);
|
cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::request req_t = AUTO_VAL_INIT(req_t);
|
||||||
cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response resp_t = AUTO_VAL_INIT(resp_t);
|
cryptonote::COMMAND_RPC_GET_OUTPUT_HISTOGRAM::response resp_t = AUTO_VAL_INIT(resp_t);
|
||||||
// request histogram for all outputs, except 0 if we have the rct distribution
|
// request histogram for all pre-rct outputs
|
||||||
req_t.amounts.reserve(selected_transfers.size());
|
req_t.amounts.reserve(selected_transfers.size());
|
||||||
for(size_t idx: selected_transfers)
|
for(size_t idx: selected_transfers)
|
||||||
if (!m_transfers[idx].is_rct() || !has_rct_distribution)
|
if (!m_transfers[idx].is_rct())
|
||||||
req_t.amounts.push_back(m_transfers[idx].is_rct() ? 0 : m_transfers[idx].amount());
|
req_t.amounts.push_back(m_transfers[idx].amount());
|
||||||
if (!req_t.amounts.empty())
|
if (!req_t.amounts.empty())
|
||||||
{
|
{
|
||||||
std::sort(req_t.amounts.begin(), req_t.amounts.end());
|
std::sort(req_t.amounts.begin(), req_t.amounts.end());
|
||||||
|
@ -8166,7 +8171,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||||
COMMAND_RPC_GET_OUTPUTS_BIN::response daemon_resp = AUTO_VAL_INIT(daemon_resp);
|
COMMAND_RPC_GET_OUTPUTS_BIN::response daemon_resp = AUTO_VAL_INIT(daemon_resp);
|
||||||
|
|
||||||
std::unique_ptr<gamma_picker> gamma;
|
std::unique_ptr<gamma_picker> gamma;
|
||||||
if (has_rct_distribution)
|
if (has_rct)
|
||||||
gamma.reset(new gamma_picker(rct_offsets));
|
gamma.reset(new gamma_picker(rct_offsets));
|
||||||
|
|
||||||
size_t num_selected_transfers = 0;
|
size_t num_selected_transfers = 0;
|
||||||
|
@ -8181,7 +8186,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||||
// request more for rct in base recent (locked) coinbases are picked, since they're locked for longer
|
// request more for rct in base recent (locked) coinbases are picked, since they're locked for longer
|
||||||
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0);
|
size_t requested_outputs_count = base_requested_outputs_count + (td.is_rct() ? CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE : 0);
|
||||||
size_t start = req.outputs.size();
|
size_t start = req.outputs.size();
|
||||||
bool use_histogram = amount != 0 || !has_rct_distribution;
|
bool use_histogram = amount != 0;
|
||||||
|
|
||||||
const bool output_is_pre_fork = td.m_block_height < segregation_fork_height;
|
const bool output_is_pre_fork = td.m_block_height < segregation_fork_height;
|
||||||
uint64_t num_outs = 0, num_recent_outs = 0;
|
uint64_t num_outs = 0, num_recent_outs = 0;
|
||||||
|
@ -8368,7 +8373,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||||
|
|
||||||
uint64_t i;
|
uint64_t i;
|
||||||
const char *type = "";
|
const char *type = "";
|
||||||
if (amount == 0 && has_rct_distribution)
|
if (amount == 0)
|
||||||
{
|
{
|
||||||
THROW_WALLET_EXCEPTION_IF(!gamma, error::wallet_internal_error, "No gamma picker");
|
THROW_WALLET_EXCEPTION_IF(!gamma, error::wallet_internal_error, "No gamma picker");
|
||||||
// gamma distribution
|
// gamma distribution
|
||||||
|
@ -8530,7 +8535,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool use_histogram = amount != 0 || !has_rct_distribution;
|
bool use_histogram = amount != 0;
|
||||||
if (!use_histogram)
|
if (!use_histogram)
|
||||||
num_outs = rct_offsets[rct_offsets.size() - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE];
|
num_outs = rct_offsets[rct_offsets.size() - CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue