Merge pull request #143 from isocolsky/ref/fees

Store fee on proposal creation
This commit is contained in:
Ivan Socolsky 2015-03-14 09:43:56 -03:00
commit 27920e176b
3 changed files with 5 additions and 1 deletions

View File

@ -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;
};

View File

@ -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);

View File

@ -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);