|
@ -18,9 +18,24 @@ var BASE_URL = 'http://localhost:3001/copay/api'; |
|
|
var WALLET_CRITICAL_DATA = ['xPrivKey', 'm', 'publicKeyRing']; |
|
|
var WALLET_CRITICAL_DATA = ['xPrivKey', 'm', 'publicKeyRing']; |
|
|
|
|
|
|
|
|
function _createProposalOpts(opts, signingKey) { |
|
|
function _createProposalOpts(opts, signingKey) { |
|
|
var hash = WalletUtils.getProposalHash(opts.toAddress, opts.amount, opts.message); |
|
|
var args = { |
|
|
opts.proposalSignature = WalletUtils.signMessage(hash, signingKey); |
|
|
toAddress: opts.toAddress, |
|
|
return opts; |
|
|
amount: opts.amount, |
|
|
|
|
|
message: _encryptProposalMessage(opts.message, signingKey), |
|
|
|
|
|
}; |
|
|
|
|
|
var hash = WalletUtils.getProposalHash(args.toAddress, args.amount, args.message); |
|
|
|
|
|
args.proposalSignature = WalletUtils.signMessage(hash, signingKey); |
|
|
|
|
|
return args; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function _encryptProposalMessage(message, encryptingKey) { |
|
|
|
|
|
if (!message) return null; |
|
|
|
|
|
return WalletUtils.encryptMessage(message, encryptingKey); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function _decryptProposalMessage(message, encryptingKey) { |
|
|
|
|
|
if (!message) return ''; |
|
|
|
|
|
return WalletUtils.decryptMessage(message, encryptingKey); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
function _parseError(body) { |
|
|
function _parseError(body) { |
|
@ -392,7 +407,14 @@ API.prototype.getTxProposals = function(opts, cb) { |
|
|
this._loadAndCheck(function(err, data) { |
|
|
this._loadAndCheck(function(err, data) { |
|
|
if (err) return cb(err); |
|
|
if (err) return cb(err); |
|
|
var url = '/v1/txproposals/'; |
|
|
var url = '/v1/txproposals/'; |
|
|
self._doGetRequest(url, data, cb); |
|
|
self._doGetRequest(url, data, function(err, txps) { |
|
|
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
|
|
|
|
_.each(txps, function(txp) { |
|
|
|
|
|
txp.message = self._decryptProposalMessage(txp.message, data.signingPrivKey); |
|
|
|
|
|
}); |
|
|
|
|
|
return cb(null, txps); |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|