Merge pull request #764 from grote/697-receivery-code-crash

Trim white-spaces from recovery code words
This commit is contained in:
Torsten Grote 2024-10-07 11:09:26 -03:00 committed by GitHub
commit 5498e838db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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