Browse Source

replace missing and unsupported flags with output.valid, similar to each loops below

activeAddress
Gregg Zigler 10 years ago
parent
commit
f324fd80cd
  1. 24
      lib/server.js

24
lib/server.js

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

Loading…
Cancel
Save