mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-26 01:37:43 +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)
|
decode(mnemonic = mnemonicOrHex).let(Hex::fromStringCondensed)
|
||||||
} catch (decodeException: Exception) {
|
} catch (decodeException: Exception) {
|
||||||
// It's not a valid mnemonic, if it's pure-hexadecimal then we'll interpret it as a
|
// It's not a valid mnemonic, if it's pure-hexadecimal then we'll interpret it as a
|
||||||
// hexadecimal-byte encoded mnemonic.
|
// hexadecimal-byte encoded mnemonic... unless it's 66 chars or longer, then it could be
|
||||||
if (!mnemonicOrHex.isHex()) throw decodeException
|
// an account id.
|
||||||
try {
|
mnemonicOrHex.takeIf { it.length < 66 && it.isHex() }
|
||||||
Hex.fromStringCondensed(mnemonicOrHex)
|
.runCatching { Hex.fromStringCondensed(this) }
|
||||||
} catch (_: Exception) {
|
.getOrNull()
|
||||||
throw decodeException
|
?: throw decodeException
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user