Trim white-spaces from recovery code words

This commit is contained in:
Torsten Grote 2024-10-03 14:09:39 -03:00
parent f2aec3f932
commit 542a79e2e1
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF

View file

@ -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) {