# Synchronizer

    public protocol Synchronizer

Primary interface for interacting with the SDK. Defines the contract that specific implementations like SdkSynchronizer fulfill.

- `status`

  Value representing the Status of this Synchronizer. As the status changes, it will be also notified

  #### Declaration

  Swift

      var status: SyncStatus { get }

- `connectionState`

  reflects current connection state to LightwalletEndpoint

  #### Declaration

  Swift

      var connectionState: ConnectionState { get }

- `prepare()`

  prepares this initializer to operate. Initializes the internal state with the given Extended Viewing Keys and a wallet birthday found in the initializer object

  #### Declaration

  Swift

      func prepare() throws

- `start(retry:)`

  Starts this synchronizer within the given scope.

  Implementations should leverage structured concurrency and cancel all jobs when this scope completes.

  #### Declaration

  Swift

      func start(retry: Bool) throws

- `stop()`

  Stop this synchronizer. Implementations should ensure that calling this method cancels all jobs that were created by this instance.

  #### Declaration

  Swift

      func stop() throws

- `getShieldedAddress(accountIndex:)`

  Gets the sapling shielded address for the given account.

  #### Declaration

  Swift

      func getShieldedAddress(accountIndex: Int) -> SaplingShieldedAddress?

  #### Parameters

  `accountIndex` | the optional accountId whose address is of interest. By default, the first account is used.

- `getUnifiedAddress(accountIndex:)`

  Gets the unified address for the given account.

  #### Declaration

  Swift

      func getUnifiedAddress(accountIndex: Int) -> UnifiedAddress?

  #### Parameters

  `accountIndex` | the optional accountId whose address is of interest. By default, the first account is used.

- `getTransparentAddress(accountIndex:)`

  Gets the transparent address for the given account.

  #### Declaration

  Swift

      func getTransparentAddress(accountIndex: Int) -> TransparentAddress?

  #### Parameters

  `accountIndex` | the optional accountId whose address is of interest. By default, the first account is used.

- `sendToAddress(spendingKey:zatoshi:toAddress:memo:from:resultBlock:)`

  Undocumented

  #### Declaration

  Swift

      func sendToAddress(
          spendingKey: String,
          zatoshi: Int64,
          toAddress: String,
          memo: String?,
          from accountIndex: Int,
          resultBlock: @escaping (_ result: Result<PendingTransactionEntity, Error>) -> Void
      )

- `shieldFunds(spendingKey:transparentSecretKey:memo:from:resultBlock:)`

  Sends zatoshi.

  #### Declaration

  Swift

      func shieldFunds(
          spendingKey: String,
          transparentSecretKey: String,
          memo: String?,
          from accountIndex: Int,
          resultBlock: @escaping (_ result: Result<PendingTransactionEntity, Error>) -> Void
      )

  #### Parameters

  `spendingKey` | the key that allows spends to occur.
  `transparentSecretKey` | the key that allows to spend transaprent funds
  `memo` | the optional memo to include as part of the transaction.
  `accountIndex` | the optional account id that will be used to shield your funds to. By default, the first account is used.

- `cancelSpend(transaction:)`

  Attempts to cancel a transaction that is about to be sent. Typically, cancellation is only an option if the transaction has not yet been submitted to the server.

  #### Declaration

  Swift

      func cancelSpend(transaction: PendingTransactionEntity) -> Bool

  #### Parameters

  `transaction` | the transaction to cancel.

  #### Return Value

  true when the cancellation request was successful. False when it is too late.

- `pendingTransactions`

  all outbound pending transactions that have been sent but are awaiting confirmations

  #### Declaration

  Swift

      var pendingTransactions: [PendingTransactionEntity] { get }

- `clearedTransactions`

  all the transactions that are on the blockchain

  #### Declaration

  Swift

      var clearedTransactions: [ConfirmedTransactionEntity] { get }

- `sentTransactions`

  All transactions that are related to sending funds

  #### Declaration

  Swift

      var sentTransactions: [ConfirmedTransactionEntity] { get }

- `receivedTransactions`

  all transactions related to receiving funds

  #### Declaration

  Swift

      var receivedTransactions: [ConfirmedTransactionEntity] { get }

- `paginatedTransactions(of:)`

  A repository serving transactions in a paginated manner

  #### Declaration

  Swift

      func paginatedTransactions(of kind: TransactionKind) -> PaginatedTransactionRepository

  #### Parameters

  `kind` | Transaction Kind expected from this PaginatedTransactionRepository

- `allConfirmedTransactions(from:limit:)`

  Returns a list of confirmed transactions that preceed the given transaction with a limit count.

  #### Declaration

  Swift

      func allConfirmedTransactions(from transaction: ConfirmedTransactionEntity?, limit: Int) throws -> [ConfirmedTransactionEntity]?

  #### Parameters

  `from` | the confirmed transaction from which the query should start from or nil to retrieve from the most recent transaction
  `limit` | the maximum amount of items this should return if available

  #### Return Value

  an array with the given Transactions or nil

- `latestDownloadedHeight()`

  Returns the latest downloaded height from the compact block cache

  #### Declaration

  Swift

      func latestDownloadedHeight() throws -> BlockHeight

- `latestHeight(result:)`

  Returns the latest block height from the provided Lightwallet endpoint

  #### Declaration

  Swift

      func latestHeight(result: @escaping (Result<BlockHeight, Error>) -> Void)

- `latestHeight()`

  Returns the latest block height from the provided Lightwallet endpoint Blocking

  #### Declaration

  Swift

      func latestHeight() throws -> BlockHeight

- `refreshUTXOs(address:from:result:)`

  Returns the latests UTXOs for the given address from the specified height on

  #### Declaration

  Swift

      func refreshUTXOs(address: String, from height: BlockHeight, result: @escaping (Result<RefreshedUTXOs, Error>) -> Void)

- `getTransparentBalance(accountIndex:)`

  Returns the last stored unshielded balance

  #### Declaration

  Swift

      func getTransparentBalance(accountIndex: Int) throws -> WalletBalance

- `getShieldedBalance(accountIndex:)`

  Returns the shielded total balance (includes verified and unverified balance)

  #### Declaration

  Swift

      func getShieldedBalance(accountIndex: Int) -> Int64

- `getShieldedVerifiedBalance(accountIndex:)`

  Returns the shielded verified balance (anchor is 10 blocks back)

  #### Declaration

  Swift

      func getShieldedVerifiedBalance(accountIndex: Int) -> Int64

- `rewind(_:)`

  Stops the synchronizer and rescans the known blocks with the current keys.

  Throws

  Throws rewindErrorUnknownArchorHeight when the rewind points to an invalid height

  Throws

  Throws rewindError for other errors

  Note

  Note rewind does not trigger notifications as a reorg would. You need to restart the synchronizer afterwards

  #### Declaration

  Swift

      func rewind(_ policy: RewindPolicy) throws

  #### Parameters

  `policy` | the rewind policy

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

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