|
|
@ -836,19 +836,25 @@ WalletService.prototype.createTx = function(opts, cb) { |
|
|
|
if (opts.type == Model.TxProposal.Types.MULTIPLEOUTPUTS) { |
|
|
|
if (!Utils.checkRequired(opts, ['outputs'])) |
|
|
|
return cb(new ClientError('Required argument missing')); |
|
|
|
var missing = false, unsupported = false; |
|
|
|
_.each(opts.outputs, function(o) { |
|
|
|
if (!Utils.checkRequired(o, ['toAddress', 'amount'])) |
|
|
|
missing = true; |
|
|
|
o.valid = true; |
|
|
|
if (!Utils.checkRequired(o, ['toAddress', 'amount'])) { |
|
|
|
o.valid = false; |
|
|
|
cb(new ClientError('Required outputs argument missing')); |
|
|
|
return false; |
|
|
|
} |
|
|
|
_.each(_.keys(o), function(key) { |
|
|
|
if (!_.contains(['toAddress', 'amount', 'message'], key)) |
|
|
|
unsupported = true; |
|
|
|
if (!_.contains(['toAddress', 'amount', 'message', 'valid'], key)) { |
|
|
|
o.valid = false; |
|
|
|
cb(new ClientError('Invalid outputs argument found')); |
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
if (!o.valid) return false; |
|
|
|
}); |
|
|
|
if (missing) |
|
|
|
return cb(new ClientError('Required outputs argument missing')); |
|
|
|
if (unsupported) |
|
|
|
return cb(new ClientError('Invalid outputs argument found')); |
|
|
|
if (_.any(opts.outputs, 'valid', false)) return; |
|
|
|
_.each(opts.outputs, function(o) { delete o.valid; }); |
|
|
|
|
|
|
|
} else { |
|
|
|
if (!Utils.checkRequired(opts, ['toAddress', 'amount'])) |
|
|
|
return cb(new ClientError('Required argument missing')); |
|
|
|