zcash-android-wallet-sdk/src/main/java/cash/z/wallet/sdk/transaction/TransactionRepository.kt

74 lines
2.7 KiB
Kotlin
Raw Normal View History

2019-10-23 22:21:52 -07:00
package cash.z.wallet.sdk.transaction
2019-11-01 13:25:28 -07:00
import androidx.paging.PagedList
import cash.z.wallet.sdk.entity.*
import kotlinx.coroutines.flow.Flow
2020-02-27 00:25:07 -08:00
/**
* Repository of wallet transactions, providing an agnostic interface to the underlying information.
*/
interface TransactionRepository {
/**
* The last height scanned by this repository.
*
* @return the last height scanned by this repository.
*/
fun lastScannedHeight(): Int
/**
* Returns true when this repository has been initialized and seeded with the initial checkpoint.
*
* @return true when this repository has been initialized and seeded with the initial checkpoint.
*/
fun isInitialized(): Boolean
/**
* Find the encoded transaction associated with the given id.
*
* @param txId the id of the transaction to find.
*
* @return the transaction or null when it cannot be found.
*/
suspend fun findEncodedTransactionById(txId: Long): EncodedTransaction?
/**
* Find all the newly scanned transactions in the given range, including transactions (like
* change or those only identified by nullifiers) which should not appear in the UI. This method
* is intended for use after a scan, in order to collect all the transactions that were
* discovered and then enhance them with additional details. It returns a list to signal that
* the intention is not to add them to a recyclerview or otherwise show in the UI.
*
* @param blockHeightRange the range of blocks to check for transactions.
*
* @return a list of transactions that were mined in the given range, inclusive.
*/
suspend fun findNewTransactions(blockHeightRange: IntRange): List<ConfirmedTransaction>
/**
* Find the mined height that matches the given raw tx_id in bytes. This is useful for matching
* a pending transaction with one that we've decrypted from the blockchain.
*
* @param rawTransactionId the id of the transaction to find.
*
* @return the mined height of the given transaction, if it is known to this wallet.
*/
suspend fun findMinedHeight(rawTransactionId: ByteArray): Int?
2019-11-01 13:25:28 -07:00
/**
* Provides a way for other components to signal that the underlying data has been modified.
*/
fun invalidate()
//
// Transactions
//
/** A flow of all the inbound confirmed transactions */
2019-11-01 13:25:28 -07:00
val receivedTransactions: Flow<PagedList<ConfirmedTransaction>>
/** A flow of all the outbound confirmed transactions */
2019-11-01 13:25:28 -07:00
val sentTransactions: Flow<PagedList<ConfirmedTransaction>>
/** A flow of all the inbound and outbound confirmed transactions */
2019-11-01 13:25:28 -07:00
val allTransactions: Flow<PagedList<ConfirmedTransaction>>
}