|
|
@ -483,9 +483,35 @@ API.prototype.import = function(str, cb) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
*/ |
|
|
|
|
|
|
|
API.prototype.parseTxProposals = function(txps, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
this._loadAndCheck(function(err, data) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
_processTxps(txps, data.sharedEncryptingKey); |
|
|
|
|
|
|
|
var fake = _.any(txps, function(txp) { |
|
|
|
return (!Verifier.checkTxProposal(data, txp)); |
|
|
|
}); |
|
|
|
|
|
|
|
if (fake) |
|
|
|
return cb(new ServerCompromisedError('Server sent fake transaction proposal')); |
|
|
|
|
|
|
|
return cb(null, txps); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* opts.doNotVerify |
|
|
|
* opts.getRawTxps |
|
|
|
* @return {undefined} |
|
|
|
*/ |
|
|
|
|
|
|
@ -498,6 +524,10 @@ API.prototype.getTxProposals = function(opts, cb) { |
|
|
|
self._doGetRequest(url, data, function(err, txps) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
var rawTxps; |
|
|
|
if (opts.getRawTxps) |
|
|
|
rawTxps = JSON.parse(JSON.stringify(txps)); |
|
|
|
|
|
|
|
_processTxps(txps, data.sharedEncryptingKey); |
|
|
|
|
|
|
|
var fake = _.any(txps, function(txp) { |
|
|
@ -507,7 +537,7 @@ API.prototype.getTxProposals = function(opts, cb) { |
|
|
|
if (fake) |
|
|
|
return cb(new ServerCompromisedError('Server sent fake transaction proposal')); |
|
|
|
|
|
|
|
return cb(null, txps); |
|
|
|
return cb(null, txps, rawTxps); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|