Skip to content

fix(restore): accept a recovery phrase pasted with its word numbers - #231

Open
coolstack-coder wants to merge 1 commit into
CypherCommons:masterfrom
coolstack-coder:fix/numbered-phrase-paste
Open

coolstack-coder wants to merge 1 commit into
CypherCommons:masterfrom
coolstack-coder:fix/numbered-phrase-paste

Conversation

@coolstack-coder

Copy link
Copy Markdown

Problem

Password managers and other wallets' backups often copy the phrase with its numbers: 1. abandon 2. ability …. cleanMnemonicText strips the punctuation but keeps the digits, so each number becomes a word. On Restore:

  • A numbered 12-word phrase fills 24 pills, 12 of them marked unknown.
  • A numbered 24-word phrase gives 48 tokens, and placeWords cuts it to the first 24, so half the phrase is lost.

Restore stays disabled until the user retypes every word.

Fix

Drop tokens that are only digits in cleanMnemonicText. That covers paste and scan (mnemonicWords), typing (mnemonicWordsAsTyped) and normalizeMnemonic in setSecret. No word in any supported wordlist holds a digit, and a SeedQR is decoded before this runs, so neither is affected.

Tests

A new case in tests/unit/bip39.test.ts covers 1. word on new lines, 1) word and 1.word. It fails on master and passes here. tsc and eslint are clean.

sendDetails.test.tsx › "fills in a payment request opened from home" fails on master too, so it's unrelated to this change.

Password managers and other wallets' backups often list the phrase as
"1. abandon 2. ability …". Only the punctuation was stripped, so each
number stayed as a word: a numbered 12-word phrase filled 24 pills with
12 marked unknown, and a numbered 24-word phrase was cut off halfway.
Restore stayed disabled until the user retyped every word.

Numbers standing alone are now dropped when the text is split into
words. No wordlist word holds a digit, and a SeedQR is decoded before
this runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant