-
- All Implemented Interfaces:
-
cash.z.ecc.android.sdk.internal.Backend
public final class RustBackend implements Backend
Serves as the JNI boundary between the Kotlin and Rust layers. Functions in this class should not be called directly by code outside of the SDK. Instead, one of the higher-level components should be used such as WalletCoordinator.kt or CompactBlockProcessor.kt.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classRustBackend.CompanionExposes all of the librustzcash functions along with helpers for loading the static library.
-
Field Summary
Fields Modifier and Type Field Description private final IntegernetworkIdprivate final FiledataDbFile
-
Method Summary
Modifier and Type Method Description IntegergetNetworkId()FilegetDataDbFile()final Booleanclear(Boolean clearCache, Boolean clearDataDb)This function deletes the data database file and the cache directory (compact blocks files) if set by input parameters. <ERROR CLASS>initBlockMetaDb()<ERROR CLASS>initDataDb(ByteArray seed)Sets up the internal structure of the data database. List<JniAccount>getAccounts()JniAccountgetAccountForUfvk(String ufvk)JniAccountUskcreateAccount(String accountName, String keySource, ByteArray seed, ByteArray treeState, Long recoverUntil)JniAccountimportAccountUfvk(String accountName, String keySource, String ufvk, ByteArray treeState, Long recoverUntil, Integer purpose, ByteArray seedFingerprint, Long zip32AccountIndex)BooleanisSeedRelevantToAnyDerivedAccounts(ByteArray seed)<ERROR CLASS>getCurrentAddress(ByteArray accountUuid)<ERROR CLASS>getSingleUseTransparentAddress(ByteArray accountUuid)<ERROR CLASS>getNextAvailableAddress(ByteArray accountUuid, Integer receiverFlags)StringgetTransparentReceiver(String ua)StringgetSaplingReceiver(String ua)List<String>listTransparentReceivers(ByteArray accountUuid)<ERROR CLASS>getMemoAsUtf8(ByteArray txId, Integer protocol, Integer outputIndex)<ERROR CLASS>writeBlockMetadata(List<JniBlockMeta> blockMetadata)<ERROR CLASS>getLatestCacheHeight()<ERROR CLASS>findBlockMetadata(Long height)<ERROR CLASS>rewindBlockMetadataToHeight(Long height)LonggetTotalTransparentBalance(String address)JniRewindResultrewindToHeight(Long height)Rewinds the data database to at most the given height. <ERROR CLASS>putSubtreeRoots(Long saplingStartIndex, List<JniSubtreeRoot> saplingRoots, Long orchardStartIndex, List<JniSubtreeRoot> orchardRoots)<ERROR CLASS>updateChainTip(Long height)<ERROR CLASS>getFullyScannedHeight()Returns the height to which the wallet has been fully scanned. <ERROR CLASS>getMaxScannedHeight()Returns the maximum height that the wallet has scanned. JniWalletSummarygetWalletSummary()List<JniScanRange>suggestScanRanges()JniScanSummaryscanBlocks(Long fromHeight, ByteArray fromState, Long limit)List<JniTransactionDataRequest>transactionDataRequests()<ERROR CLASS>fixWitnesses()This function calls check_witnessesandqueue_rescansfrom the underlying librustzcash internally.ByteArraydecryptAndStoreTransaction(ByteArray tx, Long minedHeight)ProposalUnsafeproposeTransferFromUri(ByteArray accountUuid, String uri)ProposalUnsafeproposeTransfer(ByteArray accountUuid, String to, Long value, ByteArray memo)ProposalUnsafeproposeShielding(ByteArray accountUuid, Long shieldingThreshold, ByteArray memo, String transparentReceiver)List<ByteArray>createProposedTransactions(ProposalUnsafe proposal, ByteArray unifiedSpendingKey)ByteArraycreatePcztFromProposal(ByteArray accountUuid, ProposalUnsafe proposal)Creates a partially-created (unsigned without proofs) transaction from the given proposal. ByteArrayredactPcztForSigner(ByteArray pczt)Redacts information from the given PCZT that is unnecessary for the Signer role. BooleanpcztRequiresSaplingProofs(ByteArray pczt)Checks whether the caller needs to have downloaded the Sapling parameters. ByteArrayaddProofsToPczt(ByteArray pczt)Adds proofs to the given PCZT. ByteArrayextractAndStoreTxFromPczt(ByteArray pcztWithProofs, ByteArray pcztWithSignatures)Takes a PCZT that has been separately proven and signed, finalizes it, and stores it in the wallet. <ERROR CLASS>putUtxo(ByteArray txId, Integer index, ByteArray script, Long value, Long height)<ERROR CLASS>setTransactionStatus(ByteArray txId, Long status)BooleanisValidSaplingAddr(String addr)BooleanisValidTransparentAddr(String addr)BooleanisValidUnifiedAddr(String addr)BooleanisValidTexAddr(String addr)LonggetBranchIdForHeight(Long height)-
-
Method Detail
-
getNetworkId
Integer getNetworkId()
-
getDataDbFile
File getDataDbFile()
-
clear
final Boolean clear(Boolean clearCache, Boolean clearDataDb)
This function deletes the data database file and the cache directory (compact blocks files) if set by input parameters.
- Parameters:
clearCache- to request the cache directory and its content deletionclearDataDb- to request the data database file deletion
-
initBlockMetaDb
<ERROR CLASS> initBlockMetaDb()
-
initDataDb
<ERROR CLASS> initDataDb(ByteArray seed)
Sets up the internal structure of the data database.
If
seedisnull, database migrations will be attempted without it.
-
getAccounts
List<JniAccount> getAccounts()
-
getAccountForUfvk
JniAccount getAccountForUfvk(String ufvk)
-
createAccount
JniAccountUsk createAccount(String accountName, String keySource, ByteArray seed, ByteArray treeState, Long recoverUntil)
-
importAccountUfvk
JniAccount importAccountUfvk(String accountName, String keySource, String ufvk, ByteArray treeState, Long recoverUntil, Integer purpose, ByteArray seedFingerprint, Long zip32AccountIndex)
-
isSeedRelevantToAnyDerivedAccounts
Boolean isSeedRelevantToAnyDerivedAccounts(ByteArray seed)
-
getCurrentAddress
<ERROR CLASS> getCurrentAddress(ByteArray accountUuid)
-
getSingleUseTransparentAddress
<ERROR CLASS> getSingleUseTransparentAddress(ByteArray accountUuid)
-
getNextAvailableAddress
<ERROR CLASS> getNextAvailableAddress(ByteArray accountUuid, Integer receiverFlags)
-
getTransparentReceiver
String getTransparentReceiver(String ua)
-
getSaplingReceiver
String getSaplingReceiver(String ua)
-
listTransparentReceivers
List<String> listTransparentReceivers(ByteArray accountUuid)
-
getMemoAsUtf8
<ERROR CLASS> getMemoAsUtf8(ByteArray txId, Integer protocol, Integer outputIndex)
-
writeBlockMetadata
<ERROR CLASS> writeBlockMetadata(List<JniBlockMeta> blockMetadata)
-
getLatestCacheHeight
<ERROR CLASS> getLatestCacheHeight()
-
findBlockMetadata
<ERROR CLASS> findBlockMetadata(Long height)
-
rewindBlockMetadataToHeight
<ERROR CLASS> rewindBlockMetadataToHeight(Long height)
-
getTotalTransparentBalance
Long getTotalTransparentBalance(String address)
-
rewindToHeight
JniRewindResult rewindToHeight(Long height)
Rewinds the data database to at most the given height.
-
putSubtreeRoots
<ERROR CLASS> putSubtreeRoots(Long saplingStartIndex, List<JniSubtreeRoot> saplingRoots, Long orchardStartIndex, List<JniSubtreeRoot> orchardRoots)
-
updateChainTip
<ERROR CLASS> updateChainTip(Long height)
-
getFullyScannedHeight
<ERROR CLASS> getFullyScannedHeight()
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.
-
getMaxScannedHeight
<ERROR CLASS> getMaxScannedHeight()
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.
-
getWalletSummary
JniWalletSummary getWalletSummary()
-
suggestScanRanges
List<JniScanRange> suggestScanRanges()
-
scanBlocks
JniScanSummary scanBlocks(Long fromHeight, ByteArray fromState, Long limit)
-
transactionDataRequests
List<JniTransactionDataRequest> transactionDataRequests()
-
fixWitnesses
<ERROR CLASS> fixWitnesses()
This function calls
check_witnessesandqueue_rescansfrom the underlying librustzcash internally. This method is intended for repairing wallets that broke due to bugs inshardtree.check_witnesses: It attempts to construct a witness for each note belonging to the wallet that is believed by the wallet to currently be spendable, and returns a vector of the ranges that must be rescanned in order to correct missing witness data.queue_rescans: Updates the scan queue by inserting scan ranges for the given range of block heights, with the specified scanning priority.
-
decryptAndStoreTransaction
ByteArray decryptAndStoreTransaction(ByteArray tx, Long minedHeight)
-
proposeTransferFromUri
ProposalUnsafe proposeTransferFromUri(ByteArray accountUuid, String uri)
-
proposeTransfer
ProposalUnsafe proposeTransfer(ByteArray accountUuid, String to, Long value, ByteArray memo)
-
proposeShielding
ProposalUnsafe proposeShielding(ByteArray accountUuid, Long shieldingThreshold, ByteArray memo, String transparentReceiver)
-
createProposedTransactions
List<ByteArray> createProposedTransactions(ProposalUnsafe proposal, ByteArray unifiedSpendingKey)
-
createPcztFromProposal
ByteArray createPcztFromProposal(ByteArray accountUuid, ProposalUnsafe proposal)
Creates a partially-created (unsigned without proofs) transaction from the given proposal.
Do not call this multiple times in parallel, or you will generate PCZT instances that, if finalized, would double-spend the same notes.
-
redactPcztForSigner
ByteArray redactPcztForSigner(ByteArray pczt)
Redacts information from the given PCZT that is unnecessary for the Signer role.
-
pcztRequiresSaplingProofs
Boolean pcztRequiresSaplingProofs(ByteArray pczt)
Checks whether the caller needs to have downloaded the Sapling parameters.
-
addProofsToPczt
ByteArray addProofsToPczt(ByteArray pczt)
Adds proofs to the given PCZT.
-
extractAndStoreTxFromPczt
ByteArray extractAndStoreTxFromPczt(ByteArray pcztWithProofs, ByteArray pcztWithSignatures)
Takes a PCZT that has been separately proven and signed, finalizes it, and stores it in the wallet.
-
putUtxo
<ERROR CLASS> putUtxo(ByteArray txId, Integer index, ByteArray script, Long value, Long height)
-
setTransactionStatus
<ERROR CLASS> setTransactionStatus(ByteArray txId, Long status)
-
isValidSaplingAddr
Boolean isValidSaplingAddr(String addr)
-
isValidTransparentAddr
Boolean isValidTransparentAddr(String addr)
-
isValidUnifiedAddr
Boolean isValidUnifiedAddr(String addr)
-
isValidTexAddr
Boolean isValidTexAddr(String addr)
-
getBranchIdForHeight
Long getBranchIdForHeight(Long height)
-
-
-
-