diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2017-08-24 09:25:26 +1000 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2017-08-24 09:37:21 +1000 |
commit | b18eb97ae367e7eaa276a8ddbaaca3e158cf153d (patch) | |
tree | 0e83bbc1238bf04be067991ce2b922b658fc6548 | |
parent | 88ea3e40eeed3b297899041dc590ca80c6a8b90a (diff) | |
download | BIP39-b18eb97ae367e7eaa276a8ddbaaca3e158cf153d.tar.gz BIP39-b18eb97ae367e7eaa276a8ddbaaca3e158cf153d.tar.zst BIP39-b18eb97ae367e7eaa276a8ddbaaca3e158cf153d.zip |
Show error when using xpub with hardened addresses
-rw-r--r-- | src/js/index.js | 4 | ||||
-rw-r--r-- | tests.js | 31 |
2 files changed, 34 insertions, 1 deletions
diff --git a/src/js/index.js b/src/js/index.js index 3a5a0ef..d9d5db3 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -532,7 +532,9 @@ | |||
532 | return "No root key"; | 532 | return "No root key"; |
533 | } | 533 | } |
534 | // Check no hardened derivation path when using xpub keys | 534 | // Check no hardened derivation path when using xpub keys |
535 | var hardened = path.indexOf("'") > -1; | 535 | var hardenedPath = path.indexOf("'") > -1; |
536 | var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked"); | ||
537 | var hardened = hardenedPath || hardenedAddresses; | ||
536 | var isXpubkey = bip32RootKey.isNeutered(); | 538 | var isXpubkey = bip32RootKey.isNeutered(); |
537 | if (hardened && isXpubkey) { | 539 | if (hardened && isXpubkey) { |
538 | return "Hardened derivation path is invalid with xpub key"; | 540 | return "Hardened derivation path is invalid with xpub key"; |
@@ -4185,6 +4185,37 @@ page.open(url, function(status) { | |||
4185 | }); | 4185 | }); |
4186 | }, | 4186 | }, |
4187 | 4187 | ||
4188 | // Github issue 95 | ||
4189 | // error trying to generate addresses from xpub with hardened derivation | ||
4190 | function() { | ||
4191 | page.open(url, function(status) { | ||
4192 | // set the phrase | ||
4193 | page.evaluate(function() { | ||
4194 | // Use bip32 tab with hardened addresses | ||
4195 | $(".hardened-addresses").prop("checked", true); | ||
4196 | $("#bip32-tab a").click(); | ||
4197 | // set xpub for account 0 of bip44 for 'abandon abandon ability' | ||
4198 | var bip44AccountXpub = "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf"; | ||
4199 | $("#root-key").val(bip44AccountXpub); | ||
4200 | $("#root-key").trigger("input"); | ||
4201 | }); | ||
4202 | waitForFeedback(function() { | ||
4203 | // check the error message shows | ||
4204 | var expected = "Hardened derivation path is invalid with xpub key"; | ||
4205 | var actual = page.evaluate(function() { | ||
4206 | return $(".feedback").text(); | ||
4207 | }); | ||
4208 | if (actual != expected) { | ||
4209 | console.log("xpub key with hardened addresses does not show feedback"); | ||
4210 | console.log("Expected: " + expected); | ||
4211 | console.log("Actual: " + actual); | ||
4212 | fail(); | ||
4213 | } | ||
4214 | next(); | ||
4215 | }); | ||
4216 | }); | ||
4217 | }, | ||
4218 | |||
4188 | // If you wish to add more tests, do so here... | 4219 | // If you wish to add more tests, do so here... |
4189 | 4220 | ||
4190 | // Here is a blank test template | 4221 | // Here is a blank test template |