]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/BIP39.git/commitdiff
Clear old seed when mnemonic is changed
authorIan Coleman <coleman.ian@gmail.com>
Wed, 16 Aug 2017 00:43:09 +0000 (10:43 +1000)
committerIan Coleman <coleman.ian@gmail.com>
Wed, 16 Aug 2017 00:43:09 +0000 (10:43 +1000)
src/js/index.js
tests.js

index 1f37d38f9795acf5bdf898bf4f4f0d57807e04a3..2e14a40be720ef8a0fe79dd09251790a2fcd72e3 100644 (file)
 
     function delayedPhraseChanged() {
         hideValidationError();
+        seed = null;
+        bip32RootKey = null;
+        bip32ExtendedKey = null;
+        clearAddressesList();
         showPending();
         if (phraseChangeTimeoutEvent != null) {
             clearTimeout(phraseChangeTimeoutEvent);
index dea908bec26429fc562986683e2a45685b91bdd3..464a15dde87c535bce9b061aaf82419a07ae1062 100644 (file)
--- a/tests.js
+++ b/tests.js
@@ -4120,6 +4120,41 @@ page.open(url, function(status) {
 });
 },
 
+// github issue 43
+// Cleared mnemonic and root key still allows addresses to be generated
+// https://github.com/iancoleman/bip39/issues/43
+function() {
+page.open(url, function(status) {
+    // set the phrase
+    page.evaluate(function() {
+        $("#bip49-tab a").click();
+        $(".phrase").val("abandon abandon ability");
+        $(".phrase").trigger("input");
+    });
+    waitForGenerate(function() {
+        // clear the mnemonic and root key
+        page.evaluate(function() {
+            $(".phrase").val("");
+            $(".phrase").trigger("input");
+            $(".root-key").val("");
+            $(".root-key").trigger("input");
+            $(".more").click();
+        });
+        waitForFeedback(function() {
+            // check there are no addresses shown
+            var addressCount = page.evaluate(function() {
+                return $(".address").length;
+            });
+            if (addressCount != 0) {
+                console.log("Clearing mnemonic should not allow addresses to be generated");
+                fail();
+            }
+            next();
+        });
+    });
+});
+},
+
 // If you wish to add more tests, do so here...
 
 // Here is a blank test template