diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2016-12-19 13:54:51 +1100 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2016-12-19 13:55:21 +1100 |
commit | ba3cb9ecae2667e98af71f5b38a862ba604e8e1c (patch) | |
tree | 380d24d03b7a3e6c7e02592901a62d605b2df61e /bip39-standalone.html | |
parent | 52da415f0385a6a89070498d14259aed980f989b (diff) | |
download | BIP39-ba3cb9ecae2667e98af71f5b38a862ba604e8e1c.tar.gz BIP39-ba3cb9ecae2667e98af71f5b38a862ba604e8e1c.tar.zst BIP39-ba3cb9ecae2667e98af71f5b38a862ba604e8e1c.zip |
xpub key can be used as bip32 root key
Diffstat (limited to 'bip39-standalone.html')
-rw-r--r-- | bip39-standalone.html | 26 |
1 files changed, 22 insertions, 4 deletions
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() { | |||
18868 | // Calculate and display | 18868 | // Calculate and display |
18869 | calcBip32RootKeyFromBase58(rootKeyBase58); | 18869 | calcBip32RootKeyFromBase58(rootKeyBase58); |
18870 | calcForDerivationPath(); | 18870 | calcForDerivationPath(); |
18871 | hidePending(); | ||
18872 | } | 18871 | } |
18873 | 18872 | ||
18874 | function calcForDerivationPath() { | 18873 | function calcForDerivationPath() { |
18875 | showPending(); | 18874 | showPending(); |
18875 | clearAddressesList(); | ||
18876 | hideValidationError(); | 18876 | hideValidationError(); |
18877 | // Get the derivation path | 18877 | // Get the derivation path |
18878 | var derivationPath = getDerivationPath(); | 18878 | var derivationPath = getDerivationPath(); |
@@ -18974,7 +18974,12 @@ window.Entropy = new (function() { | |||
18974 | continue; | 18974 | continue; |
18975 | } | 18975 | } |
18976 | var hardened = bit[bit.length-1] == "'"; | 18976 | var hardened = bit[bit.length-1] == "'"; |
18977 | if (hardened) { | 18977 | var isPriv = "privKey" in extendedKey; |
18978 | var invalidDerivationPath = hardened && !isPriv; | ||
18979 | if (invalidDerivationPath) { | ||
18980 | extendedKey = null; | ||
18981 | } | ||
18982 | else if (hardened) { | ||
18978 | extendedKey = extendedKey.deriveHardened(index); | 18983 | extendedKey = extendedKey.deriveHardened(index); |
18979 | } | 18984 | } |
18980 | else { | 18985 | else { |
@@ -19093,6 +19098,12 @@ window.Entropy = new (function() { | |||
19093 | } | 19098 | } |
19094 | } | 19099 | } |
19095 | } | 19100 | } |
19101 | // Check no hardened derivation path when using xpub keys | ||
19102 | var hardened = path.indexOf("'") > -1; | ||
19103 | var isXpubkey = !("privKey" in bip32RootKey); | ||
19104 | if (hardened && isXpubkey) { | ||
19105 | return "Hardened derivation path is invalid with xpub key"; | ||
19106 | } | ||
19096 | return false; | 19107 | return false; |
19097 | } | 19108 | } |
19098 | 19109 | ||
@@ -19119,7 +19130,11 @@ window.Entropy = new (function() { | |||
19119 | DOM.seed.val(seed); | 19130 | DOM.seed.val(seed); |
19120 | var rootKey = bip32RootKey.toBase58(); | 19131 | var rootKey = bip32RootKey.toBase58(); |
19121 | DOM.rootKey.val(rootKey); | 19132 | DOM.rootKey.val(rootKey); |
19122 | var extendedPrivKey = bip32ExtendedKey.toBase58(); | 19133 | var xprvkeyB58 = "NA"; |
19134 | if (bip32ExtendedKey.privKey) { | ||
19135 | xprvkeyB58 = bip32ExtendedKey.toBase58(); | ||
19136 | } | ||
19137 | var extendedPrivKey = xprvkeyB58; | ||
19123 | DOM.extendedPrivKey.val(extendedPrivKey); | 19138 | DOM.extendedPrivKey.val(extendedPrivKey); |
19124 | var extendedPubKey = bip32ExtendedKey.toBase58(false); | 19139 | var extendedPubKey = bip32ExtendedKey.toBase58(false); |
19125 | DOM.extendedPubKey.val(extendedPubKey); | 19140 | DOM.extendedPubKey.val(extendedPubKey); |
@@ -19153,7 +19168,10 @@ window.Entropy = new (function() { | |||
19153 | key = bip32ExtendedKey.derive(index); | 19168 | key = bip32ExtendedKey.derive(index); |
19154 | } | 19169 | } |
19155 | var address = key.getAddress().toString(); | 19170 | var address = key.getAddress().toString(); |
19156 | var privkey = key.privKey.toWIF(network); | 19171 | var privkey = "NA"; |
19172 | if (key.privKey) { | ||
19173 | privkey = key.privKey.toWIF(network); | ||
19174 | } | ||
19157 | var pubkey = key.pubKey.toHex(); | 19175 | var pubkey = key.pubKey.toHex(); |
19158 | var indexText = getDerivationPath() + "/" + index; | 19176 | var indexText = getDerivationPath() + "/" + index; |
19159 | if (useHardenedAddresses) { | 19177 | if (useHardenedAddresses) { |