diff --git a/lib/bip32.js b/lib/bip32.js index e552269a7..eeb7a15a7 100644 --- a/lib/bip32.js +++ b/lib/bip32.js @@ -215,10 +215,13 @@ BIP32.prototype.derive = function(path) { var c = e[i]; if (i == 0) { - if (c != 'm') throw new Error('invalid path'); + if (c != 'm') throw new Error('bip32: invalid path'); continue; } + if (parseInt(c.replace("'", "")).toString() !== c.replace("'", "")) + throw new Error('bip32: invalid path'); + var usePrivate = (c.length > 1) && (c[c.length - 1] == '\''); var childIndex = parseInt(usePrivate ? c.slice(0, c.length - 1) : c) & 0x7fffffff;