From b6ec5eba8534ce6cf0a4aba55e8f20c3bd1d9976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoshi=20J=C3=A4ger?= Date: Wed, 27 Apr 2022 13:58:21 +0200 Subject: [PATCH] Fix key derivation when path is given as string --- packages/bitcore-lib/lib/hdprivatekey.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/bitcore-lib/lib/hdprivatekey.js b/packages/bitcore-lib/lib/hdprivatekey.js index 8fc3f6c6654..9c57309ee6e 100644 --- a/packages/bitcore-lib/lib/hdprivatekey.js +++ b/packages/bitcore-lib/lib/hdprivatekey.js @@ -74,7 +74,9 @@ function HDPrivateKey(arg) { HDPrivateKey.isValidPath = function(arg, hardened) { if (_.isString(arg)) { var indexes = HDPrivateKey._getDerivationIndexes(arg); - return indexes !== null && _.every(indexes, HDPrivateKey.isValidPath); + return indexes !== null && _.every(indexes, function (index) { + return HDPrivateKey.isValidPath(index, hardened); + }); } if (_.isNumber(arg)) { @@ -116,7 +118,7 @@ HDPrivateKey._getDerivationIndexes = function(path) { return NaN; } var index = +step; // cast to number - if (isHardened) { + if (index < HDPrivateKey.Hardened && isHardened === true) { index += HDPrivateKey.Hardened; }