[#708] Fix seed byte generation
This commit is contained in:
parent
193b376fe3
commit
4f144405c1
|
@ -1,5 +1,10 @@
|
||||||
package cash.z.ecc.sdk.model
|
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
|
// Consider using ImmutableList here
|
||||||
data class SeedPhrase(val split: List<String>) {
|
data class SeedPhrase(val split: List<String>) {
|
||||||
init {
|
init {
|
||||||
|
@ -13,7 +18,7 @@ data class SeedPhrase(val split: List<String>) {
|
||||||
|
|
||||||
fun joinToString() = split.joinToString(DEFAULT_DELIMITER)
|
fun joinToString() = split.joinToString(DEFAULT_DELIMITER)
|
||||||
|
|
||||||
fun toByteArray() = joinToString().encodeToByteArray()
|
suspend fun toByteArray() = withContext(Dispatchers.IO) { Mnemonics.MnemonicCode(joinToString()).toSeed() }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SEED_PHRASE_SIZE = 24
|
const val SEED_PHRASE_SIZE = 24
|
||||||
|
|
Loading…
Reference in New Issue