Skip to content

Latest commit

 

History

History
110 lines (88 loc) · 2.65 KB

Consumers.md

File metadata and controls

110 lines (88 loc) · 2.65 KB

Configuring your build

Add flavors for testnet and mainnet. Since productFlavors cannot start with the word 'test' we recommend:

build.gradle

flavorDimensions 'network'
productFlavors {
    // would rather name them "testnet" and "mainnet" but product flavor names cannot start with the word "test"
    zcashtestnet {
        dimension 'network'
        matchingFallbacks = ['zcashtestnet', 'debug']
    }
    zcashmainnet {
        dimension 'network'
        matchingFallbacks = ['zcashmainnet', 'release']
    }
}

build.gradle.kts

flavorDimensions.add("network")

productFlavors {
    // would rather name them "testnet" and "mainnet" but product flavor names cannot start with the word "test"
    create("zcashtestnet") {
        dimension = "network"
        matchingFallbacks.addAll(listOf("zcashtestnet", "debug"))
    }

    create("zcashmainnet") {
        dimension = "network"
        matchingFallbacks.addAll(listOf("zcashmainnet", "release"))
    }
}

Resources /src/main/res/values/bools.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="zcash_is_testnet">false</bool>
</resources>

/src/zcashtestnet/res/values/bools.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <bool name="zcash_is_testnet">true</bool>
</resources>

ZcashNetworkExt.kt

/**
 * @return Zcash network determined from resources.
 */
fun ZcashNetwork.Companion.fromResources(context: Context) =
    if (context.resources.getBoolean(R.bool.zcash_is_testnet)) {
        ZcashNetwork.Testnet
    } else {
        ZcashNetwork.Mainnet
    }

Add the SDK dependency:

implementation("cash.z.ecc.android:zcash-android-sdk:$LATEST_VERSION")

Using the SDK

Start the Synchronizer

synchronizer.start(this)

Get the wallet's address

synchronizer.getAddress()

// or alternatively

DerivationTool.deriveShieldedAddress(viewingKey)

Send funds to another address

synchronizer.sendToAddress(spendingKey, zatoshi, address, memo)

The Synchronizer is the primary entrypoint for the SDK.

  1. Start the Synchronizer
  2. Subscribe to wallet data

The Synchronizer takes care of:

  • Connecting to the light wallet server
  • Downloading the latest compact blocks in a privacy-sensitive way
  • Scanning and trial decrypting those blocks for shielded transactions related to the wallet
  • Processing those related transactions into useful data for the UI
  • Sending payments to a full node through lightwalletd
  • Monitoring sent payments for status updates