Skip to content

Commit 2e1cc88

Browse files
committed
fix: wrong output value calculation in _buildTx
1 parent 1168824 commit 2e1cc88

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

lib/model/txproposal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ TxProposal.prototype._buildTx = function() {
162162
t.fee(self.fee);
163163

164164
var totalInputs = _.sum(self.inputs, 'satoshis');
165-
var totalOutputs = _.sum(self.outputs, 'satoshis');
165+
var totalOutputs = _.sum(self.outputs, 'amount');
166166

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

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

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

0 commit comments

Comments
 (0)