From 48866992d41fceebc398a461883e90bb1333265b Mon Sep 17 00:00:00 2001 From: Kirill Fomichev Date: Wed, 24 Feb 2016 13:08:40 +0300 Subject: [PATCH] Update wif to 2.0.1 --- .gitignore | 1 - package.json | 2 +- src/ecpair.js | 7 ++++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 0abc934..62562b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -bitcoin.js coverage node_modules diff --git a/package.json b/package.json index 326207c..b8e37f0 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "ecurve": "^1.0.0", "randombytes": "^2.0.1", "typeforce": "^1.6.2", - "wif": "^1.1.0" + "wif": "^2.0.1" }, "devDependencies": { "async": "^1.5.0", diff --git a/src/ecpair.js b/src/ecpair.js index 17d19e1..a01f363 100644 --- a/src/ecpair.js +++ b/src/ecpair.js @@ -66,11 +66,12 @@ ECPair.fromWIF = function (string, network) { network = network.filter(function (network) { return version === network.wif - }).pop() || {} + }).pop() + if (!network) throw new Error('Invalid network version') } - var decoded = wif.decodeRaw(network.wif, buffer) - var d = BigInteger.fromBuffer(decoded.d) + var decoded = wif.decodeRaw(buffer, network.wif) + var d = BigInteger.fromBuffer(decoded.privateKey) return new ECPair(d, null, { compressed: decoded.compressed,