From 1eb828f7f0333f754aac5ba70319d6fbd6888b14 Mon Sep 17 00:00:00 2001 From: William Morriss Date: Thu, 6 Feb 2020 14:25:45 -0800 Subject: [PATCH] Add support for 24 word seed phrases (#7987) --- app/_locales/en/messages.json | 2 +- .../import-with-seed-phrase.component.js | 3 ++- .../confirm-seed-phrase/confirm-seed-phrase.component.js | 4 ---- ui/app/pages/keychains/restore-vault.js | 3 ++- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/_locales/en/messages.json b/app/_locales/en/messages.json index 64c95545a..d6b0e2bcc 100644 --- a/app/_locales/en/messages.json +++ b/app/_locales/en/messages.json @@ -1187,7 +1187,7 @@ "message": "Separate each word with a single space" }, "seedPhraseReq": { - "message": "Seed phrases are 12 words long" + "message": "Seed phrases contain 12, 15, 18, 21, or 24 words" }, "selectCurrency": { "message": "Select Currency" diff --git a/ui/app/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js b/ui/app/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js index 12eb4900f..2ea69f832 100644 --- a/ui/app/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js +++ b/ui/app/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component.js @@ -73,7 +73,8 @@ export default class ImportWithSeedPhrase extends PureComponent { if (seedPhrase) { const parsedSeedPhrase = this.parseSeedPhrase(seedPhrase) - if (parsedSeedPhrase.split(' ').length !== 12) { + const wordCount = parsedSeedPhrase.split(new RegExp('\\s')).length + if (wordCount % 3 !== 0 || wordCount > 24 || wordCount < 12) { seedPhraseError = this.context.t('seedPhraseReq') } else if (!validateMnemonic(parsedSeedPhrase)) { seedPhraseError = this.context.t('invalidSeedPhrase') diff --git a/ui/app/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js b/ui/app/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js index 2f04a9055..cab59f4dc 100644 --- a/ui/app/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js +++ b/ui/app/pages/first-time-flow/seed-phrase/confirm-seed-phrase/confirm-seed-phrase.component.js @@ -271,9 +271,5 @@ function insert (list, value, target, removeOld) { }) } - if (nextList.length > 12) { - nextList.pop() - } - return nextList } diff --git a/ui/app/pages/keychains/restore-vault.js b/ui/app/pages/keychains/restore-vault.js index ff0e2aa1d..425aa3fbc 100644 --- a/ui/app/pages/keychains/restore-vault.js +++ b/ui/app/pages/keychains/restore-vault.js @@ -42,7 +42,8 @@ class RestoreVaultPage extends Component { handleSeedPhraseChange (seedPhrase) { let seedPhraseError = null - if (seedPhrase && this.parseSeedPhrase(seedPhrase).split(' ').length !== 12) { + const wordCount = this.parseSeedPhrase(seedPhrase).split(new RegExp('\\s')).length + if (seedPhrase && (wordCount % 3 !== 0 || wordCount < 12 || wordCount > 24)) { seedPhraseError = this.context.t('seedPhraseReq') }