# ZcashRustBackendWelding

    public protocol ZcashRustBackendWelding

Undocumented

- `lastError()`

  gets the latest error if available. Clear the existing error

  #### Declaration

  Swift

      static func lastError() -> RustWeldingError?

- `getLastError()`

  gets the latest error message from librustzcash. Does not clear existing error

  #### Declaration

  Swift

      static func getLastError() -> String?

- `initDataDb(dbData:networkType:)`

  initializes the data db

  #### Declaration

  Swift

      static func initDataDb(dbData: URL, networkType: NetworkType) throws

  #### Parameters

  `dbData` | location of the data db sql file

- `isValidShieldedAddress(_:networkType:)`

  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

- `isValidTransparentAddress(_:networkType:)`

  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

- `isValidExtendedFullViewingKey(_:networkType:)`

  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

- `initAccountsTable(dbData:seed:accounts:networkType:)`

  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

- `initAccountsTable(dbData:uvks:networkType:)`

  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

- `initBlocksTable(dbData:height:hash:time:saplingTree:networkType:)`

  Undocumented

  #### Declaration

  Swift

      static func initBlocksTable(
          dbData: URL,
          height: Int32,
          hash: String,
          time: UInt32,
          saplingTree: String,
          networkType: NetworkType
      ) throws

- `getAddress(dbData:account:networkType:)`

  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

- `getBalance(dbData:account:networkType:)`

  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

- `getVerifiedBalance(dbData:account:networkType:)`

  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

- `getVerifiedTransparentBalance(dbData:address:networkType:)`

  Get the verified cached transparent balance for the given address

  #### Declaration

  Swift

      static func getVerifiedTransparentBalance(dbData: URL, address: String, networkType: NetworkType) throws -> Int64

- `getTransparentBalance(dbData:address:networkType:)`

  Get the verified cached transparent balance for the given address

  #### Declaration

  Swift

      static func getTransparentBalance(dbData: URL, address: String, networkType: NetworkType) throws -> Int64

- `getReceivedMemoAsUTF8(dbData:idNote:networkType:)`

  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

- `getSentMemoAsUTF8(dbData:idNote:networkType:)`

  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

- `validateCombinedChain(dbCache:dbData:networkType:)`

  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. - 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

- `getNearestRewindHeight(dbData:height:networkType:)`

  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.

- `rewindToHeight(dbData:height:networkType:)`

  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

- `scanBlocks(dbCache:dbData:limit:networkType:)`

  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.

- `putUnspentTransparentOutput(dbData:address:txid:index:script:value:height:networkType:)`

  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

- `clearUtxos(dbData:address:sinceHeight:networkType:)`

  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

- `downloadedUtxoBalance(dbData:address:networkType:)`

  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.

- `decryptAndStoreTransaction(dbData:txBytes:minedHeight:networkType:)`

  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.

- `createToAddress(dbData:account:extsk:to:value:memo:spendParamsPath:outputParamsPath:networkType:)`

  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

- `shieldFunds(dbCache:dbData:account:tsk:extsk:memo:spendParamsPath:outputParamsPath:networkType:)`

  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

- `deriveExtendedFullViewingKey(_:networkType:)`

  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

- `deriveExtendedFullViewingKeys(seed:accounts:networkType:)`

  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

- `deriveExtendedSpendingKeys(seed:accounts:networkType:)`

  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

- `deriveShieldedAddressFromSeed(seed:accountIndex:networkType:)`

  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

- `deriveShieldedAddressFromViewingKey(_:networkType:)`

  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

- `deriveTransparentAddressFromSeed(seed:account:index:networkType:)`

  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

- `deriveTransparentPrivateKeyFromSeed(seed:account:index:networkType:)`

  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

- `deriveTransparentAddressFromSecretKey(_:networkType:)`

  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.

- `derivedTransparentAddressFromPublicKey(_:networkType:)`

  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

- `deriveUnifiedViewingKeyFromSeed(_:numberOfAccounts:networkType:)`

  Undocumented

  #### Declaration

  Swift

      static func deriveUnifiedViewingKeyFromSeed(_ seed: [UInt8], numberOfAccounts: Int, networkType: NetworkType) throws -> [UnifiedViewingKey]

- `consensusBranchIdFor(height:networkType:)`

  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

© 2022 Francisco Gindre and Jack Grigg. All rights reserved. (Last updated: 2022-04-07)

Generated by jazzy ♪♫ v0.14.2, a Realm project.