diff options
author | Ian Coleman <coleman.ian@gmail.com> | 2017-08-16 10:43:09 +1000 |
---|---|---|
committer | Ian Coleman <coleman.ian@gmail.com> | 2017-08-16 10:43:09 +1000 |
commit | ed6d9d3905aa581f1a76d37d601c6be39954d1ff (patch) | |
tree | adb9b239acf04ff3011af37161e616ad1e25be5c | |
parent | 47b64d3ee12f475fc939b9fbfc3f7ae2578ea2e1 (diff) | |
download | BIP39-ed6d9d3905aa581f1a76d37d601c6be39954d1ff.tar.gz BIP39-ed6d9d3905aa581f1a76d37d601c6be39954d1ff.tar.zst BIP39-ed6d9d3905aa581f1a76d37d601c6be39954d1ff.zip |
Clear old seed when mnemonic is changed
-rw-r--r-- | src/js/index.js | 4 | ||||
-rw-r--r-- | tests.js | 35 |
2 files changed, 39 insertions, 0 deletions
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 @@ | |||
175 | 175 | ||
176 | function delayedPhraseChanged() { | 176 | function delayedPhraseChanged() { |
177 | hideValidationError(); | 177 | hideValidationError(); |
178 | seed = null; | ||
179 | bip32RootKey = null; | ||
180 | bip32ExtendedKey = null; | ||
181 | clearAddressesList(); | ||
178 | showPending(); | 182 | showPending(); |
179 | if (phraseChangeTimeoutEvent != null) { | 183 | if (phraseChangeTimeoutEvent != null) { |
180 | clearTimeout(phraseChangeTimeoutEvent); | 184 | clearTimeout(phraseChangeTimeoutEvent); |
@@ -4120,6 +4120,41 @@ page.open(url, function(status) { | |||
4120 | }); | 4120 | }); |
4121 | }, | 4121 | }, |
4122 | 4122 | ||
4123 | // github issue 43 | ||
4124 | // Cleared mnemonic and root key still allows addresses to be generated | ||
4125 | // https://github.com/iancoleman/bip39/issues/43 | ||
4126 | function() { | ||
4127 | page.open(url, function(status) { | ||
4128 | // set the phrase | ||
4129 | page.evaluate(function() { | ||
4130 | $("#bip49-tab a").click(); | ||
4131 | $(".phrase").val("abandon abandon ability"); | ||
4132 | $(".phrase").trigger("input"); | ||
4133 | }); | ||
4134 | waitForGenerate(function() { | ||
4135 | // clear the mnemonic and root key | ||
4136 | page.evaluate(function() { | ||
4137 | $(".phrase").val(""); | ||
4138 | $(".phrase").trigger("input"); | ||
4139 | $(".root-key").val(""); | ||
4140 | $(".root-key").trigger("input"); | ||
4141 | $(".more").click(); | ||
4142 | }); | ||
4143 | waitForFeedback(function() { | ||
4144 | // check there are no addresses shown | ||
4145 | var addressCount = page.evaluate(function() { | ||
4146 | return $(".address").length; | ||
4147 | }); | ||
4148 | if (addressCount != 0) { | ||
4149 | console.log("Clearing mnemonic should not allow addresses to be generated"); | ||
4150 | fail(); | ||
4151 | } | ||
4152 | next(); | ||
4153 | }); | ||
4154 | }); | ||
4155 | }); | ||
4156 | }, | ||
4157 | |||
4123 | // If you wish to add more tests, do so here... | 4158 | // If you wish to add more tests, do so here... |
4124 | 4159 | ||
4125 | // Here is a blank test template | 4160 | // Here is a blank test template |