2019-10-23 22:21:52 -07:00
|
|
|
package cash.z.wallet.sdk.transaction
|
2019-01-23 02:45:26 -08:00
|
|
|
|
2019-11-01 13:25:28 -07:00
|
|
|
import androidx.paging.PagedList
|
|
|
|
import cash.z.wallet.sdk.entity.*
|
|
|
|
import kotlinx.coroutines.flow.Flow
|
2019-01-23 02:45:26 -08:00
|
|
|
|
2020-02-27 00:25:07 -08:00
|
|
|
/**
|
|
|
|
* Repository of wallet transactions, providing an agnostic interface to the underlying information.
|
|
|
|
*/
|
2019-01-23 02:45:26 -08:00
|
|
|
interface TransactionRepository {
|
2020-02-27 09:28:10 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The last height scanned by this repository.
|
|
|
|
*
|
|
|
|
* @return the last height scanned by this repository.
|
|
|
|
*/
|
2019-02-05 10:19:06 -08:00
|
|
|
fun lastScannedHeight(): Int
|
2020-02-27 09:28:10 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-02-24 11:18:46 -08:00
|
|
|
fun isInitialized(): Boolean
|
2020-02-27 09:28:10 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-11-22 23:18:20 -08:00
|
|
|
suspend fun findEncodedTransactionById(txId: Long): EncodedTransaction?
|
2020-02-27 09:28:10 -08:00
|
|
|
|
2020-03-25 14:58:08 -07:00
|
|
|
/**
|
|
|
|
* 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>
|
|
|
|
|
2020-02-27 09:28:10 -08:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-11-22 23:18:20 -08:00
|
|
|
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
|
|
|
|
//
|
|
|
|
|
2020-02-27 09:28:10 -08:00
|
|
|
/** A flow of all the inbound confirmed transactions */
|
2019-11-01 13:25:28 -07:00
|
|
|
val receivedTransactions: Flow<PagedList<ConfirmedTransaction>>
|
2020-02-27 09:28:10 -08:00
|
|
|
/** A flow of all the outbound confirmed transactions */
|
2019-11-01 13:25:28 -07:00
|
|
|
val sentTransactions: Flow<PagedList<ConfirmedTransaction>>
|
2020-02-27 09:28:10 -08:00
|
|
|
/** A flow of all the inbound and outbound confirmed transactions */
|
2019-11-01 13:25:28 -07:00
|
|
|
val allTransactions: Flow<PagedList<ConfirmedTransaction>>
|
2019-01-23 02:45:26 -08:00
|
|
|
}
|