From 10231c3aa7cede9217aa4d9cdd080458216104db Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 12 Mar 2015 15:21:24 -0300 Subject: [PATCH] set fee if txp successfully created --- lib/model/txproposal.js | 2 ++ lib/server.js | 2 +- test/integration/server.js | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js index 1846e50..2f6ca79 100644 --- a/lib/model/txproposal.js +++ b/lib/model/txproposal.js @@ -33,6 +33,7 @@ TxProposal.create = function(opts) { x.status = 'pending'; x.actions = []; x.outputOrder = _.shuffle(_.range(2)); + x.fee = null; return x; }; @@ -60,6 +61,7 @@ TxProposal.fromObj = function(obj) { return TxProposalAction.fromObj(action); }); x.outputOrder = obj.outputOrder; + x.fee = obj.fee; return x; }; diff --git a/lib/server.js b/lib/server.js index 1b4e707..8987e06 100644 --- a/lib/server.js +++ b/lib/server.js @@ -505,6 +505,7 @@ WalletService.prototype._selectTxInputs = function(txp, cb) { txp.inputs = selected; bitcoreTx = txp.getBitcoreTx(); txp.inputPaths = _.pluck(txp.inputs, 'path'); + txp.fee = bitcoreTx.getFee(); return cb(); } catch (ex) { if (ex.name != 'bitcore.ErrorTransactionFeeError') { @@ -574,7 +575,6 @@ WalletService.prototype.createTx = function(opts, cb) { requiredRejections: Math.min(wallet.m, wallet.n - wallet.m + 1), }); - self._selectTxInputs(txp, function(err) { if (err) return cb(err); diff --git a/test/integration/server.js b/test/integration/server.js index 3a5ae14..79bd38d 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -803,6 +803,8 @@ describe('Copay server', function() { tx.message.should.equal('some message'); tx.isAccepted().should.equal.false; tx.isRejected().should.equal.false; + tx.amount.should.equal(helpers.toSatoshi(80)); + tx.fee.should.equal(Bitcore.Transaction.FEE_PER_KB); server.getPendingTxs({}, function(err, txs) { should.not.exist(err); txs.length.should.equal(1);