X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FBIP39.git;a=blobdiff_plain;f=bip39-standalone.html;h=367d9a2fdc1d923728b3cf88e45a1c2f18a0f0c6;hp=0f7d7d08a10bf2759a9683bd2623cf69141908d4;hb=ba3cb9ecae2667e98af71f5b38a862ba604e8e1c;hpb=52da415f0385a6a89070498d14259aed980f989b diff --git a/bip39-standalone.html b/bip39-standalone.html index 0f7d7d0..367d9a2 100644 --- a/bip39-standalone.html +++ b/bip39-standalone.html @@ -18868,11 +18868,11 @@ window.Entropy = new (function() { // Calculate and display calcBip32RootKeyFromBase58(rootKeyBase58); calcForDerivationPath(); - hidePending(); } function calcForDerivationPath() { showPending(); + clearAddressesList(); hideValidationError(); // Get the derivation path var derivationPath = getDerivationPath(); @@ -18974,7 +18974,12 @@ window.Entropy = new (function() { continue; } var hardened = bit[bit.length-1] == "'"; - if (hardened) { + var isPriv = "privKey" in extendedKey; + var invalidDerivationPath = hardened && !isPriv; + if (invalidDerivationPath) { + extendedKey = null; + } + else if (hardened) { extendedKey = extendedKey.deriveHardened(index); } else { @@ -19093,6 +19098,12 @@ window.Entropy = new (function() { } } } + // Check no hardened derivation path when using xpub keys + var hardened = path.indexOf("'") > -1; + var isXpubkey = !("privKey" in bip32RootKey); + if (hardened && isXpubkey) { + return "Hardened derivation path is invalid with xpub key"; + } return false; } @@ -19119,7 +19130,11 @@ window.Entropy = new (function() { DOM.seed.val(seed); var rootKey = bip32RootKey.toBase58(); DOM.rootKey.val(rootKey); - var extendedPrivKey = bip32ExtendedKey.toBase58(); + var xprvkeyB58 = "NA"; + if (bip32ExtendedKey.privKey) { + xprvkeyB58 = bip32ExtendedKey.toBase58(); + } + var extendedPrivKey = xprvkeyB58; DOM.extendedPrivKey.val(extendedPrivKey); var extendedPubKey = bip32ExtendedKey.toBase58(false); DOM.extendedPubKey.val(extendedPubKey); @@ -19153,7 +19168,10 @@ window.Entropy = new (function() { key = bip32ExtendedKey.derive(index); } var address = key.getAddress().toString(); - var privkey = key.privKey.toWIF(network); + var privkey = "NA"; + if (key.privKey) { + privkey = key.privKey.toWIF(network); + } var pubkey = key.pubKey.toHex(); var indexText = getDerivationPath() + "/" + index; if (useHardenedAddresses) {