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, networkType: NetworkType) throws

    Parameters

    dbData

    location of the data db sql file

  • Throws

    Error when the provided address belongs to another network

    Declaration

    Swift

    static func isValidShieldedAddress(_ address: String, networkType: NetworkType) 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 network

    Declaration

    Swift

    static func isValidTransparentAddress(_ address: String, networkType: NetworkType) throws -> Bool

    Return Value

    true when the address is valid and transparent. false in any other case

  • Throws

    Error when there’s another problem not related to validity of the string in question

    Declaration

    Swift

    static func isValidExtendedFullViewingKey(_ key: String, networkType: NetworkType) throws -> Bool

    Return Value

    true when the address is valid and transparent. false in any other case

  • initialize the accounts table from a given seed and a number of accounts

    Declaration

    Swift

    static func initAccountsTable(dbData: URL, seed: [UInt8], accounts: Int32, networkType: NetworkType) -> [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 accounts table from a set of unified viewing keys

    Declaration

    Swift

    static func initAccountsTable(dbData: URL, uvks: [UnifiedViewingKey], networkType: NetworkType) throws -> Bool

    Parameters

    dbData

    location of the data db

    uvks

    an array of UnifiedViewingKeys

  • Undocumented

    Declaration

    Swift

    static func initBlocksTable(
        dbData: URL,
        height: Int32,
        hash: String,
        time: UInt32,
        saplingTree: String,
        networkType: NetworkType
    ) throws
  • gets the address from data db from the given account

    Declaration

    Swift

    static func getAddress(dbData: URL, account: Int32, networkType: NetworkType) -> 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, networkType: NetworkType) -> 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, networkType: NetworkType) -> Int64

    Parameters

    dbData

    location of the data db

    account

    index of the given account

  • Get the verified cached transparent balance for the given address

    Declaration

    Swift

    static func getVerifiedTransparentBalance(dbData: URL, address: String, networkType: NetworkType) throws -> Int64
  • Get the verified cached transparent balance for the given address

    Declaration

    Swift

    static func getTransparentBalance(dbData: URL, address: String, networkType: NetworkType) throws -> Int64
  • get received memo from note

    Declaration

    Swift

    static func getReceivedMemoAsUTF8(dbData: URL, idNote: Int64, networkType: NetworkType) -> 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, networkType: NetworkType) -> 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 CompactBlocks 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. - Returns: * -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.

    Declaration

    Swift

    static func validateCombinedChain(dbCache: URL, dbData: URL, networkType: NetworkType) -> Int32
  • Returns the nearest height where a rewind is possible. Currently prunning gets rid of sapling witnesses older than 100 blocks. So in order to reconstruct the witness tree that allows to spend notes from the given wallet the rewind can’t be more than 100 block or back to the oldest unspent note that this wallet contains.

    Declaration

    Swift

    static func getNearestRewindHeight(dbData: URL, height: Int32, networkType: NetworkType) -> Int32

    Parameters

    dbData

    location of the data db file

    height

    height you would like to rewind to.

  • 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, networkType: NetworkType) -> Bool

    Parameters

    dbData

    location of the data db file

    height

    height to rewind to. DON’T PASS ARBITRARY HEIGHT. Use getNearestRewindHeight when unsure

  • 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, limit: UInt32, networkType: NetworkType) -> Bool

    Parameters

    dbCache

    location of the compact block cache db

    dbData

    location of the data db file

    limit

    scan up to limit blocks. pass 0 to set no limit. returns false if fails to scan.

  • puts a UTXO into the data db database

    Declaration

    Swift

    static func putUnspentTransparentOutput(
        dbData: URL,
        address: String,
        txid: [UInt8],
        index: Int,
        script: [UInt8],
        value: Int64,
        height: BlockHeight,
        networkType: NetworkType
    ) throws -> Bool

    Parameters

    dbData

    location of the data db file

    address

    the address of the UTXO

    txid

    the txid bytes for the UTXO

    index

    the index of the UTXO

    value

    the value of the UTXO

    height

    the mined height for the UTXO

    Return Value

    true if the operation succeded or false otherwise

  • clears the cached utxos for the given address from the specified height on

    Declaration

    Swift

    static func clearUtxos(dbData: URL, address: String, sinceHeight: BlockHeight, networkType: NetworkType) throws -> Int32

    Parameters

    dbData

    location of the data db file

    address

    the address of the UTXO

    sinceheight

    clear the UXTOs from that address on

    Return Value

    the amount of UTXOs cleared or -1 on error

  • Gets the balance of the previously downloaded UTXOs

    Throws

    Rustwelding Error if something fails

    Declaration

    Swift

    static func downloadedUtxoBalance(dbData: URL, address: String, networkType: NetworkType) throws -> WalletBalance

    Parameters

    dbData

    location of the data db file

    address

    the address of the UTXO

    Return Value

    the wallet balance containing verified and total balance.

  • 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,
        txBytes: [UInt8],
        minedHeight: Int32,
        networkType: NetworkType
    ) -> Bool

    Parameters

    dbData

    location of the data db file

    tx

    the transaction to decrypt

    minedHeight

    height on which this transaction was mined. this is used to fetch the consensus branch ID. returns false if fails to decrypt.

  • Undocumented

    Declaration

    Swift

    static func createToAddress(
        dbData: URL,
        account: Int32,
        extsk: String,
        to address: String,
        value: Int64,
        memo: String?,
        spendParamsPath: String,
        outputParamsPath: String,
        networkType: NetworkType
    ) -> Int64
  • Undocumented

    Declaration

    Swift

    static func shieldFunds(
        dbCache: URL,
        dbData: URL,
        account: Int32,
        tsk: String,
        extsk: String,
        memo: String?,
        spendParamsPath: String,
        outputParamsPath: String,
        networkType: NetworkType
    ) -> Int64
  • Derives a full viewing key from a seed

    Throws

    RustBackendError if fatal error occurs

    Declaration

    Swift

    static func deriveExtendedFullViewingKey(_ spendingKey: String, networkType: NetworkType) 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 occurs

    Declaration

    Swift

    static func deriveExtendedFullViewingKeys(seed: [UInt8], accounts: Int32, networkType: NetworkType) 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 occurs

    Declaration

    Swift

    static func deriveExtendedSpendingKeys(seed: [UInt8], accounts: Int32, networkType: NetworkType) 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

  • Derives a shielded address from a seed

    Throws

    RustBackendError if fatal error occurs

    Declaration

    Swift

    static func deriveShieldedAddressFromSeed(seed: [UInt8], accountIndex: Int32, networkType: NetworkType) throws -> String?

    Parameters

    seed

    an array of bytes of the seed

    accountIndex

    the index of the account you want the address for

    Return Value

    an optional String containing the Shielded address

  • Derives a shielded address from an Extended Full Viewing Key

    Throws

    RustBackendError if fatal error occurs

    Declaration

    Swift

    static func deriveShieldedAddressFromViewingKey(_ extfvk: String, networkType: NetworkType) throws -> String?

    Parameters

    extfvk

    a string containing the extended full viewing key

    Return Value

    an optional String containing the Shielded address

  • Derives a shielded address from an Extended Full Viewing Key

    Throws

    RustBackendError if fatal error occurs

    Declaration

    Swift

    static func deriveTransparentAddressFromSeed(seed: [UInt8], account: Int, index: Int, networkType: NetworkType) throws -> String?

    Parameters

    seed

    an array of bytes of the seed

    Return Value

    an optional String containing the transparent address

  • Derives a transparent secret key from Seed

    Declaration

    Swift

    static func deriveTransparentPrivateKeyFromSeed(seed: [UInt8], account: Int, index: Int, networkType: NetworkType) throws -> String?

    Parameters

    seed

    an array of bytes containing the seed

    Return Value

    an optional String containing the transparent secret (private) key

  • Derives a transparent address from a secret key

    Declaration

    Swift

    static func deriveTransparentAddressFromSecretKey(_ tsk: String, networkType: NetworkType) throws -> String?

    Parameters

    tsk

    a hex string containing the Secret Key

    Return Value

    an optional String containing the transparent address.

  • Derives a tranparent address from a public key

    Declaration

    Swift

    static func derivedTransparentAddressFromPublicKey(_ pubkey: String, networkType: NetworkType) throws -> String

    Parameters

    pubkey

    public key represented as a string

  • Undocumented

    Declaration

    Swift

    static func deriveUnifiedViewingKeyFromSeed(_ seed: [UInt8], numberOfAccounts: Int, networkType: NetworkType) throws -> [UnifiedViewingKey]
  • Gets the consensus branch id for the given height

    Declaration

    Swift

    static func consensusBranchIdFor(height: Int32, networkType: NetworkType) throws -> Int32

    Parameters

    height

    the height you what to know the branch id for