Browse Source

change copayerId to use sjcl sha256 over xpub

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

4
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;
});

4
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) {

Loading…
Cancel
Save