2020-06-10 00:08:19 -07:00
|
|
|
package cash.z.ecc.android.sdk.util
|
2019-06-14 16:28:07 -07:00
|
|
|
|
2023-05-18 04:36:15 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.deriveUnifiedAddress
|
|
|
|
import cash.z.ecc.android.sdk.internal.jni.RustDerivationTool
|
2022-10-06 10:44:34 -07:00
|
|
|
import cash.z.ecc.android.sdk.model.Account
|
2022-08-02 06:29:09 -07:00
|
|
|
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
2022-08-25 05:36:57 -07:00
|
|
|
import cash.z.ecc.android.sdk.test.readFileLinesInFlow
|
2019-06-14 16:28:07 -07:00
|
|
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
2020-02-21 15:15:13 -08:00
|
|
|
import kotlinx.coroutines.flow.map
|
2019-06-14 16:28:07 -07:00
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
import org.junit.Assert.assertEquals
|
2020-02-21 15:15:13 -08:00
|
|
|
import org.junit.Assert.assertTrue
|
2019-06-14 16:28:07 -07:00
|
|
|
import org.junit.Test
|
|
|
|
|
|
|
|
@ExperimentalCoroutinesApi
|
|
|
|
class AddressGeneratorUtil {
|
|
|
|
|
2020-02-21 15:15:13 -08:00
|
|
|
private val mnemonics = SimpleMnemonics()
|
2019-06-14 16:28:07 -07:00
|
|
|
|
2020-02-21 15:15:13 -08:00
|
|
|
@Test
|
|
|
|
fun printMnemonic() {
|
|
|
|
mnemonics.apply {
|
|
|
|
val mnemonicPhrase = String(nextMnemonic())
|
|
|
|
println("example mnemonic: $mnemonicPhrase")
|
|
|
|
assertEquals(24, mnemonicPhrase.split(" ").size)
|
|
|
|
}
|
2019-06-14 16:28:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
fun generateAddresses() = runBlocking {
|
2022-08-25 05:36:57 -07:00
|
|
|
readFileLinesInFlow("/utils/seeds.txt")
|
2020-02-21 15:15:13 -08:00
|
|
|
.map { seedPhrase ->
|
|
|
|
mnemonics.toSeed(seedPhrase.toCharArray())
|
|
|
|
}.map { seed ->
|
2023-05-18 04:36:15 -07:00
|
|
|
RustDerivationTool.new().deriveUnifiedAddress(seed, ZcashNetwork.Mainnet, Account.DEFAULT)
|
2020-02-21 15:15:13 -08:00
|
|
|
}.collect { address ->
|
|
|
|
println("xrxrx2\t$address")
|
2022-08-23 15:40:51 -07:00
|
|
|
assertTrue(address.startsWith("u1"))
|
2020-02-21 15:15:13 -08:00
|
|
|
}
|
2019-06-14 16:28:07 -07:00
|
|
|
}
|
2020-06-09 20:28:21 -07:00
|
|
|
}
|