Removing unsupported stuff and building based on service.proto from our lightwalletd
This commit is contained in:
@@ -80,10 +80,12 @@ class TestWallet(
|
|||||||
val networkName get() = synchronizer.network.networkName
|
val networkName get() = synchronizer.network.networkName
|
||||||
val connectionInfo get() = service.connectionInfo.toString()
|
val connectionInfo get() = service.connectionInfo.toString()
|
||||||
|
|
||||||
|
/* NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun transparentBalance(): WalletBalance {
|
suspend fun transparentBalance(): WalletBalance {
|
||||||
synchronizer.refreshUtxos(transparentAddress, synchronizer.latestBirthdayHeight)
|
synchronizer.refreshUtxos(transparentAddress, synchronizer.latestBirthdayHeight)
|
||||||
return synchronizer.getTransparentBalance(transparentAddress)
|
return synchronizer.getTransparentBalance(transparentAddress)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
suspend fun sync(timeout: Long = -1): TestWallet {
|
suspend fun sync(timeout: Long = -1): TestWallet {
|
||||||
val killSwitch = walletScope.launch {
|
val killSwitch = walletScope.launch {
|
||||||
@@ -122,6 +124,7 @@ class TestWallet(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun shieldFunds(): TestWallet {
|
suspend fun shieldFunds(): TestWallet {
|
||||||
twig("checking $transparentAddress for transactions!")
|
twig("checking $transparentAddress for transactions!")
|
||||||
synchronizer.refreshUtxos(transparentAddress, 935000).let { count ->
|
synchronizer.refreshUtxos(transparentAddress, 935000).let { count ->
|
||||||
@@ -141,6 +144,7 @@ class TestWallet(
|
|||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
suspend fun join(timeout: Long? = null): TestWallet {
|
suspend fun join(timeout: Long? = null): TestWallet {
|
||||||
// block until stopped
|
// block until stopped
|
||||||
|
|||||||
@@ -82,12 +82,13 @@ class ListUtxosFragment : BaseDemoFragment<FragmentListUtxosBinding>() {
|
|||||||
|
|
||||||
binding.buttonLoad.setOnClickListener {
|
binding.buttonLoad.setOnClickListener {
|
||||||
mainActivity()?.hideKeyboard()
|
mainActivity()?.hideKeyboard()
|
||||||
downloadTransactions()
|
//downloadTransactions()
|
||||||
}
|
}
|
||||||
|
|
||||||
initTransactionUi()
|
initTransactionUi()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
fun downloadTransactions() {
|
fun downloadTransactions() {
|
||||||
binding.textStatus.text = "loading..."
|
binding.textStatus.text = "loading..."
|
||||||
binding.textStatus.post {
|
binding.textStatus.post {
|
||||||
@@ -135,6 +136,7 @@ class ListUtxosFragment : BaseDemoFragment<FragmentListUtxosBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private val now get() = System.currentTimeMillis()
|
private val now get() = System.currentTimeMillis()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package cash.z.ecc.android.sdk.demoapp
|
package cash.z.ecc.android.sdk.demoapp
|
||||||
|
|
||||||
object DemoConstants {
|
object DemoConstants {
|
||||||
val utxoEndHeight: Int = 968085
|
val utxoEndHeight: Int = 950000
|
||||||
val sendAmount: Double = 0.000018
|
val sendAmount: Double = 0.000018
|
||||||
|
|
||||||
// corresponds to address: zs15tzaulx5weua5c7l47l4pku2pw9fzwvvnsp4y80jdpul0y3nwn5zp7tmkcclqaca3mdjqjkl7hx
|
// corresponds to address: zs15tzaulx5weua5c7l47l4pku2pw9fzwvvnsp4y80jdpul0y3nwn5zp7tmkcclqaca3mdjqjkl7hx
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class SanityTest(
|
|||||||
fun testServerConnection() {
|
fun testServerConnection() {
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"$name has an invalid server connection",
|
"$name has an invalid server connection",
|
||||||
"$networkName.lightwalletd.com:9067?usePlaintext=false",
|
"$networkName.lite.hushpool.is:9067?usePlaintext=true",
|
||||||
wallet.connectionInfo
|
wallet.connectionInfo
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,10 +80,12 @@ class TestWallet(
|
|||||||
val networkName get() = synchronizer.network.networkName
|
val networkName get() = synchronizer.network.networkName
|
||||||
val connectionInfo get() = service.connectionInfo.toString()
|
val connectionInfo get() = service.connectionInfo.toString()
|
||||||
|
|
||||||
|
/* NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun transparentBalance(): WalletBalance {
|
suspend fun transparentBalance(): WalletBalance {
|
||||||
synchronizer.refreshUtxos(transparentAddress, synchronizer.latestBirthdayHeight)
|
synchronizer.refreshUtxos(transparentAddress, synchronizer.latestBirthdayHeight)
|
||||||
return synchronizer.getTransparentBalance(transparentAddress)
|
return synchronizer.getTransparentBalance(transparentAddress)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
suspend fun sync(timeout: Long = -1): TestWallet {
|
suspend fun sync(timeout: Long = -1): TestWallet {
|
||||||
val killSwitch = walletScope.launch {
|
val killSwitch = walletScope.launch {
|
||||||
@@ -122,6 +124,7 @@ class TestWallet(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun shieldFunds(): TestWallet {
|
suspend fun shieldFunds(): TestWallet {
|
||||||
twig("checking $transparentAddress for transactions!")
|
twig("checking $transparentAddress for transactions!")
|
||||||
synchronizer.refreshUtxos(transparentAddress, 935000).let { count ->
|
synchronizer.refreshUtxos(transparentAddress, 935000).let { count ->
|
||||||
@@ -141,6 +144,7 @@ class TestWallet(
|
|||||||
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
suspend fun join(timeout: Long? = null): TestWallet {
|
suspend fun join(timeout: Long? = null): TestWallet {
|
||||||
// block until stopped
|
// block until stopped
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<bool name="lightwalletd_allow_very_insecure_connections">false</bool>
|
<bool name="lightwalletd_allow_very_insecure_connections">true</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ import kotlin.coroutines.EmptyCoroutineContext
|
|||||||
*/
|
*/
|
||||||
@ExperimentalCoroutinesApi
|
@ExperimentalCoroutinesApi
|
||||||
@FlowPreview
|
@FlowPreview
|
||||||
|
|
||||||
class SdkSynchronizer internal constructor(
|
class SdkSynchronizer internal constructor(
|
||||||
private val storage: TransactionRepository,
|
private val storage: TransactionRepository,
|
||||||
private val txManager: OutboundTransactionManager,
|
private val txManager: OutboundTransactionManager,
|
||||||
@@ -102,9 +103,9 @@ class SdkSynchronizer internal constructor(
|
|||||||
) : Synchronizer {
|
) : Synchronizer {
|
||||||
|
|
||||||
// pools
|
// pools
|
||||||
private val _orchardBalances = MutableStateFlow<WalletBalance?>(null)
|
//private val _orchardBalances = MutableStateFlow<WalletBalance?>(null)
|
||||||
private val _saplingBalances = MutableStateFlow<WalletBalance?>(null)
|
private val _saplingBalances = MutableStateFlow<WalletBalance?>(null)
|
||||||
private val _transparentBalances = MutableStateFlow<WalletBalance?>(null)
|
//private val _transparentBalances = MutableStateFlow<WalletBalance?>(null)
|
||||||
|
|
||||||
private val _status = ConflatedBroadcastChannel<Synchronizer.Status>(DISCONNECTED)
|
private val _status = ConflatedBroadcastChannel<Synchronizer.Status>(DISCONNECTED)
|
||||||
|
|
||||||
@@ -143,9 +144,9 @@ class SdkSynchronizer internal constructor(
|
|||||||
// Balances
|
// Balances
|
||||||
//
|
//
|
||||||
|
|
||||||
override val orchardBalances = _orchardBalances.asStateFlow()
|
//override val orchardBalances = _orchardBalances.asStateFlow()
|
||||||
override val saplingBalances = _saplingBalances.asStateFlow()
|
override val saplingBalances = _saplingBalances.asStateFlow()
|
||||||
override val transparentBalances = _transparentBalances.asStateFlow()
|
//override val transparentBalances = _transparentBalances.asStateFlow()
|
||||||
|
|
||||||
//
|
//
|
||||||
// Transactions
|
// Transactions
|
||||||
@@ -355,10 +356,12 @@ class SdkSynchronizer internal constructor(
|
|||||||
// Private API
|
// Private API
|
||||||
//
|
//
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun refreshUtxos() {
|
suspend fun refreshUtxos() {
|
||||||
twig("refreshing utxos", -1)
|
twig("refreshing utxos", -1)
|
||||||
refreshUtxos(getTransparentAddress())
|
refreshUtxos(getTransparentAddress())
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the latest balance, based on the blocks that have been scanned and transmit this
|
* Calculate the latest balance, based on the blocks that have been scanned and transmit this
|
||||||
@@ -366,7 +369,7 @@ class SdkSynchronizer internal constructor(
|
|||||||
*/
|
*/
|
||||||
suspend fun refreshAllBalances() {
|
suspend fun refreshAllBalances() {
|
||||||
refreshSaplingBalance()
|
refreshSaplingBalance()
|
||||||
refreshTransparentBalance()
|
// refreshTransparentBalance()
|
||||||
// TODO: refresh orchard balance
|
// TODO: refresh orchard balance
|
||||||
twig("Warning: Orchard balance does not yet refresh. Only some of the plumbing is in place.")
|
twig("Warning: Orchard balance does not yet refresh. Only some of the plumbing is in place.")
|
||||||
}
|
}
|
||||||
@@ -376,11 +379,14 @@ class SdkSynchronizer internal constructor(
|
|||||||
_saplingBalances.value = processor.getBalanceInfo()
|
_saplingBalances.value = processor.getBalanceInfo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun refreshTransparentBalance() {
|
suspend fun refreshTransparentBalance() {
|
||||||
twig("refreshing transparent balance")
|
twig("refreshing transparent balance")
|
||||||
_transparentBalances.value = processor.getUtxoCacheBalance(getTransparentAddress())
|
_transparentBalances.value = processor.getUtxoCacheBalance(getTransparentAddress())
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun isValidAddress(address: String): Boolean {
|
suspend fun isValidAddress(address: String): Boolean {
|
||||||
try {
|
try {
|
||||||
return !validateAddress(address).isNotValid
|
return !validateAddress(address).isNotValid
|
||||||
@@ -388,6 +394,7 @@ class SdkSynchronizer internal constructor(
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
private fun CoroutineScope.onReady() = launch(CoroutineExceptionHandler(::onCriticalError)) {
|
private fun CoroutineScope.onReady() = launch(CoroutineExceptionHandler(::onCriticalError)) {
|
||||||
twig("Preparing to start...")
|
twig("Preparing to start...")
|
||||||
@@ -516,7 +523,7 @@ class SdkSynchronizer internal constructor(
|
|||||||
// balance refresh is complete.
|
// balance refresh is complete.
|
||||||
if (shouldRefresh) {
|
if (shouldRefresh) {
|
||||||
twigTask("Triggering utxo refresh since $reason!", -1) {
|
twigTask("Triggering utxo refresh since $reason!", -1) {
|
||||||
refreshUtxos()
|
//refreshUtxos()
|
||||||
}
|
}
|
||||||
twigTask("Triggering balance refresh since $reason!", -1) {
|
twigTask("Triggering balance refresh since $reason!", -1) {
|
||||||
refreshAllBalances()
|
refreshAllBalances()
|
||||||
@@ -694,17 +701,22 @@ class SdkSynchronizer internal constructor(
|
|||||||
txManager.monitorById(it.id)
|
txManager.monitorById(it.id)
|
||||||
}.distinctUntilChanged()
|
}.distinctUntilChanged()
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
override suspend fun refreshUtxos(address: String, startHeight: Int): Int? {
|
override suspend fun refreshUtxos(address: String, startHeight: Int): Int? {
|
||||||
return processor.refreshUtxos(address, startHeight)
|
return processor.refreshUtxos(address, startHeight)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
override suspend fun getTransparentBalance(tAddr: String): WalletBalance {
|
override suspend fun getTransparentBalance(tAddr: String): WalletBalance {
|
||||||
return processor.getUtxoCacheBalance(tAddr)
|
return processor.getUtxoCacheBalance(tAddr)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
override suspend fun isValidShieldedAddr(address: String) =
|
override suspend fun isValidShieldedAddr(address: String) =
|
||||||
txManager.isValidShieldedAddress(address)
|
txManager.isValidShieldedAddress(address)
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
override suspend fun isValidTransparentAddr(address: String) =
|
override suspend fun isValidTransparentAddr(address: String) =
|
||||||
txManager.isValidTransparentAddress(address)
|
txManager.isValidTransparentAddress(address)
|
||||||
|
|
||||||
@@ -725,6 +737,7 @@ class SdkSynchronizer internal constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
override suspend fun validateConsensusBranch(): ConsensusMatchType {
|
override suspend fun validateConsensusBranch(): ConsensusMatchType {
|
||||||
val serverBranchId = tryNull { processor.downloader.getServerInfo().consensusBranchId }
|
val serverBranchId = tryNull { processor.downloader.getServerInfo().consensusBranchId }
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ interface Synchronizer {
|
|||||||
/**
|
/**
|
||||||
* A stream of balance values for the orchard pool. Includes the available and total balance.
|
* A stream of balance values for the orchard pool. Includes the available and total balance.
|
||||||
*/
|
*/
|
||||||
val orchardBalances: StateFlow<WalletBalance?>
|
//val orchardBalances: StateFlow<WalletBalance?>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A stream of balance values for the sapling pool. Includes the available and total balance.
|
* A stream of balance values for the sapling pool. Includes the available and total balance.
|
||||||
@@ -113,7 +113,7 @@ interface Synchronizer {
|
|||||||
/**
|
/**
|
||||||
* A stream of balance values for the transparent pool. Includes the available and total balance.
|
* A stream of balance values for the transparent pool. Includes the available and total balance.
|
||||||
*/
|
*/
|
||||||
val transparentBalances: StateFlow<WalletBalance?>
|
//val transparentBalances: StateFlow<WalletBalance?>
|
||||||
|
|
||||||
/* Transactions */
|
/* Transactions */
|
||||||
|
|
||||||
@@ -238,7 +238,9 @@ interface Synchronizer {
|
|||||||
*
|
*
|
||||||
* @throws RuntimeException when the address is invalid.
|
* @throws RuntimeException when the address is invalid.
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun isValidTransparentAddr(address: String): Boolean
|
suspend fun isValidTransparentAddr(address: String): Boolean
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate whether the server and this SDK share the same consensus branch. This is
|
* Validate whether the server and this SDK share the same consensus branch. This is
|
||||||
@@ -264,7 +266,9 @@ interface Synchronizer {
|
|||||||
*
|
*
|
||||||
* @return an instance of [AddressType] providing validation info regarding the given address.
|
* @return an instance of [AddressType] providing validation info regarding the given address.
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun validateAddress(address: String): AddressType
|
suspend fun validateAddress(address: String): AddressType
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to cancel a transaction that is about to be sent. Typically, cancellation is only
|
* Attempts to cancel a transaction that is about to be sent. Typically, cancellation is only
|
||||||
@@ -300,15 +304,19 @@ interface Synchronizer {
|
|||||||
*
|
*
|
||||||
* @return the number of utxos that were downloaded and addded to the UTXO table.
|
* @return the number of utxos that were downloaded and addded to the UTXO table.
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun refreshUtxos(
|
suspend fun refreshUtxos(
|
||||||
tAddr: String,
|
tAddr: String,
|
||||||
sinceHeight: Int = network.saplingActivationHeight
|
sinceHeight: Int = network.saplingActivationHeight
|
||||||
): Int?
|
): Int?
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the balance that the wallet knows about. This should be called after [refreshUtxos].
|
* Returns the balance that the wallet knows about. This should be called after [refreshUtxos].
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORT IN HUSH LIGHTWALLETD
|
||||||
suspend fun getTransparentBalance(tAddr: String): WalletBalance
|
suspend fun getTransparentBalance(tAddr: String): WalletBalance
|
||||||
|
*/
|
||||||
|
|
||||||
suspend fun getNearestRewindHeight(height: Int): Int
|
suspend fun getNearestRewindHeight(height: Int): Int
|
||||||
|
|
||||||
|
|||||||
@@ -425,6 +425,7 @@ class CompactBlockProcessor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
var failedUtxoFetches = 0
|
var failedUtxoFetches = 0
|
||||||
internal suspend fun refreshUtxos(tAddress: String, startHeight: Int): Int? = withContext(IO) {
|
internal suspend fun refreshUtxos(tAddress: String, startHeight: Int): Int? = withContext(IO) {
|
||||||
var count: Int? = null
|
var count: Int? = null
|
||||||
@@ -446,7 +447,9 @@ class CompactBlockProcessor(
|
|||||||
}
|
}
|
||||||
count
|
count
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
internal suspend fun processUtxoResult(result: List<Service.GetAddressUtxosReply>, tAddress: String, startHeight: Int): Int = withContext(IO) {
|
internal suspend fun processUtxoResult(result: List<Service.GetAddressUtxosReply>, tAddress: String, startHeight: Int): Int = withContext(IO) {
|
||||||
var skipped = 0
|
var skipped = 0
|
||||||
val aboveHeight = startHeight - 1
|
val aboveHeight = startHeight - 1
|
||||||
@@ -473,6 +476,7 @@ class CompactBlockProcessor(
|
|||||||
// return the number of UTXOs that were downloaded
|
// return the number of UTXOs that were downloaded
|
||||||
result.size - skipped
|
result.size - skipped
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request all blocks in the given range and persist them locally for processing, later.
|
* Request all blocks in the given range and persist them locally for processing, later.
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class LightWalletGrpcService private constructor(
|
|||||||
network: ZcashNetwork,
|
network: ZcashNetwork,
|
||||||
usePlaintext: Boolean =
|
usePlaintext: Boolean =
|
||||||
appContext.resources.getBoolean(R.bool.lightwalletd_allow_very_insecure_connections)
|
appContext.resources.getBoolean(R.bool.lightwalletd_allow_very_insecure_connections)
|
||||||
) : this(appContext, network.defaultHost, network.defaultPort, usePlaintext)
|
) : this(appContext, network.defaultHost, network.defaultPort, true)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an instance that corresponds to the given host and port.
|
* Construct an instance that corresponds to the given host and port.
|
||||||
@@ -58,8 +58,8 @@ class LightWalletGrpcService private constructor(
|
|||||||
port: Int = ZcashNetwork.Mainnet.defaultPort,
|
port: Int = ZcashNetwork.Mainnet.defaultPort,
|
||||||
usePlaintext: Boolean =
|
usePlaintext: Boolean =
|
||||||
appContext.resources.getBoolean(R.bool.lightwalletd_allow_very_insecure_connections)
|
appContext.resources.getBoolean(R.bool.lightwalletd_allow_very_insecure_connections)
|
||||||
) : this(createDefaultChannel(appContext, host, port, usePlaintext)) {
|
) : this(createDefaultChannel(appContext, host, port, true)) {
|
||||||
connectionInfo = ConnectionInfo(appContext.applicationContext, host, port, usePlaintext)
|
connectionInfo = ConnectionInfo(appContext.applicationContext, host, port, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LightWalletService implementation */
|
/* LightWalletService implementation */
|
||||||
@@ -109,6 +109,7 @@ class LightWalletGrpcService private constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
override fun fetchUtxos(
|
override fun fetchUtxos(
|
||||||
tAddress: String,
|
tAddress: String,
|
||||||
startHeight: Int
|
startHeight: Int
|
||||||
@@ -119,7 +120,9 @@ class LightWalletGrpcService private constructor(
|
|||||||
)
|
)
|
||||||
return result.addressUtxosList
|
return result.addressUtxosList
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
override fun getTAddressTransactions(
|
override fun getTAddressTransactions(
|
||||||
tAddress: String,
|
tAddress: String,
|
||||||
blockHeightRange: IntRange
|
blockHeightRange: IntRange
|
||||||
@@ -132,6 +135,7 @@ class LightWalletGrpcService private constructor(
|
|||||||
)
|
)
|
||||||
return result.toList()
|
return result.toList()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
override fun reconnect() {
|
override fun reconnect() {
|
||||||
twig(
|
twig(
|
||||||
@@ -143,7 +147,7 @@ class LightWalletGrpcService private constructor(
|
|||||||
connectionInfo.appContext,
|
connectionInfo.appContext,
|
||||||
connectionInfo.host,
|
connectionInfo.host,
|
||||||
connectionInfo.port,
|
connectionInfo.port,
|
||||||
connectionInfo.usePlaintext
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +199,7 @@ class LightWalletGrpcService private constructor(
|
|||||||
val usePlaintext: Boolean
|
val usePlaintext: Boolean
|
||||||
) {
|
) {
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return "$host:$port?usePlaintext=$usePlaintext"
|
return "$host:$port?usePlaintext=true"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ interface LightWalletService {
|
|||||||
*
|
*
|
||||||
* @return the UTXOs for the given address from the startHeight.
|
* @return the UTXOs for the given address from the startHeight.
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORT IN HUSH LIGHTWALLETD
|
||||||
fun fetchUtxos(tAddress: String, startHeight: Int): List<Service.GetAddressUtxosReply>
|
fun fetchUtxos(tAddress: String, startHeight: Int): List<Service.GetAddressUtxosReply>
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the given range of blocks.
|
* Return the given range of blocks.
|
||||||
@@ -70,7 +72,9 @@ interface LightWalletService {
|
|||||||
*
|
*
|
||||||
* @return a list of transactions that correspond to the given address for the given range.
|
* @return a list of transactions that correspond to the given address for the given range.
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
fun getTAddressTransactions(tAddress: String, blockHeightRange: IntRange): List<Service.RawTransaction>
|
fun getTAddressTransactions(tAddress: String, blockHeightRange: IntRange): List<Service.RawTransaction>
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reconnect to the same or a different server. This is useful when the connection is
|
* Reconnect to the same or a different server. This is useful when the connection is
|
||||||
|
|||||||
@@ -230,8 +230,10 @@ class PersistentTransactionManager(
|
|||||||
override suspend fun isValidShieldedAddress(address: String) =
|
override suspend fun isValidShieldedAddress(address: String) =
|
||||||
encoder.isValidShieldedAddress(address)
|
encoder.isValidShieldedAddress(address)
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
override suspend fun isValidTransparentAddress(address: String) =
|
override suspend fun isValidTransparentAddress(address: String) =
|
||||||
encoder.isValidTransparentAddress(address)
|
encoder.isValidTransparentAddress(address)
|
||||||
|
*/
|
||||||
|
|
||||||
override suspend fun cancel(pendingId: Long): Boolean {
|
override suspend fun cancel(pendingId: Long): Boolean {
|
||||||
return pendingTransactionDao {
|
return pendingTransactionDao {
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ interface TransactionEncoder {
|
|||||||
*
|
*
|
||||||
* @return true when the given address is a valid t-addr
|
* @return true when the given address is a valid t-addr
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun isValidTransparentAddress(address: String): Boolean
|
suspend fun isValidTransparentAddress(address: String): Boolean
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the consensus branch that the encoder is using when making transactions.
|
* Return the consensus branch that the encoder is using when making transactions.
|
||||||
|
|||||||
@@ -94,7 +94,9 @@ interface OutboundTransactionManager {
|
|||||||
*
|
*
|
||||||
* @return true when the given address is a valid z-addr.
|
* @return true when the given address is a valid z-addr.
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
suspend fun isValidTransparentAddress(address: String): Boolean
|
suspend fun isValidTransparentAddress(address: String): Boolean
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to cancel a transaction.
|
* Attempt to cancel a transaction.
|
||||||
|
|||||||
@@ -77,8 +77,10 @@ class WalletTransactionEncoder(
|
|||||||
*
|
*
|
||||||
* @return true when the given address is a valid t-addr
|
* @return true when the given address is a valid t-addr
|
||||||
*/
|
*/
|
||||||
|
/* THIS IS NOT SUPPORTED BY HUSH LIGHTWALLETD
|
||||||
override suspend fun isValidTransparentAddress(address: String): Boolean =
|
override suspend fun isValidTransparentAddress(address: String): Boolean =
|
||||||
rustBackend.isValidTransparentAddr(address)
|
rustBackend.isValidTransparentAddr(address)
|
||||||
|
*/
|
||||||
|
|
||||||
override suspend fun getConsensusBranchId(): Long {
|
override suspend fun getConsensusBranchId(): Long {
|
||||||
val height = repository.lastScannedHeight()
|
val height = repository.lastScannedHeight()
|
||||||
|
|||||||
@@ -110,9 +110,11 @@ class RustBackend private constructor() : RustBackendWelding {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
override suspend fun getTransparentAddress(account: Int, index: Int): String {
|
override suspend fun getTransparentAddress(account: Int, index: Int): String {
|
||||||
throw NotImplementedError("TODO: implement this at the zcash_client_sqlite level. But for now, use DerivationTool, instead to derive addresses from seeds")
|
throw NotImplementedError("TODO: implement this at the zcash_client_sqlite level. But for now, use DerivationTool, instead to derive addresses from seeds")
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
override suspend fun getBalance(account: Int): Zatoshi {
|
override suspend fun getBalance(account: Int): Zatoshi {
|
||||||
val longValue = withContext(SdkDispatchers.DATABASE_IO) {
|
val longValue = withContext(SdkDispatchers.DATABASE_IO) {
|
||||||
@@ -311,8 +313,10 @@ class RustBackend private constructor() : RustBackendWelding {
|
|||||||
override fun isValidShieldedAddr(addr: String) =
|
override fun isValidShieldedAddr(addr: String) =
|
||||||
isValidShieldedAddress(addr, networkId = network.id)
|
isValidShieldedAddress(addr, networkId = network.id)
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORTED IN HUSH LIGHTWALLETD
|
||||||
override fun isValidTransparentAddr(addr: String) =
|
override fun isValidTransparentAddr(addr: String) =
|
||||||
isValidTransparentAddress(addr, networkId = network.id)
|
isValidTransparentAddress(addr, networkId = network.id)
|
||||||
|
*/
|
||||||
|
|
||||||
override fun getBranchIdForHeight(height: Int): Long =
|
override fun getBranchIdForHeight(height: Int): Long =
|
||||||
branchIdForHeight(height, networkId = network.id)
|
branchIdForHeight(height, networkId = network.id)
|
||||||
@@ -413,8 +417,10 @@ class RustBackend private constructor() : RustBackendWelding {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
private external fun isValidShieldedAddress(addr: String, networkId: Int): Boolean
|
private external fun isValidShieldedAddress(addr: String, networkId: Int): Boolean
|
||||||
|
|
||||||
|
/* THIS IS NOT SUPPORT IN HUSH LIGHTWALLETD
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
private external fun isValidTransparentAddress(addr: String, networkId: Int): Boolean
|
private external fun isValidTransparentAddress(addr: String, networkId: Int): Boolean
|
||||||
|
*/
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
private external fun getBalance(dbDataPath: String, account: Int, networkId: Int): Long
|
private external fun getBalance(dbDataPath: String, account: Int, networkId: Int): Long
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ interface RustBackendWelding {
|
|||||||
|
|
||||||
fun isValidShieldedAddr(addr: String): Boolean
|
fun isValidShieldedAddr(addr: String): Boolean
|
||||||
|
|
||||||
fun isValidTransparentAddr(addr: String): Boolean
|
//fun isValidTransparentAddr(addr: String): Boolean
|
||||||
|
|
||||||
suspend fun getShieldedAddress(account: Int = 0): String
|
suspend fun getShieldedAddress(account: Int = 0): String
|
||||||
|
|
||||||
suspend fun getTransparentAddress(account: Int = 0, index: Int = 0): String
|
//suspend fun getTransparentAddress(account: Int = 0, index: Int = 0): String
|
||||||
|
|
||||||
suspend fun getBalance(account: Int = 0): Zatoshi
|
suspend fun getBalance(account: Int = 0): Zatoshi
|
||||||
|
|
||||||
|
|||||||
@@ -78,8 +78,8 @@ enum class ZcashNetwork(
|
|||||||
val defaultHost: String,
|
val defaultHost: String,
|
||||||
val defaultPort: Int
|
val defaultPort: Int
|
||||||
) {
|
) {
|
||||||
Testnet(0, "testnet", 280_000, "testnet.lightwalletd.com", 9067),
|
Testnet(0, "testnet", 995_000, "lite.hushpool.is", 9067),
|
||||||
Mainnet(1, "mainnet", 419_200, "mainnet.lightwalletd.com", 9067);
|
Mainnet(1, "mainnet", 995_000, "lite.hushpool.is", 9067);
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun from(id: Int) = values().first { it.id == id }
|
fun from(id: Int) = values().first { it.id == id }
|
||||||
|
|||||||
@@ -1,22 +1,19 @@
|
|||||||
// Copyright (c) 2019-2020 The Zcash developers
|
|
||||||
// Distributed under the MIT software license, see the accompanying
|
|
||||||
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
|
||||||
|
|
||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
package cash.z.wallet.sdk.rpc;
|
package cash.z.wallet.sdk.rpc;
|
||||||
option go_package = ".;walletrpc";
|
option go_package = "walletrpc";
|
||||||
option swift_prefix = "";
|
|
||||||
import "compact_formats.proto";
|
import "compact_formats.proto";
|
||||||
|
|
||||||
// A BlockID message contains identifiers to select a block: a height or a
|
// A BlockID message contains identifiers to select a block: a height or a
|
||||||
// hash. Specification by hash is not implemented, but may be in the future.
|
// hash. If the hash is present it takes precedence.
|
||||||
message BlockID {
|
message BlockID {
|
||||||
uint64 height = 1;
|
uint64 height = 1;
|
||||||
bytes hash = 2;
|
bytes hash = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// BlockRange specifies a series of blocks from start to end inclusive.
|
// BlockRange technically allows ranging from hash to hash etc but this is not
|
||||||
// Both BlockIDs must be heights; specification by hash is not yet supported.
|
// currently intended for support, though there is no reason you couldn't do
|
||||||
|
// it. Further permutations are left as an exercise.
|
||||||
message BlockRange {
|
message BlockRange {
|
||||||
BlockID start = 1;
|
BlockID start = 1;
|
||||||
BlockID end = 2;
|
BlockID end = 2;
|
||||||
@@ -24,154 +21,73 @@ message BlockRange {
|
|||||||
|
|
||||||
// A TxFilter contains the information needed to identify a particular
|
// A TxFilter contains the information needed to identify a particular
|
||||||
// transaction: either a block and an index, or a direct transaction hash.
|
// transaction: either a block and an index, or a direct transaction hash.
|
||||||
// Currently, only specification by hash is supported.
|
|
||||||
message TxFilter {
|
message TxFilter {
|
||||||
BlockID block = 1; // block identifier, height or hash
|
BlockID block = 1;
|
||||||
uint64 index = 2; // index within the block
|
uint64 index = 2;
|
||||||
bytes hash = 3; // transaction ID (hash, txid)
|
bytes hash = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RawTransaction contains the complete transaction data. It also optionally includes
|
// RawTransaction contains the complete transaction data. It also optionally includes
|
||||||
// the block height in which the transaction was included.
|
// the block height in which the transaction was included
|
||||||
message RawTransaction {
|
message RawTransaction {
|
||||||
bytes data = 1; // exact data returned by Zcash 'getrawtransaction'
|
bytes data = 1;
|
||||||
uint64 height = 2; // height that the transaction was mined (or -1)
|
uint64 height = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// A SendResponse encodes an error code and a string. It is currently used
|
|
||||||
// only by SendTransaction(). If error code is zero, the operation was
|
|
||||||
// successful; if non-zero, it and the message specify the failure.
|
|
||||||
message SendResponse {
|
message SendResponse {
|
||||||
int32 errorCode = 1;
|
int32 errorCode = 1;
|
||||||
string errorMessage = 2;
|
string errorMessage = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chainspec is a placeholder to allow specification of a particular chain fork.
|
// Empty placeholder. Someday we may want to specify e.g. a particular chain fork.
|
||||||
message ChainSpec {}
|
message ChainSpec {}
|
||||||
|
|
||||||
// Empty is for gRPCs that take no arguments, currently only GetLightdInfo.
|
|
||||||
message Empty {}
|
message Empty {}
|
||||||
|
|
||||||
// LightdInfo returns various information about this lightwalletd instance
|
|
||||||
// and the state of the blockchain.
|
|
||||||
message LightdInfo {
|
message LightdInfo {
|
||||||
string version = 1;
|
string version = 1;
|
||||||
string vendor = 2;
|
string vendor = 2;
|
||||||
bool taddrSupport = 3; // true
|
bool taddrSupport = 3;
|
||||||
string chainName = 4; // either "main" or "test"
|
string chainName = 4;
|
||||||
uint64 saplingActivationHeight = 5; // depends on mainnet or testnet
|
uint64 saplingActivationHeight = 5;
|
||||||
string consensusBranchId = 6; // protocol identifier, see consensus/upgrades.cpp
|
string consensusBranchId = 6; // This should really be u32 or []byte, but string for readability
|
||||||
uint64 blockHeight = 7; // latest block on the best chain
|
uint64 blockHeight = 7;
|
||||||
string gitCommit = 8;
|
uint64 difficulty = 8;
|
||||||
string branch = 9;
|
uint64 longestchain = 9;
|
||||||
string buildDate = 10;
|
uint64 notarized = 10;
|
||||||
string buildUser = 11;
|
}
|
||||||
uint64 estimatedHeight = 12; // less than tip height if zcashd is syncing
|
message Coinsupply {
|
||||||
string zcashdBuild = 13; // example: "v4.1.1-877212414"
|
string result = 1;
|
||||||
string zcashdSubversion = 14; // example: "/MagicBean:4.1.1/"
|
string coin = 2;
|
||||||
|
uint64 height = 3;
|
||||||
|
uint64 supply = 4;
|
||||||
|
uint64 zfunds = 5;
|
||||||
|
uint64 total = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TransparentAddress {
|
||||||
|
string address = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransparentAddressBlockFilter restricts the results to the given address
|
|
||||||
// or block range.
|
|
||||||
message TransparentAddressBlockFilter {
|
message TransparentAddressBlockFilter {
|
||||||
string address = 1; // t-address
|
|
||||||
BlockRange range = 2; // start, end heights
|
|
||||||
}
|
|
||||||
|
|
||||||
// Duration is currently used only for testing, so that the Ping rpc
|
|
||||||
// can simulate a delay, to create many simultaneous connections. Units
|
|
||||||
// are microseconds.
|
|
||||||
message Duration {
|
|
||||||
int64 intervalUs = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// PingResponse is used to indicate concurrency, how many Ping rpcs
|
|
||||||
// are executing upon entry and upon exit (after the delay).
|
|
||||||
// This rpc is used for testing only.
|
|
||||||
message PingResponse {
|
|
||||||
int64 entry = 1;
|
|
||||||
int64 exit = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Address {
|
|
||||||
string address = 1;
|
string address = 1;
|
||||||
}
|
BlockRange range = 2;
|
||||||
message AddressList {
|
|
||||||
repeated string addresses = 1;
|
|
||||||
}
|
|
||||||
message Balance {
|
|
||||||
int64 valueZat = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message Exclude {
|
|
||||||
repeated bytes txid = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The TreeState is derived from the Zcash z_gettreestate rpc.
|
|
||||||
message TreeState {
|
|
||||||
string network = 1; // "main" or "test"
|
|
||||||
uint64 height = 2;
|
|
||||||
string hash = 3; // block id
|
|
||||||
uint32 time = 4; // Unix epoch time when the block was mined
|
|
||||||
string tree = 5; // sapling commitment tree state
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetAddressUtxosArg {
|
|
||||||
string address = 1;
|
|
||||||
uint64 startHeight = 2;
|
|
||||||
uint32 maxEntries = 3; // zero means unlimited
|
|
||||||
}
|
|
||||||
message GetAddressUtxosReply {
|
|
||||||
bytes txid = 1;
|
|
||||||
int32 index = 2;
|
|
||||||
bytes script = 3;
|
|
||||||
int64 valueZat = 4;
|
|
||||||
uint64 height = 5;
|
|
||||||
}
|
|
||||||
message GetAddressUtxosReplyList {
|
|
||||||
repeated GetAddressUtxosReply addressUtxos = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
service CompactTxStreamer {
|
service CompactTxStreamer {
|
||||||
// Return the height of the tip of the best chain
|
// Compact Blocks
|
||||||
rpc GetLatestBlock(ChainSpec) returns (BlockID) {}
|
rpc GetLatestBlock(ChainSpec) returns (BlockID) {}
|
||||||
// Return the compact block corresponding to the given block identifier
|
|
||||||
rpc GetBlock(BlockID) returns (CompactBlock) {}
|
rpc GetBlock(BlockID) returns (CompactBlock) {}
|
||||||
// Return a list of consecutive compact blocks
|
|
||||||
rpc GetBlockRange(BlockRange) returns (stream CompactBlock) {}
|
rpc GetBlockRange(BlockRange) returns (stream CompactBlock) {}
|
||||||
|
|
||||||
// Return the requested full (not compact) transaction (as from zcashd)
|
// Transactions
|
||||||
rpc GetTransaction(TxFilter) returns (RawTransaction) {}
|
rpc GetTransaction(TxFilter) returns (RawTransaction) {}
|
||||||
// Submit the given transaction to the Zcash network
|
|
||||||
rpc SendTransaction(RawTransaction) returns (SendResponse) {}
|
rpc SendTransaction(RawTransaction) returns (SendResponse) {}
|
||||||
|
|
||||||
// Return the txids corresponding to the given t-address within the given block range
|
// t-Address support
|
||||||
rpc GetTaddressTxids(TransparentAddressBlockFilter) returns (stream RawTransaction) {}
|
rpc GetAddressTxids(TransparentAddressBlockFilter) returns (stream RawTransaction) {}
|
||||||
rpc GetTaddressBalance(AddressList) returns (Balance) {}
|
|
||||||
rpc GetTaddressBalanceStream(stream Address) returns (Balance) {}
|
|
||||||
|
|
||||||
// Return the compact transactions currently in the mempool; the results
|
// Misc
|
||||||
// can be a few seconds out of date. If the Exclude list is empty, return
|
|
||||||
// all transactions; otherwise return all *except* those in the Exclude list
|
|
||||||
// (if any); this allows the client to avoid receiving transactions that it
|
|
||||||
// already has (from an earlier call to this rpc). The transaction IDs in the
|
|
||||||
// Exclude list can be shortened to any number of bytes to make the request
|
|
||||||
// more bandwidth-efficient; if two or more transactions in the mempool
|
|
||||||
// match a shortened txid, they are all sent (none is excluded). Transactions
|
|
||||||
// in the exclude list that don't exist in the mempool are ignored.
|
|
||||||
rpc GetMempoolTx(Exclude) returns (stream CompactTx) {}
|
|
||||||
|
|
||||||
// GetTreeState returns the note commitment tree state corresponding to the given block.
|
|
||||||
// See section 3.7 of the Zcash protocol specification. It returns several other useful
|
|
||||||
// values also (even though they can be obtained using GetBlock).
|
|
||||||
// The block can be specified by either height or hash.
|
|
||||||
rpc GetTreeState(BlockID) returns (TreeState) {}
|
|
||||||
|
|
||||||
rpc GetAddressUtxos(GetAddressUtxosArg) returns (GetAddressUtxosReplyList) {}
|
|
||||||
rpc GetAddressUtxosStream(GetAddressUtxosArg) returns (stream GetAddressUtxosReply) {}
|
|
||||||
|
|
||||||
// Return information about this lightwalletd instance and the blockchain
|
|
||||||
rpc GetLightdInfo(Empty) returns (LightdInfo) {}
|
rpc GetLightdInfo(Empty) returns (LightdInfo) {}
|
||||||
// Testing-only
|
rpc GetCoinsupply(Empty) returns (Coinsupply) {}
|
||||||
rpc Ping(Duration) returns (PingResponse) {}
|
}
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<bool name="lightwalletd_allow_very_insecure_connections">false</bool>
|
<bool name="lightwalletd_allow_very_insecure_connections">true</bool>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user