Synchronizer

public protocol Synchronizer

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

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

    Declaration

    Swift

    var status: SyncStatus { get }
  • reflects current connection state to LightwalletEndpoint

    Declaration

    Swift

    var connectionState: ConnectionState { get }
  • 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
  • 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 this synchronizer. Implementations should ensure that calling this method cancels all jobs that were created by this instance.

    Declaration

    Swift

    func stop() throws
  • 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.

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

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

  • Undocumented

    Declaration

    Swift

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

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

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

    Declaration

    Swift

    var pendingTransactions: [PendingTransactionEntity] { get }
  • all the transactions that are on the blockchain

    Declaration

    Swift

    var clearedTransactions: [ConfirmedTransactionEntity] { get }
  • All transactions that are related to sending funds

    Declaration

    Swift

    var sentTransactions: [ConfirmedTransactionEntity] { get }
  • all transactions related to receiving funds

    Declaration

    Swift

    var receivedTransactions: [ConfirmedTransactionEntity] { get }
  • A repository serving transactions in a paginated manner

    Declaration

    Swift

    func paginatedTransactions(of kind: TransactionKind) -> PaginatedTransactionRepository

    Parameters

    kind

    Transaction Kind expected from this PaginatedTransactionRepository

  • 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

  • Returns the latest downloaded height from the compact block cache

    Declaration

    Swift

    func latestDownloadedHeight() throws -> BlockHeight
  • Returns the latest block height from the provided Lightwallet endpoint

    Declaration

    Swift

    func latestHeight(result: @escaping (Result<BlockHeight, Error>) -> Void)
  • Returns the latest block height from the provided Lightwallet endpoint Blocking

    Declaration

    Swift

    func latestHeight() throws -> BlockHeight
  • 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)
  • Returns the last stored unshielded balance

    Declaration

    Swift

    func getTransparentBalance(accountIndex: Int) throws -> WalletBalance
  • Returns the shielded total balance (includes verified and unverified balance)

    Declaration

    Swift

    func getShieldedBalance(accountIndex: Int) -> Int64
  • Returns the shielded verified balance (anchor is 10 blocks back)

    Declaration

    Swift

    func getShieldedVerifiedBalance(accountIndex: Int) -> Int64
  • 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