zcash-android-wallet-sdk/docs/-synchronizer/README.md

8.1 KiB

zcash-android-wallet-sdk / cash.z.wallet.sdk / Synchronizer

Synchronizer

interface Synchronizer

Primary interface for interacting with the SDK. Defines the contract that specific implementations like MockSynchronizer and SdkSynchronizer fulfill. Given the language-level support for coroutines, we favor their use in the SDK and incorporate that choice into this contract.

Types

Name Summary
AddressType sealed class AddressType
Status enum class Status

Properties

Name Summary
balances abstract val balances: Flow<CompactBlockProcessor.WalletBalance>
A stream of balance values, separately reflecting both the available and total balance.
clearedTransactions abstract val clearedTransactions: Flow<PagedList<ConfirmedTransaction>>
A flow of all the transactions that are on the blockchain.
onCriticalErrorHandler abstract var onCriticalErrorHandler: ((Throwable?) -> Boolean)?
Gets or sets a global error handler. This is a useful hook for handling unexpected critical errors.
onProcessorErrorHandler abstract var onProcessorErrorHandler: ((Throwable?) -> Boolean)?
An error handler for exceptions during processing. For instance, a block might be missing or a reorg may get mishandled or the database may get corrupted.
onSubmissionErrorHandler abstract var onSubmissionErrorHandler: ((Throwable?) -> Boolean)?
An error handler for exceptions while submitting transactions to lightwalletd. For instance, a transaction may get rejected because it would be a double-spend or the user might lose their cellphone signal.
pendingTransactions abstract val pendingTransactions: Flow<List<PendingTransaction>>
A flow of all the outbound pending transaction that have been sent but are awaiting confirmations.
processorInfo abstract val processorInfo: Flow<CompactBlockProcessor.ProcessorInfo>
A flow of processor details, updated every time blocks are processed to include the latest block height, blocks downloaded and blocks scanned. Similar to the progress flow but with a lot more detail.
progress abstract val progress: Flow<Int>
A flow of progress values, typically corresponding to this Synchronizer downloading blocks. Typically, any non- zero value below 100 indicates that progress indicators can be shown and a value of 100 signals that progress is complete and any progress indicators can be hidden.
receivedTransactions abstract val receivedTransactions: Flow<PagedList<ConfirmedTransaction>>
A flow of all transactions related to receiving funds.
sentTransactions abstract val sentTransactions: Flow<PagedList<ConfirmedTransaction>>
A flow of all transactions related to sending funds.
status abstract val status: Flow<Synchronizer.Status>
A flow of values representing the Status of this Synchronizer. As the status changes, a new value will be emitted by this flow.

Functions

Name Summary
cancelSpend abstract suspend fun cancelSpend(transaction: PendingTransaction): Boolean
Attempts to cancel a transaction that is about to be sent. Typically, cancellation is only an option if the transaction has not yet been submitted to the server.
getAddress abstract suspend fun getAddress(accountId: Int= 0):String
Gets the address for the given account.
isValidShieldedAddr abstract suspend fun isValidShieldedAddr(address: String): Boolean
Returns true when the given address is a valid z-addr. Invalid addresses will throw an exception. Valid z-addresses have these characteristics: //TODO
isValidTransparentAddr abstract suspend fun isValidTransparentAddr(address: String): Boolean
Returns true when the given address is a valid t-addr. Invalid addresses will throw an exception. Valid t-addresses have these characteristics: //TODO
sendToAddress abstract fun sendToAddress(spendingKey: String, zatoshi: Long, toAddress: String, memo: String= "", fromAccountIndex:Int = 0): Flow<PendingTransaction>
Sends zatoshi.
start abstract fun start(parentScope: CoroutineScope? = null): Synchronizer
Starts this synchronizer within the given scope.
stop abstract fun stop(): Unit
Stop this synchronizer. Implementations should ensure that calling this method cancels all jobs that were created by this instance.
validateAddress abstract suspend fun validateAddress(address: String): Synchronizer.AddressType
Validates the given address, returning information about why it is invalid.

Inheritors

Name Summary
SdkSynchronizer class SdkSynchronizer : Synchronizer
A Synchronizer that attempts to remain operational, despite any number of errors that can occur. It acts as the glue that ties all the pieces of the SDK together. Each component of the SDK is designed for the potential of stand-alone usage but coordinating all the interactions is non- trivial. So the Synchronizer facilitates this, acting as reference that demonstrates how all the pieces can be tied together. Its goal is to allow a developer to focus on their app rather than the nuances of how Zcash works.