]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Show error when using xpub with hardened addresses
authorIan Coleman <coleman.ian@gmail.com>
Wed, 23 Aug 2017 23:25:26 +0000 (09:25 +1000)
committerIan Coleman <coleman.ian@gmail.com>
Wed, 23 Aug 2017 23:37:21 +0000 (09:37 +1000)
src/js/index.js
tests.js

index 3a5a0ef3fecc7f4d804bc84bc118832c28f20527..d9d5db39739986e03af718d970e4de0fc882a01a 100644 (file)
             return "No root key";
         }
         // Check no hardened derivation path when using xpub keys
-        var hardened = path.indexOf("'") > -1;
+        var hardenedPath = path.indexOf("'") > -1;
+        var hardenedAddresses = bip32TabSelected() && DOM.hardenedAddresses.prop("checked");
+        var hardened = hardenedPath || hardenedAddresses;
         var isXpubkey = bip32RootKey.isNeutered();
         if (hardened && isXpubkey) {
             return "Hardened derivation path is invalid with xpub key";
index 1cf5b2204d573bf891095cceaa57f4eb0f83b48d..316a817e594d9cc38dcc595f2c8d9ef3b7ef7c6f 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -4185,6 +4185,37 @@ page.open(url, function(status) {
 });
 },
 
+// Github issue 95
+// error trying to generate addresses from xpub with hardened derivation
+function() {
+page.open(url, function(status) {
+    // set the phrase
+    page.evaluate(function() {
+        // Use bip32 tab with hardened addresses
+        $(".hardened-addresses").prop("checked", true);
+        $("#bip32-tab a").click();
+        // set xpub for account 0 of bip44 for 'abandon abandon ability'
+        var bip44AccountXpub = "xpub6CzDCPbtLrrn4VpVbyyQLHbdSMpZoHN4iuW64VswCyEpfjM2mJGdaHJ2DyuZwtst96E16VvcERb8BBeJdHSCVmAq9RhtRQg6eAZFrTKCNqf";
+        $("#root-key").val(bip44AccountXpub);
+        $("#root-key").trigger("input");
+    });
+    waitForFeedback(function() {
+        // check the error message shows
+        var expected = "Hardened derivation path is invalid with xpub key";
+        var actual = page.evaluate(function() {
+            return $(".feedback").text();
+        });
+        if (actual != expected) {
+            console.log("xpub key with hardened addresses does not show feedback");
+            console.log("Expected: " + expected);
+            console.log("Actual: " + actual);
+            fail();
+        }
+        next();
+    });
+});
+},
+
 // If you wish to add more tests, do so here...
 
 // Here is a blank test template