diff --git a/lib/expressapp.js b/lib/expressapp.js index e44e26a..bb73d52 100644 --- a/lib/expressapp.js +++ b/lib/expressapp.js @@ -134,6 +134,17 @@ ExpressApp.start = function(opts) { }); }); + + router.put('/v1/copayers', function(req, res) { + getServerWithAuth(req, res, function(server) { + server.replaceTemporaryRequestKey(req.body, function(err, result) { + if (err) return returnError(err, res, req); + res.json(result); + }); + }); + }); + + router.get('/v1/wallets/', function(req, res) { getServerWithAuth(req, res, function(server) { var result = {}; diff --git a/lib/model/wallet.js b/lib/model/wallet.js index 51ed4e2..3439321 100644 --- a/lib/model/wallet.js +++ b/lib/model/wallet.js @@ -96,7 +96,7 @@ Wallet.prototype.addCopayer = function(copayer) { this.status = 'complete'; this.publicKeyRing = _.map(this.copayers, function(copayer) { - return _.pick(copayer, ['xPubKey', 'requestPubKey']); + return _.pick(copayer, ['xPubKey', 'requestPubKey', 'isTemporaryRequestKey']); }); }; @@ -113,7 +113,7 @@ Wallet.prototype.updateCopayerRequestKey = function(copayerId, requestPubKey) { c.requestPubKey = requestPubKey; c.isTemporaryRequestKey = false; this.publicKeyRing = _.map(this.copayers, function(copayer) { - return _.pick(copayer, ['xPubKey', 'requestPubKey']); + return _.pick(copayer, ['xPubKey', 'requestPubKey', 'isTemporaryRequestKey']); }); }; diff --git a/lib/server.js b/lib/server.js index 3ec2e3f..61ca69d 100644 --- a/lib/server.js +++ b/lib/server.js @@ -79,7 +79,6 @@ WalletService.getInstanceWithAuth = function(opts, cb) { if (!copayer) return cb(new ClientError('NOTAUTHORIZED', 'Copayer not found')); var isValid = server._verifySignature(opts.message, opts.signature, copayer.requestPubKey); - if (!isValid) return cb(new ClientError('NOTAUTHORIZED', 'Invalid signature')); @@ -219,8 +218,8 @@ WalletService.prototype.replaceTemporaryRequestKey = function(opts, cb) { self._notify('CopayerUpdated', { walletId: opts.walletId, - copayerId: copayer.id, - copayerName: copayer.name, + copayerId: self.copayerId, + copayerName: opts.name, }); return cb(null, {