diff options
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/index.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/js/index.js b/src/js/index.js index 45edea8..13c6178 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -324,6 +324,10 @@ | |||
324 | } | 324 | } |
325 | 325 | ||
326 | function calcBip32ExtendedKey(path) { | 326 | function calcBip32ExtendedKey(path) { |
327 | // Check there's a root key to derive from | ||
328 | if (!bip32RootKey) { | ||
329 | return bip32RootKey; | ||
330 | } | ||
327 | var extendedKey = bip32RootKey; | 331 | var extendedKey = bip32RootKey; |
328 | // Derive the key from the path | 332 | // Derive the key from the path |
329 | var pathBits = path.split("/"); | 333 | var pathBits = path.split("/"); |
@@ -458,6 +462,10 @@ | |||
458 | } | 462 | } |
459 | } | 463 | } |
460 | } | 464 | } |
465 | // Check root key exists or else derivation path is useless! | ||
466 | if (!bip32RootKey) { | ||
467 | return "No root key"; | ||
468 | } | ||
461 | // Check no hardened derivation path when using xpub keys | 469 | // Check no hardened derivation path when using xpub keys |
462 | var hardened = path.indexOf("'") > -1; | 470 | var hardened = path.indexOf("'") > -1; |
463 | var isXpubkey = !("privKey" in bip32RootKey); | 471 | var isXpubkey = !("privKey" in bip32RootKey); |