check fee xor feePerKb
This commit is contained in:
parent
4bad281966
commit
f7328fc4ce
|
@ -1553,6 +1553,8 @@ WalletService.prototype.createTx = function(opts, cb) {
|
|||
return cb(new ClientError('Required argument missing'));
|
||||
|
||||
if (_.isNumber(opts.fee)) {
|
||||
if (_.isNumber(opts.feePerKb))
|
||||
return cb(new ClientError('Cannot sepcify both fee and feePerKb arguments'));
|
||||
opts.feePerKb = null;
|
||||
if (opts.fee < Defaults.MIN_TX_FEE || opts.fee > Defaults.MAX_TX_FEE)
|
||||
return cb(new ClientError('Invalid fee'));
|
||||
|
|
|
@ -2742,6 +2742,24 @@ describe('Wallet service', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not be able to specify both final fee & fee per kb', function(done) {
|
||||
helpers.stubUtxos(server, wallet, [1, 2], function() {
|
||||
var txOpts = {
|
||||
outputs: [{
|
||||
toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7',
|
||||
amount: 0.8 * 1e8,
|
||||
}],
|
||||
fee: 123400,
|
||||
feePerKb: 123400,
|
||||
};
|
||||
server.createTx(txOpts, function(err, tx) {
|
||||
should.exist(err);
|
||||
err.message.should.contain('fee');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should check explicit fee to be below max', function(done) {
|
||||
helpers.stubUtxos(server, wallet, [1, 2], function() {
|
||||
var txOpts = {
|
||||
|
|
Loading…
Reference in New Issue