|
|
@ -1175,6 +1175,7 @@ WalletService.prototype.getSendMaxInfo = function(opts, cb) { |
|
|
|
amount: 0, |
|
|
|
fee: 0, |
|
|
|
nbInputs: 0, |
|
|
|
inputs: [], |
|
|
|
}; |
|
|
|
|
|
|
|
var inputs = _.reject(utxos, 'locked'); |
|
|
@ -1197,8 +1198,8 @@ WalletService.prototype.getSendMaxInfo = function(opts, cb) { |
|
|
|
_.eachRight(inputs, function(input) { |
|
|
|
txp.inputs.push(input); |
|
|
|
var fee = txp.getEstimatedFee(); |
|
|
|
if (fee - lastFee > input.satoshis || |
|
|
|
txp.getEstimatedSize() / 1000. > Defaults.MAX_TX_SIZE_IN_KB) { |
|
|
|
var sizeInKb = txp.getEstimatedSize() / 1000.; |
|
|
|
if (fee - lastFee > input.satoshis || sizeInKb > Defaults.MAX_TX_SIZE_IN_KB) { |
|
|
|
txp.inputs.pop(); |
|
|
|
return false; |
|
|
|
} |
|
|
@ -1210,6 +1211,7 @@ WalletService.prototype.getSendMaxInfo = function(opts, cb) { |
|
|
|
info.fee = txp.getEstimatedFee(); |
|
|
|
info.amount = _.sum(txp.inputs, 'satoshis') - info.fee; |
|
|
|
info.nbInputs = txp.inputs.length; |
|
|
|
info.inputs = txp.inputs; |
|
|
|
|
|
|
|
return cb(null, info); |
|
|
|
}); |
|
|
|