From 182698f53dc80bc73dc53590ed48aa4b21acdcf4 Mon Sep 17 00:00:00 2001 From: Karel Bilek Date: Sat, 13 Feb 2016 15:51:42 +0100 Subject: [PATCH] Using parseInt instead of + in path parsing + can cause issues - +"" is 0. parseInt("", 10) is NaN, which is better (since it causes typeforce to throw). --- src/hdnode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hdnode.js b/src/hdnode.js index a18fb98..198fe96 100644 --- a/src/hdnode.js +++ b/src/hdnode.js @@ -306,10 +306,10 @@ HDNode.prototype.derivePath = function (path) { return splitPath.reduce(function (prevHd, indexStr) { var index if (indexStr.slice(-1) === "'") { - index = +(indexStr.slice(0, -1)) + index = parseInt(indexStr.slice(0, -1), 10) return prevHd.deriveHardened(index) } else { - index = +indexStr + index = parseInt(indexStr, 10) return prevHd.derive(index) } }, this)