Skip to content

Commit

Permalink
fix: wrong output value calculation in _buildTx
Browse files Browse the repository at this point in the history
  • Loading branch information
troggy committed Apr 11, 2016
1 parent 1168824 commit 2e1cc88
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/model/txproposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ TxProposal.prototype._buildTx = function() {
t.fee(self.fee);

var totalInputs = _.sum(self.inputs, 'satoshis');
var totalOutputs = _.sum(self.outputs, 'satoshis');
var totalOutputs = _.sum(self.outputs, 'amount');

if (totalInputs - totalOutputs - self.fee > 0 && self.changeAddress) {
t.change(self.changeAddress.address);
Expand All @@ -182,7 +182,7 @@ TxProposal.prototype._buildTx = function() {
}

// Validate actual inputs vs outputs independently of Bitcore
var totalInputs = _.sum(t.inputs, 'satoshis');
var totalInputs = _.sum(t.inputs, 'output.satoshis');
var totalOutputs = _.sum(t.outputs, 'satoshis');

$.checkState(totalInputs - totalOutputs <= Defaults.MAX_TX_FEE);
Expand Down

0 comments on commit 2e1cc88

Please sign in to comment.