From ed6d9d3905aa581f1a76d37d601c6be39954d1ff Mon Sep 17 00:00:00 2001 From: Ian Coleman Date: Wed, 16 Aug 2017 10:43:09 +1000 Subject: Clear old seed when mnemonic is changed --- src/js/index.js | 4 ++++ tests.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/js/index.js b/src/js/index.js index 1f37d38..2e14a40 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -175,6 +175,10 @@ function delayedPhraseChanged() { hideValidationError(); + seed = null; + bip32RootKey = null; + bip32ExtendedKey = null; + clearAddressesList(); showPending(); if (phraseChangeTimeoutEvent != null) { clearTimeout(phraseChangeTimeoutEvent); diff --git a/tests.js b/tests.js index dea908b..464a15d 100644 --- 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 -- cgit v1.2.3