Browse Source

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).
hk-custom-address
Karel Bilek 9 years ago
parent
commit
182698f53d
  1. 4
      src/hdnode.js

4
src/hdnode.js

@ -306,10 +306,10 @@ HDNode.prototype.derivePath = function (path) {
return splitPath.reduce(function (prevHd, indexStr) { return splitPath.reduce(function (prevHd, indexStr) {
var index var index
if (indexStr.slice(-1) === "'") { if (indexStr.slice(-1) === "'") {
index = +(indexStr.slice(0, -1)) index = parseInt(indexStr.slice(0, -1), 10)
return prevHd.deriveHardened(index) return prevHd.deriveHardened(index)
} else { } else {
index = +indexStr index = parseInt(indexStr, 10)
return prevHd.derive(index) return prevHd.derive(index)
} }
}, this) }, this)

Loading…
Cancel
Save