monero_config: updated the dust threshold from 10^10 to 2*10^9; monero_sendingFunds_utils: enhanced sweeping to support sending dusty but mixable outs to get closer to full account balance

pull/24/head
Paul Shapiro 6 years ago
parent fb4887f2d9
commit d71bfb239e

@ -56,8 +56,8 @@ module.exports =
subaddressPrefix: 42,
// Dust threshold in atomic units
// 10^10 used for choosing outputs/change - we decompose all the way down if the receiver wants now regardless of threshold
dustThreshold: new JSBigInt('10000000000'),
// 2*10^9 used for choosing outputs/change - we decompose all the way down if the receiver wants now regardless of threshold
dustThreshold: new JSBigInt('2000000000'),
// Maximum block number, used for tx unlock time
maxBlockNumber: 500000000,

@ -270,6 +270,7 @@ function SendFunds(
wallet__public_keys.spend,
wallet__private_keys.spend,
mixin,
sweeping,
function(
err,
unspentOuts,
@ -340,7 +341,8 @@ function SendFunds(
const usableOutputsAndAmounts = _outputsAndAmountToUseForMixin(
totalAmountIncludingFees,
unusedOuts,
isRingCT
isRingCT,
sweeping
)
// v-- now if RingCT compute fee as closely as possible before hand
var usingOuts = usableOutputsAndAmounts.usingOuts
@ -663,9 +665,9 @@ function _popAndReturnRandomElementFromList(list)
function _outputsAndAmountToUseForMixin(
target_amount,
unusedOuts,
isRingCT
)
{
isRingCT,
sweeping
) {
console.log("Selecting outputs to use. target: " + monero_utils.formatMoney(target_amount))
var toFinalize_usingOutsAmount = new JSBigInt(0)
const toFinalize_usingOuts = []
@ -675,10 +677,22 @@ function _outputsAndAmountToUseForMixin(
if (!isRingCT && out.rct) { // out.rct is set by the server
continue; // skip rct outputs if not creating rct tx
}
const out_amount = out.amount
const out_amount_JSBigInt = new JSBigInt(out.amount)
if (out_amount_JSBigInt.compare(monero_config.dustThreshold) < 0) { // amount is dusty..
if (sweeping == false) {
console.log("Not sweeping, and found a dusty (though maybe mixable) output... skipping it!")
continue
}
if (!out.rct || typeof out.rct === 'undefined') {
console.log("Sweeping, and found a dusty but unmixable (non-rct) output... skipping it!")
continue
} else {
console.log("Sweeping and found a dusty but mixable (rct) amount... keeping it!")
}
}
toFinalize_usingOuts.push(out)
toFinalize_usingOutsAmount = toFinalize_usingOutsAmount.add(out_amount)
console.log("Using output: " + monero_utils.formatMoney(out_amount) + " - " + JSON.stringify(out))
toFinalize_usingOutsAmount = toFinalize_usingOutsAmount.add(out_amount_JSBigInt)
console.log("Using output: " + monero_utils.formatMoney(out_amount_JSBigInt) + " - " + JSON.stringify(out))
}
return {
usingOuts: toFinalize_usingOuts,

Loading…
Cancel
Save