From 208bc0203babcc58e3d645b8e8a628c5f30a727b Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Thu, 19 Feb 2015 12:25:10 -0300 Subject: [PATCH] change copayerId to use sjcl sha256 over xpub --- lib/server.js | 4 ++-- lib/walletutils.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/server.js b/lib/server.js index b810797..373f96f 100644 --- a/lib/server.js +++ b/lib/server.js @@ -222,7 +222,7 @@ CopayServer.prototype.joinWallet = function(opts, cb) { self.storage.fetchCopayerLookup(copayer.id, function(err, res) { if (err) return cb(err); 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); self.storage.storeWalletAndUpdateCopayersLookup(wallet, function(err) { @@ -378,7 +378,7 @@ CopayServer.prototype._getUtxos = function(cb) { // Needed for the clients to sign UTXOs _.each(utxos, function(utxo) { utxo.satoshis = utxo.satoshis ? +utxo.satoshis : Utils.strip(utxo.amount * 1e8); - delete utxo.amount; + delete utxo.amount; utxo.path = addressToPath[utxo.address].path; utxo.publicKeys = addressToPath[utxo.address].publicKeys; }); diff --git a/lib/walletutils.js b/lib/walletutils.js index aa9a465..e150e4b 100644 --- a/lib/walletutils.js +++ b/lib/walletutils.js @@ -61,8 +61,8 @@ WalletUtils.getProposalHash = function(toAddress, amount, message) { }; WalletUtils.xPubToCopayerId = function(xpub) { - //return (new Bitcore.HDPublicKey(xpub)).derive(HDPath.IdBranch).publicKey.toString(); - return crypto.Hash.sha256(new Buffer(xpub)).toString('hex'); + var hash = sjcl.hash.sha256.hash(xpub); + return sjcl.codec.hex.fromBits(hash); }; WalletUtils.toSecret = function(walletId, walletPrivKey, network) {