merge utxo exclusion into sanitize fn
This commit is contained in:
parent
cbde3233df
commit
08cb603a50
|
@ -1279,22 +1279,17 @@ WalletService.prototype._selectTxInputs = function(txp, utxosToExclude, cb) {
|
|||
var sizePerInput = txp.getEstimatedSizeForSingleInput();
|
||||
var feePerInput = sizePerInput * txp.feePerKb / 1000.;
|
||||
|
||||
function excludeUtxos(utxos) {
|
||||
function sanitizeUtxos(utxos) {
|
||||
var excludeIndex = _.reduce(utxosToExclude, function(res, val) {
|
||||
res[val] = val;
|
||||
return res;
|
||||
}, {});
|
||||
|
||||
return _.reject(utxos, function(utxo) {
|
||||
return excludeIndex[utxo.txid + ":" + utxo.vout];
|
||||
});
|
||||
};
|
||||
|
||||
function sanitizeUtxos(utxos) {
|
||||
return _.filter(utxos, function(utxo) {
|
||||
if (utxo.locked) return false;
|
||||
if (utxo.satoshis <= feePerInput) return false;
|
||||
if (txp.excludeUnconfirmedUtxos && !utxo.confirmations) return false;
|
||||
if (excludeIndex[utxo.txid + ":" + utxo.vout]) return false;
|
||||
return true;
|
||||
});
|
||||
};
|
||||
|
@ -1415,8 +1410,6 @@ WalletService.prototype._selectTxInputs = function(txp, utxosToExclude, cb) {
|
|||
self._getUtxosForCurrentWallet(null, function(err, utxos) {
|
||||
if (err) return cb(err);
|
||||
|
||||
utxos = excludeUtxos(utxos);
|
||||
|
||||
var totalAmount;
|
||||
var availableAmount;
|
||||
|
||||
|
|
Loading…
Reference in New Issue