mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 09:17:44 +00:00
Error-out when you scan an account id when trying to recover an account
This commit is contained in:
parent
84b1fb6527
commit
71f04678cf
@ -128,13 +128,12 @@ class MnemonicCodec(private val loadFileContents: (String) -> String) {
|
||||
decode(mnemonic = mnemonicOrHex).let(Hex::fromStringCondensed)
|
||||
} catch (decodeException: Exception) {
|
||||
// It's not a valid mnemonic, if it's pure-hexadecimal then we'll interpret it as a
|
||||
// hexadecimal-byte encoded mnemonic.
|
||||
if (!mnemonicOrHex.isHex()) throw decodeException
|
||||
try {
|
||||
Hex.fromStringCondensed(mnemonicOrHex)
|
||||
} catch (_: Exception) {
|
||||
throw decodeException
|
||||
}
|
||||
// hexadecimal-byte encoded mnemonic... unless it's 66 chars or longer, then it could be
|
||||
// an account id.
|
||||
mnemonicOrHex.takeIf { it.length < 66 && it.isHex() }
|
||||
.runCatching { Hex.fromStringCondensed(this) }
|
||||
.getOrNull()
|
||||
?: throw decodeException
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user