UnspentOutput: Fix issue when 0 being feed as amount

This commit is contained in:
Esteban Ordano 2015-02-05 11:58:00 -03:00
parent 7d20aadf37
commit 4f1e13a686
1 changed files with 2 additions and 2 deletions

View File

@ -41,9 +41,9 @@ function UnspentOutput(data) {
if (!_.isNumber(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);
$.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;
$.checkArgument(_.isNumber(amount), 'Amount must be a number');
JSUtil.defineImmutable(this, {