fix signature
This commit is contained in:
parent
18252b2cae
commit
681b8e0bf6
4
app.js
4
app.js
|
@ -77,10 +77,9 @@ function getServerWithAuth(req, res, cb) {
|
||||||
var credentials = getCredentials(req);
|
var credentials = getCredentials(req);
|
||||||
var auth = {
|
var auth = {
|
||||||
copayerId: credentials.copayerId,
|
copayerId: credentials.copayerId,
|
||||||
message: req.url + req.body ? '|' + JSON.stringify(req.body) : '',
|
message: req.url + '|' + JSON.stringify(req.body),
|
||||||
signature: credentials.signature,
|
signature: credentials.signature,
|
||||||
};
|
};
|
||||||
|
|
||||||
CopayServer.getInstanceWithAuth(auth, function(err, server) {
|
CopayServer.getInstanceWithAuth(auth, function(err, server) {
|
||||||
if (err) return returnError(err, res);
|
if (err) return returnError(err, res);
|
||||||
return cb(server);
|
return cb(server);
|
||||||
|
@ -110,7 +109,6 @@ router.post('/v1/wallets/:id/copayers/', function(req, res) {
|
||||||
|
|
||||||
router.get('/v1/wallets/', function(req, res) {
|
router.get('/v1/wallets/', function(req, res) {
|
||||||
getServerWithAuth(req, res, function(server) {
|
getServerWithAuth(req, res, function(server) {
|
||||||
if (err) return returnError(err, res);
|
|
||||||
server.getWallet({}, function(err, wallet) {
|
server.getWallet({}, function(err, wallet) {
|
||||||
if (err) returnError(err, res);
|
if (err) returnError(err, res);
|
||||||
res.json(wallet);
|
res.json(wallet);
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{"xPrivKey":"xprv9s21ZrQH143K2uyafhWe3R9ZTTmQUyteFd6QGAFbHZTwBS8DeF8f1a6rYDKewR1JJzdWDJcvGZek4yD6rVmSDUjKGY475TGueeo3PQpupCS","m":1,"secret":"182bd4b9-1a2c-4d6d-8a23-f24b57c4fe31|3a7f5a37738bcb397bf23f9c3ee73463c0dac9269ead6bfb31f6fae7a7abc1bd","copayerId":"d9942e96-47c1-49a2-85ad-3543cff84fa6","signingPrivKey":"xpub6AUPGinc75EWpFQGjYMbAUaGGZZYTU2zEZJiyEYtKWb6oVY3DZV8WTstpWarRXXshABeo8G2azn35MfBZCM9dMerg4JhtMi1RTE1hQCMKgq","n":1,"publicKeyRing":["xpub661MyMwAqRbcFQ43mj3eQZ6J1VbttScVcr214YfCqtzv4ETNBnSuZNRLPUcFopCszn5UhYC4PYpqmz2mZEeGb5yL2jcFeDdGEVKMY4jZk16"]}
|
|
@ -29,9 +29,7 @@ function _parseError(body) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function _signRequest(url, args, privKey) {
|
function _signRequest(url, args, privKey) {
|
||||||
var message = url + (args ? '|' + JSON.stringify(args) : '');
|
var message = url + '|' + JSON.stringify(args);
|
||||||
console.log('[clilib.js.32:message:]',message); //TODO
|
|
||||||
console.log('[clilib.js.34:privKey:]',privKey); //TODO
|
|
||||||
return SignUtils.sign(message, privKey);
|
return SignUtils.sign(message, privKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,7 +45,7 @@ function CliLib(opts) {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CliLib.prototype._save = function (data) {
|
CliLib.prototype._save = function(data) {
|
||||||
fs.writeFileSync(this.filename, JSON.stringify(data));
|
fs.writeFileSync(this.filename, JSON.stringify(data));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -96,7 +94,7 @@ CliLib.prototype.createWallet = function(walletName, copayerName, m, n, network,
|
||||||
|
|
||||||
request({
|
request({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: _getUrl('v1/wallets'),
|
url: _getUrl('/v1/wallets/'),
|
||||||
body: args,
|
body: args,
|
||||||
json: true,
|
json: true,
|
||||||
}, function(err, res, body) {
|
}, function(err, res, body) {
|
||||||
|
@ -142,7 +140,7 @@ CliLib.prototype._joinWallet = function(data, secret, copayerName, cb) {
|
||||||
|
|
||||||
request({
|
request({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: _getUrl('v1/wallets/' + walletId + '/copayers'),
|
url: _getUrl('/v1/wallets/' + walletId + '/copayers'),
|
||||||
body: args,
|
body: args,
|
||||||
json: true,
|
json: true,
|
||||||
}, function(err, res, body) {
|
}, function(err, res, body) {
|
||||||
|
@ -181,10 +179,10 @@ CliLib.prototype.status = function(cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var data = this._loadAndCheck();
|
var data = this._loadAndCheck();
|
||||||
console.log('[clilib.js.180:data:]',data); //TODO
|
console.log('[clilib.js.180:data:]', data); //TODO
|
||||||
|
|
||||||
var url = 'v1/wallets/';
|
var url = '/v1/wallets/';
|
||||||
var signature = _signRequest(url, null, data.signingPrivKey);
|
var signature = _signRequest(url, {}, data.signingPrivKey);
|
||||||
|
|
||||||
request({
|
request({
|
||||||
headers: {
|
headers: {
|
||||||
|
|
Loading…
Reference in New Issue