[#708] Fix seed byte generation

This commit is contained in:
Carter Jernigan 2023-01-17 11:44:57 -05:00 committed by GitHub
parent 193b376fe3
commit 4f144405c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -1,5 +1,10 @@
package cash.z.ecc.sdk.model
import cash.z.ecc.android.bip39.Mnemonics
import cash.z.ecc.android.bip39.toSeed
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
// Consider using ImmutableList here
data class SeedPhrase(val split: List<String>) {
init {
@ -13,7 +18,7 @@ data class SeedPhrase(val split: List<String>) {
fun joinToString() = split.joinToString(DEFAULT_DELIMITER)
fun toByteArray() = joinToString().encodeToByteArray()
suspend fun toByteArray() = withContext(Dispatchers.IO) { Mnemonics.MnemonicCode(joinToString()).toSeed() }
companion object {
const val SEED_PHRASE_SIZE = 24