From 6bead5dc30a09fd330159196546a011985d4a31b Mon Sep 17 00:00:00 2001 From: junderw Date: Sat, 6 Apr 2019 09:03:21 +0900 Subject: [PATCH] Fix rmd160 issue in Electron v4 without using crypto --- package-lock.json | 6 +++--- package.json | 2 +- src/crypto.js | 17 +++++------------ 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7919044..d0c759f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -148,9 +148,9 @@ "integrity": "sha512-i47mqjF9UbjxJhxGf+pZ6kSxrnI3wBLlnGI2ArWJ4r0VrvDS7ZYXkprq/pLaBWYq4GM0r4zdHY+NNRqEMU7uew==" }, "bip32": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/bip32/-/bip32-1.0.3.tgz", - "integrity": "sha512-rY7ie/4Nmcpgx1y4kAsJJLiluGzNzz20u44LFaElLXCGq3hQjfHV11r9fHwbtquKZ4JXL7BEMCnmpCzFko4ZLA==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/bip32/-/bip32-1.0.4.tgz", + "integrity": "sha512-8T21eLWylZETolyqCPgia+MNp+kY37zFr7PTFDTPObHeNi9JlfG4qGIh8WzerIJidtwoK+NsWq2I5i66YfHoIw==", "requires": { "bs58check": "^2.1.1", "create-hash": "^1.2.0", diff --git a/package.json b/package.json index 34ece33..5eb7b0f 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ ], "dependencies": { "bech32": "^1.1.2", - "bip32": "^1.0.3", + "bip32": "^1.0.4", "bip66": "^1.1.0", "bitcoin-ops": "^1.4.0", "bs58check": "^2.0.0", diff --git a/src/crypto.js b/src/crypto.js index 604cd0c..f2109bd 100644 --- a/src/crypto.js +++ b/src/crypto.js @@ -1,18 +1,11 @@ const createHash = require('create-hash') -let rmd160 -try { - rmd160 = require('crypto') - .getHashes() - .includes('rmd160') - ? 'rmd160' - : 'ripemd160' -} catch (err) { - rmd160 = 'rmd160' -} - function ripemd160 (buffer) { - return createHash(rmd160).update(buffer).digest() + try { + return createHash('rmd160').update(buffer).digest() + } catch (err) { + return createHash('ripemd160').update(buffer).digest() + } } function sha1 (buffer) {