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).
This commit is contained in:
Karel Bilek 2016-02-13 15:51:42 +01:00
parent 755eac5bbd
commit 182698f53d

View file

@ -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)