Skip to content

Commit

Permalink
Trim white-spaces from recovery code words
Browse files Browse the repository at this point in the history
  • Loading branch information
grote committed Oct 3, 2024
1 parent f2aec3f commit 542a79e
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ internal class RecoveryCodeViewModel(

@Throws(InvalidWordException::class, ChecksumException::class)
fun validateCode(input: List<CharSequence>): Mnemonics.MnemonicCode {
val code = Mnemonics.MnemonicCode(input.toMnemonicChars())
check(input.size == WORD_NUM) { "Got ${input.size} words instead of $WORD_NUM" }
val trimmedInput = input.map { it.trim() } // white-spaces have a meaning in next line
val code = Mnemonics.MnemonicCode(trimmedInput.toMnemonicChars())
try {
code.validate()
} catch (e: WordCountException) {
Expand Down

0 comments on commit 542a79e

Please sign in to comment.