Browse Source

change copayerId to use sjcl sha256 over xpub

activeAddress
Ivan Socolsky 10 years ago
parent
commit
208bc0203b
  1. 2
      lib/server.js
  2. 4
      lib/walletutils.js

2
lib/server.js

@ -222,7 +222,7 @@ CopayServer.prototype.joinWallet = function(opts, cb) {
self.storage.fetchCopayerLookup(copayer.id, function(err, res) { self.storage.fetchCopayerLookup(copayer.id, function(err, res) {
if (err) return cb(err); if (err) return cb(err);
if (res) if (res)
return cb(new ClientError('CREGISTED', 'Copayer ID already registered on server')); return cb(new ClientError('CREGISTERED', 'Copayer ID already registered on server'));
wallet.addCopayer(copayer); wallet.addCopayer(copayer);
self.storage.storeWalletAndUpdateCopayersLookup(wallet, function(err) { self.storage.storeWalletAndUpdateCopayersLookup(wallet, function(err) {

4
lib/walletutils.js

@ -61,8 +61,8 @@ WalletUtils.getProposalHash = function(toAddress, amount, message) {
}; };
WalletUtils.xPubToCopayerId = function(xpub) { WalletUtils.xPubToCopayerId = function(xpub) {
//return (new Bitcore.HDPublicKey(xpub)).derive(HDPath.IdBranch).publicKey.toString(); var hash = sjcl.hash.sha256.hash(xpub);
return crypto.Hash.sha256(new Buffer(xpub)).toString('hex'); return sjcl.codec.hex.fromBits(hash);
}; };
WalletUtils.toSecret = function(walletId, walletPrivKey, network) { WalletUtils.toSecret = function(walletId, walletPrivKey, network) {

Loading…
Cancel
Save