diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js index a286927..1ae7538 100644 --- a/lib/model/txproposal.js +++ b/lib/model/txproposal.js @@ -44,7 +44,7 @@ TxProposal.create = function(opts) { x.requiredRejections = Math.min(x.walletM, x.walletN - x.walletM + 1), x.status = 'temporary'; x.actions = []; - x.fee = opts.fee; + x.fee = null; x.feePerKb = opts.feePerKb; x.feeLevel = opts.feeLevel; x.excludeUnconfirmedUtxos = opts.excludeUnconfirmedUtxos; diff --git a/lib/server.js b/lib/server.js index f651bba..b72998e 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1223,9 +1223,7 @@ WalletService.prototype._checkTxAndEstimateFee = function(txp) { serializationOpts.disableLargeFees = true; } - if (_.isNumber(txp.feePerKb)) { - txp.estimateFee(); - } + txp.estimateFee(); try { var bitcoreTx = txp.getBitcoreTx(); @@ -1544,7 +1542,6 @@ WalletService.prototype.createTxLegacy = function(opts, cb) { * @param {string} opts.outputs[].message - A message to attach to this output. * @param {string} opts.message - A message to attach to this transaction. * @param {Array} opts.inputs - Optional. Inputs for this TX - * @param {string} opts.fee - Optional. Use an alternative fee for this TX (mutually exclusive with feePerKb) * @param {string} opts.feePerKb - Optional. Use an alternative fee per KB for this TX (mutually exclusive with fee) * @param {string} opts.feeLevel - Optional. Specify the fee level used to compute feePerKb for this txp. * @param {string} opts.payProUrl - Optional. Paypro URL for peers to verify TX @@ -1558,18 +1555,9 @@ WalletService.prototype.createTx = function(opts, cb) { if (!Utils.checkRequired(opts, ['outputs'])) 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')); - } else { - opts.fee = null; - opts.feePerKb = opts.feePerKb || Defaults.DEFAULT_FEE_PER_KB; - if (opts.feePerKb < Defaults.MIN_FEE_PER_KB || opts.feePerKb > Defaults.MAX_FEE_PER_KB) - return cb(new ClientError('Invalid fee per KB')); - } + opts.feePerKb = opts.feePerKb || Defaults.DEFAULT_FEE_PER_KB; + if (opts.feePerKb < Defaults.MIN_FEE_PER_KB || opts.feePerKb > Defaults.MAX_FEE_PER_KB) + return cb(new ClientError('Invalid fee per KB')); self._runLocked(cb, function(cb) { self.getWallet({}, function(err, wallet) { @@ -1594,7 +1582,6 @@ WalletService.prototype.createTx = function(opts, cb) { outputs: opts.outputs, message: opts.message, changeAddress: wallet.createAddress(true), - fee: opts.fee, feePerKb: opts.feePerKb, feeLevel: opts.feeLevel, payProUrl: opts.payProUrl, diff --git a/test/integration/server.js b/test/integration/server.js index 58cd249..5bca205 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -2742,61 +2742,6 @@ describe('Wallet service', function() { }); }); - it('should be able to specify the final fee', function(done) { - helpers.stubUtxos(server, wallet, [1, 2], function() { - var txOpts = { - outputs: [{ - toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', - amount: 0.8 * 1e8, - }], - fee: 123400, - }; - server.createTx(txOpts, function(err, tx) { - should.not.exist(err); - should.exist(tx); - tx.fee.should.equal(123400); - var t = tx.getBitcoreTx(); - t.getFee().should.equal(123400); - done(); - }); - }); - }); - - 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 = { - outputs: [{ - toAddress: '18PzpUFkFZE8zKWUPvfykkTxmB9oMR8qP7', - amount: 0.8 * 1e8, - }], - fee: 1e8, - }; - server.createTx(txOpts, function(err, tx) { - should.exist(err); - err.message.should.contain('fee'); - done(); - }); - }); - }); - it('should be able to publish a temporary tx proposal', function(done) { helpers.stubUtxos(server, wallet, [1, 2], function() { var txOpts = {