diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js index 7abea35..a05db2c 100644 --- a/lib/model/txproposal.js +++ b/lib/model/txproposal.js @@ -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); @@ -182,9 +182,10 @@ 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 > 0 && totalOutputs > 0 && totalInputs >= totalOutputs); $.checkState(totalInputs - totalOutputs <= Defaults.MAX_TX_FEE); return t;