handle 0 input txs
This commit is contained in:
parent
93a8d65932
commit
6b8af51993
|
@ -1207,6 +1207,9 @@ WalletService.prototype.getSendMaxInfo = function(opts, cb) {
|
|||
|
||||
lastFee = fee;
|
||||
});
|
||||
|
||||
if (_.isEmpty(txp.inputs)) return cb(null, info);
|
||||
|
||||
info.size = txp.getEstimatedSize();
|
||||
info.fee = txp.getEstimatedFee();
|
||||
info.amount = _.sum(txp.inputs, 'satoshis') - info.fee;
|
||||
|
|
|
@ -3745,7 +3745,6 @@ describe('Wallet service', function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should exclude unconfirmed inputs', function(done) {
|
||||
helpers.stubUtxos(server, wallet, ['u0.1', 0.2, 0.3, 0.4], function() {
|
||||
server.getSendMaxInfo({
|
||||
|
@ -3817,6 +3816,22 @@ describe('Wallet service', function() {
|
|||
});
|
||||
});
|
||||
});
|
||||
it('should work when all inputs are below their cost in fee', function(done) {
|
||||
helpers.stubUtxos(server, wallet, ['u 10bit', '10bit', '20bit'], function() {
|
||||
server.getSendMaxInfo({
|
||||
feePerKb: 500e2,
|
||||
returnInputs: true,
|
||||
}, function(err, info) {
|
||||
should.not.exist(err);
|
||||
should.exist(info);
|
||||
info.inputs.should.be.empty;
|
||||
info.size.should.equal(0);
|
||||
info.fee.should.equal(0);
|
||||
info.amount.should.equal(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should not go beyond max tx size', function(done) {
|
||||
var _oldDefault = Defaults.MAX_TX_SIZE_IN_KB;
|
||||
Defaults.MAX_TX_SIZE_IN_KB = 2;
|
||||
|
|
Loading…
Reference in New Issue