Allow fractional outputs to be ignored
This commit is contained in:
@@ -676,6 +676,7 @@ wallet2::wallet2(network_type nettype, bool restricted):
|
||||
m_segregate_pre_fork_outputs(true),
|
||||
m_key_reuse_mitigation2(true),
|
||||
m_segregation_height(0),
|
||||
m_ignore_fractional_outputs(true),
|
||||
m_is_initialized(false),
|
||||
m_restricted(restricted),
|
||||
is_old_file_format(false),
|
||||
@@ -2782,6 +2783,9 @@ bool wallet2::store_keys(const std::string& keys_file_name, const epee::wipeable
|
||||
value2.SetUint(m_segregation_height);
|
||||
json.AddMember("segregation_height", value2, json.GetAllocator());
|
||||
|
||||
value2.SetInt(m_ignore_fractional_outputs ? 1 : 0);
|
||||
json.AddMember("ignore_fractional_outputs", value2, json.GetAllocator());
|
||||
|
||||
value2.SetUint(m_subaddress_lookahead_major);
|
||||
json.AddMember("subaddress_lookahead_major", value2, json.GetAllocator());
|
||||
|
||||
@@ -2864,6 +2868,7 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_
|
||||
m_segregate_pre_fork_outputs = true;
|
||||
m_key_reuse_mitigation2 = true;
|
||||
m_segregation_height = 0;
|
||||
m_ignore_fractional_outputs = true;
|
||||
m_subaddress_lookahead_major = SUBADDRESS_LOOKAHEAD_MAJOR;
|
||||
m_subaddress_lookahead_minor = SUBADDRESS_LOOKAHEAD_MINOR;
|
||||
m_key_on_device = false;
|
||||
@@ -2990,6 +2995,8 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_
|
||||
m_key_reuse_mitigation2 = field_key_reuse_mitigation2;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, segregation_height, int, Uint, false, 0);
|
||||
m_segregation_height = field_segregation_height;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, ignore_fractional_outputs, int, Int, false, true);
|
||||
m_ignore_fractional_outputs = field_ignore_fractional_outputs;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, subaddress_lookahead_major, uint32_t, Uint, false, SUBADDRESS_LOOKAHEAD_MAJOR);
|
||||
m_subaddress_lookahead_major = field_subaddress_lookahead_major;
|
||||
GET_FIELD_FROM_JSON_RETURN_ON_ERROR(json, subaddress_lookahead_minor, uint32_t, Uint, false, SUBADDRESS_LOOKAHEAD_MINOR);
|
||||
@@ -7673,12 +7680,24 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
||||
for (uint32_t i : subaddr_indices)
|
||||
LOG_PRINT_L2("Candidate subaddress index for spending: " << i);
|
||||
|
||||
// determine threshold for fractional amount
|
||||
const size_t tx_size_one_ring = estimate_tx_size(use_rct, 1, fake_outs_count, 2, 0, bulletproof);
|
||||
const size_t tx_size_two_rings = estimate_tx_size(use_rct, 2, fake_outs_count, 2, 0, bulletproof);
|
||||
THROW_WALLET_EXCEPTION_IF(tx_size_one_ring > tx_size_two_rings, error::wallet_internal_error, "Estimated tx size with 1 input is larger than with 2 inputs!");
|
||||
const size_t tx_size_per_ring = tx_size_two_rings - tx_size_one_ring;
|
||||
const uint64_t fractional_threshold = (fee_multiplier * fee_per_kb * tx_size_per_ring) / 1024;
|
||||
|
||||
// gather all dust and non-dust outputs belonging to specified subaddresses
|
||||
size_t num_nondust_outputs = 0;
|
||||
size_t num_dust_outputs = 0;
|
||||
for (size_t i = 0; i < m_transfers.size(); ++i)
|
||||
{
|
||||
const transfer_details& td = m_transfers[i];
|
||||
if (m_ignore_fractional_outputs && td.amount() < fractional_threshold)
|
||||
{
|
||||
MDEBUG("Ignoring output " << i << " of amount " << print_money(td.amount()) << " which is below threshold " << print_money(fractional_threshold));
|
||||
continue;
|
||||
}
|
||||
if (!td.m_spent && !td.m_key_image_partial && (use_rct ? true : !td.is_rct()) && is_transfer_unlocked(td) && td.m_subaddr_index.major == subaddr_account && subaddr_indices.count(td.m_subaddr_index.minor) == 1)
|
||||
{
|
||||
const uint32_t index_minor = td.m_subaddr_index.minor;
|
||||
|
||||
Reference in New Issue
Block a user