2023-05-18 04:36:15 -07:00
|
|
|
package cash.z.ecc.android.sdk.internal
|
2023-04-10 07:35:40 -07:00
|
|
|
|
2024-03-18 19:06:08 -07:00
|
|
|
import cash.z.ecc.android.sdk.exception.InitializeException
|
2023-04-10 07:35:40 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.JniBlockMeta
|
2023-07-17 06:27:54 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.ScanRange
|
2024-01-24 13:51:45 -08:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.ScanSummary
|
2023-07-19 23:42:19 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.SubtreeRoot
|
2023-09-11 10:11:03 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.TreeState
|
2023-11-08 01:57:23 -08:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.WalletSummary
|
2024-04-14 12:28:07 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.ZcashProtocol
|
2023-04-10 07:35:40 -07:00
|
|
|
import cash.z.ecc.android.sdk.model.Account
|
|
|
|
import cash.z.ecc.android.sdk.model.BlockHeight
|
2023-08-07 12:17:28 -07:00
|
|
|
import cash.z.ecc.android.sdk.model.FirstClassByteArray
|
2024-01-08 15:02:52 -08:00
|
|
|
import cash.z.ecc.android.sdk.model.Proposal
|
2023-07-17 03:50:53 -07:00
|
|
|
import cash.z.ecc.android.sdk.model.UnifiedSpendingKey
|
2024-02-07 08:33:47 -08:00
|
|
|
import cash.z.ecc.android.sdk.model.Zatoshi
|
2023-07-17 03:50:53 -07:00
|
|
|
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
2023-04-10 07:35:40 -07:00
|
|
|
|
|
|
|
@Suppress("TooManyFunctions")
|
|
|
|
internal interface TypesafeBackend {
|
2023-07-17 03:50:53 -07:00
|
|
|
val network: ZcashNetwork
|
|
|
|
|
2023-09-05 18:54:59 -07:00
|
|
|
suspend fun createAccountAndGetSpendingKey(
|
2023-04-10 07:35:40 -07:00
|
|
|
seed: ByteArray,
|
2023-09-11 10:11:03 -07:00
|
|
|
treeState: TreeState,
|
2023-09-05 18:54:59 -07:00
|
|
|
recoverUntil: BlockHeight?
|
|
|
|
): UnifiedSpendingKey
|
2023-07-17 03:50:53 -07:00
|
|
|
|
|
|
|
@Suppress("LongParameterList")
|
2024-01-08 15:02:52 -08:00
|
|
|
suspend fun proposeTransfer(
|
2024-02-19 14:09:01 -08:00
|
|
|
account: Account,
|
2023-07-17 03:50:53 -07:00
|
|
|
to: String,
|
|
|
|
value: Long,
|
|
|
|
memo: ByteArray? = byteArrayOf()
|
2024-01-08 15:02:52 -08:00
|
|
|
): Proposal
|
2023-07-17 03:50:53 -07:00
|
|
|
|
2024-01-08 15:02:52 -08:00
|
|
|
suspend fun proposeShielding(
|
2024-02-19 14:09:01 -08:00
|
|
|
account: Account,
|
2024-02-27 11:00:06 -08:00
|
|
|
shieldingThreshold: Long,
|
2024-02-27 17:44:12 -08:00
|
|
|
memo: ByteArray? = byteArrayOf(),
|
|
|
|
transparentReceiver: String? = null
|
|
|
|
): Proposal?
|
2024-01-08 15:02:52 -08:00
|
|
|
|
2024-03-01 10:51:54 -08:00
|
|
|
suspend fun createProposedTransactions(
|
2024-01-08 15:02:52 -08:00
|
|
|
proposal: Proposal,
|
|
|
|
usk: UnifiedSpendingKey
|
2024-03-01 10:51:54 -08:00
|
|
|
): List<FirstClassByteArray>
|
2023-07-17 03:50:53 -07:00
|
|
|
|
2023-04-10 07:35:40 -07:00
|
|
|
suspend fun getCurrentAddress(account: Account): String
|
|
|
|
|
|
|
|
suspend fun listTransparentReceivers(account: Account): List<String>
|
|
|
|
|
|
|
|
fun getBranchIdForHeight(height: BlockHeight): Long
|
|
|
|
|
|
|
|
suspend fun getNearestRewindHeight(height: BlockHeight): BlockHeight
|
|
|
|
|
2023-06-09 01:29:33 -07:00
|
|
|
suspend fun rewindToHeight(height: BlockHeight)
|
2023-04-10 07:35:40 -07:00
|
|
|
|
2023-09-06 12:28:45 -07:00
|
|
|
suspend fun getLatestCacheHeight(): BlockHeight?
|
2023-04-10 07:35:40 -07:00
|
|
|
|
|
|
|
suspend fun findBlockMetadata(height: BlockHeight): JniBlockMeta?
|
|
|
|
|
|
|
|
suspend fun rewindBlockMetadataToHeight(height: BlockHeight)
|
|
|
|
|
2024-02-07 08:33:47 -08:00
|
|
|
suspend fun getDownloadedUtxoBalance(address: String): Zatoshi
|
2023-07-17 03:50:53 -07:00
|
|
|
|
|
|
|
@Suppress("LongParameterList")
|
|
|
|
suspend fun putUtxo(
|
|
|
|
tAddress: String,
|
|
|
|
txId: ByteArray,
|
|
|
|
index: Int,
|
|
|
|
script: ByteArray,
|
|
|
|
value: Long,
|
|
|
|
height: BlockHeight
|
|
|
|
)
|
|
|
|
|
2024-01-04 12:21:32 -08:00
|
|
|
suspend fun getMemoAsUtf8(
|
|
|
|
txId: ByteArray,
|
2024-04-14 12:28:07 -07:00
|
|
|
protocol: ZcashProtocol,
|
2024-01-04 12:21:32 -08:00
|
|
|
outputIndex: Int
|
|
|
|
): String?
|
2023-07-17 03:50:53 -07:00
|
|
|
|
2024-03-18 19:06:08 -07:00
|
|
|
@Throws(InitializeException::class)
|
|
|
|
suspend fun initDataDb(seed: ByteArray?)
|
2023-07-17 03:50:53 -07:00
|
|
|
|
2023-07-19 23:42:19 -07:00
|
|
|
/**
|
|
|
|
* @throws RuntimeException as a common indicator of the operation failure
|
|
|
|
*/
|
|
|
|
@Throws(RuntimeException::class)
|
2024-04-09 04:49:52 -07:00
|
|
|
suspend fun putSubtreeRoots(
|
|
|
|
saplingStartIndex: UInt,
|
|
|
|
saplingRoots: List<SubtreeRoot>,
|
|
|
|
orchardStartIndex: UInt,
|
|
|
|
orchardRoots: List<SubtreeRoot>,
|
2023-07-19 23:42:19 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws RuntimeException as a common indicator of the operation failure
|
|
|
|
*/
|
|
|
|
@Throws(RuntimeException::class)
|
|
|
|
suspend fun updateChainTip(height: BlockHeight)
|
|
|
|
|
2023-09-06 12:28:45 -07:00
|
|
|
/**
|
|
|
|
* Returns the height to which the wallet has been fully scanned.
|
|
|
|
*
|
|
|
|
* This is the height for which the wallet has fully trial-decrypted this and all
|
|
|
|
* preceding blocks above the wallet's birthday height.
|
|
|
|
*
|
|
|
|
* @return The height to which the wallet has been fully scanned, or Null if no blocks have been scanned.
|
|
|
|
* @throws RuntimeException as a common indicator of the operation failure
|
|
|
|
*/
|
|
|
|
suspend fun getFullyScannedHeight(): BlockHeight?
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the maximum height that the wallet has scanned.
|
|
|
|
*
|
|
|
|
* If the wallet is fully synced, this will be equivalent to `getFullyScannedHeight`;
|
|
|
|
* otherwise the maximal scanned height is likely to be greater than the fully scanned
|
|
|
|
* height due to the fact that out-of-order scanning can leave gaps.
|
|
|
|
*
|
|
|
|
* @return The maximum height that the wallet has scanned, or Null if no blocks have been scanned.
|
|
|
|
* @throws RuntimeException as a common indicator of the operation failure
|
|
|
|
*/
|
|
|
|
suspend fun getMaxScannedHeight(): BlockHeight?
|
|
|
|
|
2023-07-17 03:50:53 -07:00
|
|
|
/**
|
|
|
|
* @throws RuntimeException as a common indicator of the operation failure
|
|
|
|
*/
|
|
|
|
@Throws(RuntimeException::class)
|
2024-01-04 12:21:32 -08:00
|
|
|
suspend fun scanBlocks(
|
|
|
|
fromHeight: BlockHeight,
|
2024-04-09 04:49:52 -07:00
|
|
|
fromState: TreeState,
|
2024-01-04 12:21:32 -08:00
|
|
|
limit: Long
|
2024-01-24 13:51:45 -08:00
|
|
|
): ScanSummary
|
2023-07-11 08:17:44 -07:00
|
|
|
|
2023-09-05 18:54:59 -07:00
|
|
|
/**
|
|
|
|
* @throws RuntimeException as a common indicator of the operation failure
|
|
|
|
*/
|
|
|
|
@Throws(RuntimeException::class)
|
2023-11-08 01:57:23 -08:00
|
|
|
suspend fun getWalletSummary(): WalletSummary?
|
2023-09-05 18:54:59 -07:00
|
|
|
|
2023-07-11 08:17:44 -07:00
|
|
|
/**
|
|
|
|
* @throws RuntimeException as a common indicator of the operation failure
|
|
|
|
*/
|
|
|
|
@Throws(RuntimeException::class)
|
2023-07-17 06:27:54 -07:00
|
|
|
suspend fun suggestScanRanges(): List<ScanRange>
|
2023-07-17 03:50:53 -07:00
|
|
|
|
|
|
|
suspend fun decryptAndStoreTransaction(tx: ByteArray)
|
|
|
|
|
|
|
|
fun getSaplingReceiver(ua: String): String?
|
|
|
|
|
|
|
|
fun getTransparentReceiver(ua: String): String?
|
|
|
|
|
|
|
|
suspend fun initBlockMetaDb(): Int
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws RuntimeException as a common indicator of the operation failure
|
|
|
|
*/
|
|
|
|
@Throws(RuntimeException::class)
|
|
|
|
suspend fun writeBlockMetadata(blockMetadata: List<JniBlockMeta>)
|
|
|
|
|
2024-01-08 09:17:35 -08:00
|
|
|
fun isValidSaplingAddr(addr: String): Boolean
|
2023-07-17 03:50:53 -07:00
|
|
|
|
|
|
|
fun isValidTransparentAddr(addr: String): Boolean
|
|
|
|
|
|
|
|
fun isValidUnifiedAddr(addr: String): Boolean
|
2023-04-10 07:35:40 -07:00
|
|
|
}
|