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

Package cash.z.wallet.sdk.ext

Types

BlockingProvider

class BlockingProvider<T> : ReadWriteProperty<Any?, T>

BlockingSeedProvider

class BlockingSeedProvider : ReadOnlyProperty<Any?, ByteArray>

Bush

A collection of tiny logs (twigs) consisting of one trunk and maybe some leaves. There can only ever be one trunk. Trunks are created by planting a twig. Whenever a leaf sprouts, it will appear as a tag on every log message until clipped.

object Bush

CompositeTwig

Since there can only ever be one trunk on the bush of twigs, this class lets you cheat and make that trunk be a bundle of twigs.

open class CompositeTwig : Twig

Conversions

object Conversions

SampleSeedProvider

class SampleSeedProvider : ReadOnlyProperty<Any?, ByteArray>

SampleSpendingKeyProvider

class SampleSpendingKeyProvider : ReadWriteProperty<Any?, String>

SeedGenerator

This is intentionally insecure. Wallet makers have told us storing keys is their specialty so we don't put a lot of energy here. A true implementation would create a key using user interaction, perhaps with a password they know that is never stored, along with requiring user authentication for key use (i.e. fingerprint/PIN/pattern/etc). From there, one of these approaches might be helpful to store the key securely:

class SeedGenerator

SilentTwig

A tiny log that does nothing. No one hears this twig fall in the woods.

class SilentTwig : Twig

SimpleProvider

class SimpleProvider<T> : ReadWriteProperty<Any?, T>

TroubleshootingTwig

A tiny log for detecting troubles. Aim at your troubles and pull the twigger.

open class TroubleshootingTwig : Twig

Twig

A tiny log.

interface Twig

ZcashSdk

Wrapper for all the constant values in the SDK. It is important that these values stay fixed for all users of the SDK. Otherwise, if individual wallet makers are using different values, it becomes easier to reduce privacy by segmenting the anonymity set of users, particularly as it relates to network requests.

object ZcashSdk : ZcashSdkCommon

ZcashSdkCommon

Wrapper for all the constant values in the SDK. It is important that these values stay fixed for all users of the SDK. Otherwise, if individual wallet makers are using different values, it becomes easier to reduce privacy by segmenting the anonymity set of users, particularly as it relates to network requests.

open class ZcashSdkCommon

Extensions for External Classes

java.math.BigDecimal

kotlin.Double

kotlin.Long

kotlin.String

kotlinx.coroutines.flow.Flow

Functions

currencyFormatter

Create a number formatter for use with converting currency to strings. This probably isn't needed externally since the other formatting functions leverage this, instead. Leverages the default rounding mode for zec found in ZEC_FORMATTER.

fun currencyFormatter(maxDecimals: Int, minDecimals: Int): NumberFormat

retrySimple

Execute the given block and if it fails, retry up to retries more times, using thread sleep instead of suspending. If none of the retries succeed then throw the final error. This function is intended to be called with no parameters, i.e., it is designed to use its defaults.

fun retrySimple(retries: Int = 2, sleepTime: Long = 20L, block: (Int) -> Unit): Unit

retryUpTo

Execute the given block and if it fails, retry up to retries more times. If none of the retries succeed then throw the final error, which can be wrapped in order to add more context.

suspend fun retryUpTo(retries: Int, exceptionWrapper: (Throwable) -> Throwable = { it }, initialDelayMillis: Long = 500L, block: (Int) -> Unit): Unit

retryWithBackoff

Execute the given block and if it fails, retry with an exponential backoff.

suspend fun retryWithBackoff(onErrorListener: ((Throwable) -> Boolean)? = null, initialDelayMillis: Long = 1000L, maxDelayMillis: Long = MAX_BACKOFF_INTERVAL, block: () -> Unit): Unit

spiffy

A tiny log formatter that makes twigs pretty spiffy.

fun spiffy(stackFrame: Int = 4, tag: String = "@TWIG"): (String) -> String

twig

Makes a tiny log.

fun twig(message: String): Unit

Times a tiny log.

fun <R> twig(logMessage: String, block: () -> R): R

Times a tiny log. Execute the block of code on the clock.

fun <R> Twig.twig(logMessage: String, block: () -> R): R

twigTask

Meticulously times a tiny task.

fun <R> twigTask(logMessage: String, block: () -> R): R

A tiny log task. Execute the block of code with some twigging around the outside. For silent twigs, this adds a small amount of overhead at the call site but still avoids logging.

fun <R> Twig.twigTask(logMessage: String, block: () -> R): R