Demo app bug fixes and testnet correction.
This commit is contained in:
parent
986286fced
commit
14888d2280
|
@ -11,7 +11,7 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
class SharedViewModel : ViewModel() {
|
||||
|
||||
private val config = App.instance.defaultConfig
|
||||
private val _seedPhrase = MutableStateFlow(config.seedWords)
|
||||
private val _seedPhrase = MutableStateFlow(config.initialSeedWords)
|
||||
|
||||
// publicly, this is read-only
|
||||
val seedPhrase: StateFlow<String> get() = _seedPhrase
|
||||
|
|
|
@ -64,7 +64,7 @@ class GetAddressFragment : BaseDemoFragment<FragmentGetAddressBinding>() {
|
|||
|
||||
override fun onActionButtonClicked() {
|
||||
copyToClipboard(
|
||||
DerivationTool.deriveTransparentAddress(seed),
|
||||
DerivationTool.deriveShieldedAddress(viewingKey),
|
||||
"Shielded address copied to clipboard!"
|
||||
)
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.view.View
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.paging.PagedList
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import cash.z.ecc.android.bip39.Mnemonics
|
||||
import cash.z.ecc.android.bip39.toSeed
|
||||
import cash.z.ecc.android.sdk.SdkSynchronizer
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.VkInitializer
|
||||
|
@ -39,9 +41,19 @@ class ListTransactionsFragment : BaseDemoFragment<FragmentListTransactionsBindin
|
|||
* here for completeness so that each demo file can serve as a standalone example.
|
||||
*/
|
||||
private fun setup() {
|
||||
// defaults to the value of `DemoConfig.seedWords` but can also be set by the user
|
||||
var seedPhrase = sharedViewModel.seedPhrase.value
|
||||
|
||||
// Use a BIP-39 library to convert a seed phrase into a byte array. Most wallets already
|
||||
// have the seed stored
|
||||
val seed = Mnemonics.MnemonicCode(seedPhrase).toSeed()
|
||||
|
||||
App.instance.defaultConfig.let { config ->
|
||||
initializer = VkInitializer(App.instance) { import(config.seed, config.birthdayHeight) }
|
||||
address = DerivationTool.deriveShieldedAddress(config.seed)
|
||||
initializer = VkInitializer(App.instance) {
|
||||
import(seed, config.birthdayHeight)
|
||||
server(config.host, config.port)
|
||||
}
|
||||
address = DerivationTool.deriveShieldedAddress(seed)
|
||||
}
|
||||
synchronizer = Synchronizer(initializer)
|
||||
}
|
||||
|
|
|
@ -25,11 +25,19 @@ import cash.z.ecc.android.sdk.service.LightWalletGrpcService
|
|||
import cash.z.ecc.android.sdk.service.LightWalletService
|
||||
import cash.z.ecc.android.sdk.rpc.LocalRpcTypes
|
||||
import cash.z.ecc.android.sdk.tool.DerivationTool
|
||||
import cash.z.ecc.android.sdk.tool.WalletBirthdayTool
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
/**
|
||||
* ===============================================================================================
|
||||
* NOTE: this is still a WIP because t-addrs are not officially supported by the SDK yet
|
||||
* ===============================================================================================
|
||||
*
|
||||
*
|
||||
* List all transactions related to the given seed, since the given birthday. This begins by
|
||||
* downloading any missing blocks and then validating and scanning their contents. Once scan is
|
||||
* complete, the transactions are available in the database and can be accessed by any SQL tool.
|
||||
|
@ -40,7 +48,7 @@ class ListUtxosFragment : BaseDemoFragment<FragmentListUtxosBinding>() {
|
|||
private val config = App.instance.defaultConfig
|
||||
private val initializer =
|
||||
Initializer(App.instance, host = config.host, port = config.port, alias = "Demo_Utxos")
|
||||
private val birthday = config.loadBirthday()
|
||||
private val birthday = WalletBirthdayTool.loadNearest(App.instance, config.birthdayHeight)
|
||||
private lateinit var synchronizer: Synchronizer
|
||||
private lateinit var adapter: UtxoAdapter<ConfirmedTransaction>
|
||||
private val address: String = "t1RwbKka1CnktvAJ1cSqdn7c6PXWG4tZqgd"
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import cash.z.ecc.android.bip39.Mnemonics
|
||||
import cash.z.ecc.android.bip39.toSeed
|
||||
import cash.z.ecc.android.sdk.Synchronizer
|
||||
import cash.z.ecc.android.sdk.VkInitializer
|
||||
import cash.z.ecc.android.sdk.block.CompactBlockProcessor
|
||||
|
@ -41,13 +43,21 @@ class SendFragment : BaseDemoFragment<FragmentSendBinding>() {
|
|||
* here for completeness so that each demo file can serve as a standalone example.
|
||||
*/
|
||||
private fun setup() {
|
||||
// defaults to the value of `DemoConfig.seedWords` but can also be set by the user
|
||||
var seedPhrase = sharedViewModel.seedPhrase.value
|
||||
|
||||
// Use a BIP-39 library to convert a seed phrase into a byte array. Most wallets already
|
||||
// have the seed stored
|
||||
val seed = Mnemonics.MnemonicCode(seedPhrase).toSeed()
|
||||
|
||||
App.instance.defaultConfig.let { config ->
|
||||
VkInitializer(App.instance) {
|
||||
import(config.seed, config.birthdayHeight)
|
||||
import(seed, config.birthdayHeight)
|
||||
server(config.host, config.port)
|
||||
}.let { initializer ->
|
||||
synchronizer = Synchronizer(initializer)
|
||||
}
|
||||
spendingKey = DerivationTool.deriveSpendingKeys(config.seed).first()
|
||||
spendingKey = DerivationTool.deriveSpendingKeys(seed).first()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,12 +11,8 @@ data class DemoConfig(
|
|||
val sendAmount: Double = 0.000018,
|
||||
|
||||
// corresponds to address: zs15tzaulx5weua5c7l47l4pku2pw9fzwvvnsp4y80jdpul0y3nwn5zp7tmkcclqaca3mdjqjkl7hx
|
||||
val seedWords: String = "wish puppy smile loan doll curve hole maze file ginger hair nose key relax knife witness cannon grab despair throw review deal slush frame",
|
||||
val initialSeedWords: String = "wish puppy smile loan doll curve hole maze file ginger hair nose key relax knife witness cannon grab despair throw review deal slush frame",
|
||||
|
||||
// corresponds to seed: urban kind wise collect social marble riot primary craft lucky head cause syrup odor artist decorate rhythm phone style benefit portion bus truck top
|
||||
val toAddress: String = "zs1lcdmue7rewgvzh3jd09sfvwq3sumu6hkhpk53q94kcneuffjkdg9e3tyxrugkmpza5c3c5e6eqh"
|
||||
) {
|
||||
val seed: ByteArray get() = SimpleMnemonics().toSeed(seedWords.toCharArray())
|
||||
fun newWalletBirthday() = WalletBirthdayTool.loadNearest(App.instance)
|
||||
fun loadBirthday(height: Int = birthdayHeight) = WalletBirthdayTool.loadNearest(App.instance, height)
|
||||
}
|
||||
)
|
|
@ -1,22 +1,15 @@
|
|||
package cash.z.ecc.android.sdk.demoapp
|
||||
|
||||
import cash.z.ecc.android.sdk.Initializer
|
||||
import cash.z.ecc.android.sdk.demoapp.util.SimpleMnemonics
|
||||
|
||||
data class DemoConfig(
|
||||
val host: String = "lightwalletd.testnet.z.cash",
|
||||
val alias: String = "SdkDemo",
|
||||
val host: String = "lightwalletd.testnet.electriccoin.co",
|
||||
val port: Int = 9067,
|
||||
val birthdayHeight: Int = 820_000,
|
||||
val sendAmount: Double = 0.0018,
|
||||
|
||||
// corresponds to address: ztestsapling1zhqvuq8zdwa8nsnde7074kcfsat0w25n08jzuvz5skzcs6h9raxu898l48xwr8fmkny3zqqrgd9
|
||||
val seedWords: String = "wish puppy smile loan doll curve hole maze file ginger hair nose key relax knife witness cannon grab despair throw review deal slush frame",
|
||||
val initialSeedWords: String = "wish puppy smile loan doll curve hole maze file ginger hair nose key relax knife witness cannon grab despair throw review deal slush frame",
|
||||
|
||||
// corresponds to seed: urban kind wise collect social marble riot primary craft lucky head cause syrup odor artist decorate rhythm phone style benefit portion bus truck top
|
||||
val toAddress: String = "ztestsapling1ddttvrm6ueug4vwlczs8daqjaul60aur4udnvcz9qdnjt9ekt2tsxheqvv3mn50wvhmzj4ge9rl"
|
||||
) {
|
||||
val seed: ByteArray get() = SimpleMnemonics().toSeed(seedWords.toCharArray())
|
||||
|
||||
fun newWalletBirthday() = Initializer.DefaultBirthdayStore.loadBirthdayFromAssets(App.instance)
|
||||
fun loadBirthday(height: Int = birthdayHeight) = Initializer.DefaultBirthdayStore.loadBirthdayFromAssets(App.instance, height)
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue