diff --git a/hdkey.js b/hdkey.js index 3fa830e..ac95fdb 100644 --- a/hdkey.js +++ b/hdkey.js @@ -22,9 +22,8 @@ EthereumHDKey.fromExtendedKey = function (base58key) { } EthereumHDKey.prototype.privateExtendedKey = function () { - // FIXME: change this according to the outcome of https://github.com/cryptocoinjs/hdkey/issues/7 - if (!this._hdkey._privateKey) { - throw new Error('Private key is not available') + if (!this._hdkey.privateExtendedKey) { + throw new Error('This is a public key only wallet') } return this._hdkey.privateExtendedKey } diff --git a/package.json b/package.json index 6993757..2877eab 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "aes-js": "^3.1.0", "bs58check": "^2.1.1", "ethereumjs-util": "^5.1.4", - "hdkey": "^0.7.0", + "hdkey": "^0.8.0", "safe-buffer": "^5.1.1", "scrypt.js": "^0.2.0", "utf8": "^3.0.0", diff --git a/test/hdkey.js b/test/hdkey.js index 1d7645a..f33eab9 100644 --- a/test/hdkey.js +++ b/test/hdkey.js @@ -32,7 +32,7 @@ describe('.fromExtendedKey()', function () { assert.equal(hdnode.publicExtendedKey(), 'xpub661MyMwAqRbcGout4B6s29b6gGQsowyoiF6UgXBEr7eFCWYfXuZDvRxP9zEh1Kwq3TLqDQMbkbaRpSnoC28oWvjLeshoQz1StZ9YHM1EpcJ') assert.throws(function () { hdnode.privateExtendedKey() - }, /^Error: Private key is not available$/) + }, /^Error: This is a public key only wallet$/) }) it('should work with private', function () { var hdnode = HDKey.fromExtendedKey('xprv9s21ZrQH143K4KqQx9Zrf1eN8EaPQVFxM2Ast8mdHn7GKiDWzNEyNdduJhWXToy8MpkGcKjxeFWd8oBSvsz4PCYamxR7TX49pSpp3bmHVAY')