handle invalid xpub on wallet join

This commit is contained in:
Ivan Socolsky 2015-12-01 11:25:59 -03:00
parent 8f8d2f511f
commit 98773fe40a
2 changed files with 23 additions and 2 deletions

View File

@ -567,6 +567,12 @@ WalletService.prototype.joinWallet = function(opts, cb) {
if (_.isEmpty(opts.name))
return cb(new ClientError('Invalid copayer name'));
try {
Bitcore.HDPublicKey(opts.xPubKey);
} catch (ex) {
return cb(new ClientError('Invalid extended public key'));
}
opts.supportBIP44AndP2PKH = _.isBoolean(opts.supportBIP44AndP2PKH) ? opts.supportBIP44AndP2PKH : true;
self.walletId = opts.walletId;

View File

@ -450,6 +450,21 @@ describe('Wallet service', function() {
});
});
it('should fail to join with invalid xPubKey', function(done) {
var copayerOpts = helpers.getSignedCopayerOpts({
walletId: walletId,
name: 'copayer 1',
xPubKey: 'invalid',
requestPubKey: TestData.copayers[0].pubKey_1H_0,
});
server.joinWallet(copayerOpts, function(err, result) {
should.not.exist(result);
should.exist(err);
err.message.should.contain('extended public key');
done();
});
});
it('should fail to join with null signature', function(done) {
var copayerOpts = {
walletId: walletId,