Browse Source

Merge pull request #1038 from eordano/unspent/fixZeroUndefined

UnspentOutput: Fix issue when 0 being feed as amount
patch-2
Manuel Aráoz 10 years ago
parent
commit
2c00c87198
  1. 4
      lib/transaction/unspentoutput.js

4
lib/transaction/unspentoutput.js

@ -41,9 +41,9 @@ function UnspentOutput(data) {
if (!_.isNumber(outputIndex)) { if (!_.isNumber(outputIndex)) {
throw new Error('Invalid outputIndex, received ' + outputIndex); throw new Error('Invalid outputIndex, received ' + outputIndex);
} }
$.checkArgument(data.scriptPubKey || data.script, 'Must provide the scriptPubKey for that output!'); $.checkArgument(!_.isUndefined(data.scriptPubKey || data.script), 'Must provide the scriptPubKey for that output!');
var script = new Script(data.scriptPubKey || data.script); var script = new Script(data.scriptPubKey || data.script);
$.checkArgument(data.amount || data.satoshis, 'Must provide the scriptPubKey for that output!'); $.checkArgument(!_.isUndefined(data.amount || data.satoshis), 'Must provide an amount for the output');
var amount = data.amount ? new Unit.fromBTC(data.amount).toSatoshis() : data.satoshis; var amount = data.amount ? new Unit.fromBTC(data.amount).toSatoshis() : data.satoshis;
$.checkArgument(_.isNumber(amount), 'Amount must be a number'); $.checkArgument(_.isNumber(amount), 'Amount must be a number');
JSUtil.defineImmutable(this, { JSUtil.defineImmutable(this, {

Loading…
Cancel
Save