X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git;a=blobdiff_plain;f=src%2Fjs%2Findex.js;h=13c61780931f03282c99d043e76d7231af7fbc0f;hp=45edea8477b835245c3a03b34183310f226ebbc3;hb=0a1f0259d1cfe5217ca9c08f7fbd371a03703594;hpb=ba3cb9ecae2667e98af71f5b38a862ba604e8e1c 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 @@ } function calcBip32ExtendedKey(path) { + // Check there's a root key to derive from + if (!bip32RootKey) { + return bip32RootKey; + } var extendedKey = bip32RootKey; // Derive the key from the path var pathBits = path.split("/"); @@ -458,6 +462,10 @@ } } } + // Check root key exists or else derivation path is useless! + if (!bip32RootKey) { + return "No root key"; + } // Check no hardened derivation path when using xpub keys var hardened = path.indexOf("'") > -1; var isXpubkey = !("privKey" in bip32RootKey);