New: Add lightwalletd service for fetching t-addr txs.

This commit is contained in:
Kevin Gorham 2020-08-13 20:44:05 -04:00
parent fafc749394
commit 816d1afbb3
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
2 changed files with 24 additions and 0 deletions

View File

@ -97,6 +97,20 @@ class LightWalletGrpcService private constructor(
return channel.createStub().getTransaction(Service.TxFilter.newBuilder().setHash(ByteString.copyFrom(txId)).build())
}
override fun getTAddressTransactions(
tAddress: String,
blockHeightRange: IntRange
): List<Service.RawTransaction> {
if (blockHeightRange.isEmpty() || tAddress.isBlank()) return listOf()
channel.resetConnectBackoff()
val result = channel.createStub().getAddressTxids(
Service.TransparentAddressBlockFilter.newBuilder().setAddress(tAddress)
.setRange(blockHeightRange.toBlockRange()).build()
)
return result.toList()
}
override fun reconnect() {
twig("closing existing channel and then reconnecting to" +
" ${connectionInfo.host}:${connectionInfo.port}?usePlaintext=${connectionInfo.usePlaintext}")

View File

@ -1,5 +1,6 @@
package cash.z.ecc.android.sdk.service
import cash.z.ecc.android.sdk.db.entity.ConfirmedTransaction
import cash.z.wallet.sdk.rpc.CompactFormats
import cash.z.wallet.sdk.rpc.Service
@ -52,6 +53,15 @@ interface LightWalletService {
*/
fun submitTransaction(spendTransaction: ByteArray): Service.SendResponse
/**
* Gets all the transactions for a given t-address over the given range. In practice, this is
* effectively the same as an RPC call to a node that's running an insight server. The data is
* indexed and responses are fairly quick.
*
* @return a list of transactions that correspond to the given address for the given range.
*/
fun getTAddressTransactions(tAddress: String, blockHeightRange: IntRange): List<Service.RawTransaction>
/**
* Fetch the details of a known transaction.
*