Merge pull request #143 from isocolsky/ref/fees
Store fee on proposal creation
This commit is contained in:
commit
27920e176b
|
@ -33,6 +33,7 @@ TxProposal.create = function(opts) {
|
||||||
x.status = 'pending';
|
x.status = 'pending';
|
||||||
x.actions = [];
|
x.actions = [];
|
||||||
x.outputOrder = _.shuffle(_.range(2));
|
x.outputOrder = _.shuffle(_.range(2));
|
||||||
|
x.fee = null;
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
@ -60,6 +61,7 @@ TxProposal.fromObj = function(obj) {
|
||||||
return TxProposalAction.fromObj(action);
|
return TxProposalAction.fromObj(action);
|
||||||
});
|
});
|
||||||
x.outputOrder = obj.outputOrder;
|
x.outputOrder = obj.outputOrder;
|
||||||
|
x.fee = obj.fee;
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
};
|
};
|
||||||
|
|
|
@ -505,6 +505,7 @@ WalletService.prototype._selectTxInputs = function(txp, cb) {
|
||||||
txp.inputs = selected;
|
txp.inputs = selected;
|
||||||
bitcoreTx = txp.getBitcoreTx();
|
bitcoreTx = txp.getBitcoreTx();
|
||||||
txp.inputPaths = _.pluck(txp.inputs, 'path');
|
txp.inputPaths = _.pluck(txp.inputs, 'path');
|
||||||
|
txp.fee = bitcoreTx.getFee();
|
||||||
return cb();
|
return cb();
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
if (ex.name != 'bitcore.ErrorTransactionFeeError') {
|
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),
|
requiredRejections: Math.min(wallet.m, wallet.n - wallet.m + 1),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
self._selectTxInputs(txp, function(err) {
|
self._selectTxInputs(txp, function(err) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
|
|
||||||
|
|
|
@ -803,6 +803,8 @@ describe('Copay server', function() {
|
||||||
tx.message.should.equal('some message');
|
tx.message.should.equal('some message');
|
||||||
tx.isAccepted().should.equal.false;
|
tx.isAccepted().should.equal.false;
|
||||||
tx.isRejected().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) {
|
server.getPendingTxs({}, function(err, txs) {
|
||||||
should.not.exist(err);
|
should.not.exist(err);
|
||||||
txs.length.should.equal(1);
|
txs.length.should.equal(1);
|
||||||
|
|
Loading…
Reference in New Issue