diff options
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/index.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/js/index.js b/src/js/index.js index d169ed2..3148ca4 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -19,6 +19,7 @@ | |||
19 | var entropyTypeAutoDetect = true; | 19 | var entropyTypeAutoDetect = true; |
20 | var entropyChangeTimeoutEvent = null; | 20 | var entropyChangeTimeoutEvent = null; |
21 | var phraseChangeTimeoutEvent = null; | 21 | var phraseChangeTimeoutEvent = null; |
22 | var seedChangedTimeoutEvent = null; | ||
22 | var rootKeyChangedTimeoutEvent = null; | 23 | var rootKeyChangedTimeoutEvent = null; |
23 | 24 | ||
24 | var generationProcesses = []; | 25 | var generationProcesses = []; |
@@ -135,6 +136,7 @@ | |||
135 | DOM.passphrase.on("input", delayedPhraseChanged); | 136 | DOM.passphrase.on("input", delayedPhraseChanged); |
136 | DOM.generate.on("click", generateClicked); | 137 | DOM.generate.on("click", generateClicked); |
137 | DOM.more.on("click", showMore); | 138 | DOM.more.on("click", showMore); |
139 | DOM.seed.on("input", delayedSeedChanged); | ||
138 | DOM.rootKey.on("input", delayedRootKeyChanged); | 140 | DOM.rootKey.on("input", delayedRootKeyChanged); |
139 | DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); | 141 | DOM.litecoinUseLtub.on("change", litecoinUseLtubChanged); |
140 | DOM.bip32path.on("input", calcForDerivationPath); | 142 | DOM.bip32path.on("input", calcForDerivationPath); |
@@ -340,6 +342,30 @@ | |||
340 | entropyChanged(); | 342 | entropyChanged(); |
341 | } | 343 | } |
342 | 344 | ||
345 | function delayedSeedChanged() { | ||
346 | // Warn if there is an existing mnemonic or passphrase. | ||
347 | if (DOM.phrase.val().length > 0 || DOM.passphrase.val().length > 0) { | ||
348 | if (!confirm("This will clear existing mnemonic and passphrase")) { | ||
349 | DOM.seed.val(seed); | ||
350 | return | ||
351 | } | ||
352 | } | ||
353 | hideValidationError(); | ||
354 | showPending(); | ||
355 | // Clear existing mnemonic and passphrase | ||
356 | DOM.phrase.val(""); | ||
357 | DOM.phraseSplit.val(""); | ||
358 | DOM.passphrase.val(""); | ||
359 | DOM.rootKey.val(""); | ||
360 | clearAddressesList(); | ||
361 | clearDerivedKeys(); | ||
362 | seed = null; | ||
363 | if (seedChangedTimeoutEvent != null) { | ||
364 | clearTimeout(seedChangedTimeoutEvent); | ||
365 | } | ||
366 | seedChangedTimeoutEvent = setTimeout(seedChanged, 400); | ||
367 | } | ||
368 | |||
343 | function delayedRootKeyChanged() { | 369 | function delayedRootKeyChanged() { |
344 | // Warn if there is an existing mnemonic or passphrase. | 370 | // Warn if there is an existing mnemonic or passphrase. |
345 | if (DOM.phrase.val().length > 0 || DOM.passphrase.val().length > 0) { | 371 | if (DOM.phrase.val().length > 0 || DOM.passphrase.val().length > 0) { |
@@ -361,6 +387,22 @@ | |||
361 | rootKeyChangedTimeoutEvent = setTimeout(rootKeyChanged, 400); | 387 | rootKeyChangedTimeoutEvent = setTimeout(rootKeyChanged, 400); |
362 | } | 388 | } |
363 | 389 | ||
390 | function seedChanged() { | ||
391 | showPending(); | ||
392 | hideValidationError(); | ||
393 | seed = DOM.seed.val(); | ||
394 | bip32RootKey = bitcoinjs.bitcoin.HDNode.fromSeedHex(seed, network); | ||
395 | var rootKeyBase58 = bip32RootKey.toBase58(); | ||
396 | DOM.rootKey.val(rootKeyBase58); | ||
397 | var errorText = validateRootKey(rootKeyBase58); | ||
398 | if (errorText) { | ||
399 | showValidationError(errorText); | ||
400 | return; | ||
401 | } | ||
402 | // Calculate and display | ||
403 | calcForDerivationPath(); | ||
404 | } | ||
405 | |||
364 | function rootKeyChanged() { | 406 | function rootKeyChanged() { |
365 | showPending(); | 407 | showPending(); |
366 | hideValidationError(); | 408 | hideValidationError(); |