ZcashRustBackendWelding
public protocol ZcashRustBackendWelding
Undocumented
-
gets the latest error if available. Clear the existing error
Declaration
Swift
static func lastError() -> RustWeldingError?
-
gets the latest error message from librustzcash. Does not clear existing error
Declaration
Swift
static func getLastError() -> String?
-
initializes the data db
Declaration
Swift
static func initDataDb(dbData: URL) throws
Parameters
dbData
location of the data db sql file
-
Throws
Error when the provided address belongs to another networkDeclaration
Swift
static func isValidShieldedAddress(_ address: String) throws -> Bool
Return Value
true when the address is valid and shielded. Returns false in any other case
-
Throws
Error when the provided address belongs to another networkDeclaration
Swift
static func isValidTransparentAddress(_ address: String) throws -> Bool
Return Value
true when the address is valid and transparent. false in any other case
-
initialize the blocks table from a given checkpoint (birthday)
Declaration
Swift
static func initAccountsTable(dbData: URL, seed: [UInt8], accounts: Int32) -> [String]?
Parameters
dbData
location of the data db
seed
byte array of the zip32 seed
accounts
how many accounts you want to have
-
initialize the blocks table from a given checkpoint (birthday)
Declaration
Swift
static func initBlocksTable(dbData: URL, height: Int32, hash: String, time: UInt32, saplingTree: String) throws
Parameters
dbData
location of the data db
height
represents the block height of the given checkpoint
hash
hash of the merkle tree
time
in milliseconds from reference
saplingTree
hash of the sapling tree
-
gets the address from data db from the given account
Declaration
Swift
static func getAddress(dbData: URL, account: Int32) -> String?
Parameters
dbData
location of the data db
account
index of the given account
Return Value
an optional string with the address if found
-
get the (unverified) balance from the given account
Declaration
Swift
static func getBalance(dbData: URL, account: Int32) -> Int64
Parameters
dbData
location of the data db
account
index of the given account
-
get the verified balance from the given account
Declaration
Swift
static func getVerifiedBalance(dbData: URL, account: Int32) -> Int64
Parameters
dbData
location of the data db
account
index of the given account
-
get received memo from note
Declaration
Swift
static func getReceivedMemoAsUTF8(dbData: URL, idNote: Int64) -> String?
Parameters
dbData
location of the data db file
idNote
note_id of note where the memo is located
-
get sent memo from note
Declaration
Swift
static func getSentMemoAsUTF8(dbData: URL, idNote: Int64) -> String?
Parameters
dbData
location of the data db file
idNote
note_id of note where the memo is located
-
Checks that the scanned blocks in the data database, when combined with the recent `CompactBlock`s in the cache database, form a valid chain. This function is built on the core assumption that the information provided in the cache database is more likely to be accurate than the previously-scanned information. This follows from the design (and trust) assumption that the `lightwalletd` server provides accurate block information as of the time it was requested.
Declaration
Swift
static func validateCombinedChain(dbCache: URL, dbData: URL) -> Int32
Return Value
-1
if the combined chain is valid.upper_bound
if the combined chain is invalid.upper_bound
is the height of the highest invalid block (on the assumption that the highest block in the cache database is correct).0
if there was an error during validation unrelated to chain validity.
Important
This function does not mutate either of the databases. -
rewinds the compact block storage to the given height. clears up all derived data as well
Declaration
Swift
static func rewindToHeight(dbData: URL, height: Int32) -> Bool
Parameters
dbData
location of the data db file
height
height to rewind to
-
Scans new blocks added to the cache for any transactions received by the tracked accounts. This function pays attention only to cached blocks with heights greater than the highest scanned block in
db_data
. Cached blocks with lower heights are not verified against previously-scanned blocks. In particular, this function assumes that the caller is handling rollbacks. For brand-new light client databases, this function starts scanning from the Sapling activation height. This height can be fast-forwarded to a more recent block by calling [zcashlc_init_blocks_table
] before this function. Scanned blocks are required to be height-sequential. If a block is missing from the cache, an error will be signalled.Declaration
Swift
static func scanBlocks(dbCache: URL, dbData: URL) -> Bool
Parameters
dbCache
location of the compact block cache db
dbData
location of the data db file returns false if fails to scan.
-
Scans a transaction for any information that can be decrypted by the accounts in the wallet, and saves it to the wallet.
Declaration
Swift
static func decryptAndStoreTransaction(dbData: URL, tx: [UInt8]) -> Bool
Parameters
dbData
location of the data db file
tx
the transaction to decrypt returns false if fails to decrypt.
-
Creates a transaction to the given address from the given account
Declaration
Swift
static func createToAddress(dbData: URL, account: Int32, extsk: String, to: String, value: Int64, memo: String?, spendParamsPath: String, outputParamsPath: String) -> Int64
Parameters
dbData
URL for the Data DB
account
the account index that will originate the transaction
extsk
extended spending key string
to
recipient address
value
transaction amount in Zatoshi
memo
the memo string for this transaction
spendParamsPath
path escaped String for the filesystem locations where the spend parameters are located
outputParamsPath
path escaped String for the filesystem locations where the output parameters are located
-
Derives a full viewing key from a seed
Throws
RustBackendError if fatal error occursDeclaration
Swift
static func deriveExtendedFullViewingKey(_ spendingKey: String) throws -> String?
Parameters
spendingKey
a string containing the spending key
Return Value
the derived key
-
Derives a set of full viewing keys from a seed
Throws
RustBackendError if fatal error occursDeclaration
Swift
static func deriveExtendedFullViewingKeys(seed: String, accounts: Int32) throws -> [String]?
Parameters
spendingKey
a string containing the spending key
accounts
the number of accounts you want to derive from this seed
Return Value
an array containing the derived keys
-
Derives a set of full viewing keys from a seed
Throws
RustBackendError if fatal error occursDeclaration
Swift
static func deriveExtendedSpendingKeys(seed: String, accounts: Int32) throws -> [String]?
Parameters
seed
a string containing the seed
accounts
the number of accounts you want to derive from this seed
Return Value
an array containing the spending keys