|
|
@ -17,17 +17,6 @@ var BASE_URL = 'http://localhost:3001/copay/api'; |
|
|
|
|
|
|
|
var WALLET_CRITICAL_DATA = ['xPrivKey', 'm', 'publicKeyRing']; |
|
|
|
|
|
|
|
function _createProposalOpts(opts, signingKey) { |
|
|
|
var args = { |
|
|
|
toAddress: opts.toAddress, |
|
|
|
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); |
|
|
@ -298,18 +287,31 @@ API.prototype.getStatus = function(cb) { |
|
|
|
/** |
|
|
|
* send |
|
|
|
* |
|
|
|
* @param inArgs |
|
|
|
* @param inArgs.toAddress |
|
|
|
* @param inArgs.amount |
|
|
|
* @param inArgs.message |
|
|
|
* @param opts |
|
|
|
* @param opts.toAddress |
|
|
|
* @param opts.amount |
|
|
|
* @param opts.message |
|
|
|
*/ |
|
|
|
API.prototype.sendTxProposal = function(inArgs, cb) { |
|
|
|
API.prototype.sendTxProposal = function(opts, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
this._loadAndCheck(function(err, data) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
var args = _createProposalOpts(inArgs, data.signingPrivKey); |
|
|
|
var amount; |
|
|
|
try { |
|
|
|
amount = WalletUtils.parseAmount(opts.amount); |
|
|
|
} catch (ex) { |
|
|
|
return cb(ex); |
|
|
|
} |
|
|
|
|
|
|
|
var args = { |
|
|
|
toAddress: opts.toAddress, |
|
|
|
amount: amount, |
|
|
|
message: _encryptProposalMessage(opts.message, data.signingPrivKey), |
|
|
|
}; |
|
|
|
var hash = WalletUtils.getProposalHash(args.toAddress, args.amount, args.message); |
|
|
|
args.proposalSignature = WalletUtils.signMessage(hash, data.signingPrivKey); |
|
|
|
|
|
|
|
var url = '/v1/txproposals/'; |
|
|
|
self._doPostRequest(url, args, data, cb); |
|
|
|