throw error if deriving an invalid path string
...the path consists "m", numbers, /, and ' characters
This commit is contained in:
parent
134952d1f8
commit
efbebb3528
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue