Initializer

public class Initializer

Wrapper for all the Rust backend functionality that does not involve processing blocks. This class initializes the Rust backend and the supporting data required to exercise those abilities. The [cash.z.wallet.sdk.block.CompactBlockProcessor] handles all the remaining Rust backend functionality, related to processing blocks.

  • the LightWalletEndpoint that this initializer is connecting to

    Declaration

    Swift

    public private(set) var endpoint: LightWalletEndpoint { get }
  • Constructs the Initializer

    Declaration

    Swift

    public init(cacheDbURL: URL, dataDbURL: URL, pendingDbURL: URL, endpoint: LightWalletEndpoint, spendParamsURL: URL, outputParamsURL: URL, loggerProxy: Logger? = nil)

    Parameters

    cacheDbURL

    location of the compact blocks cache db

    dataDbURL

    Location of the data db

    pendingDbURL

    location of the pending transactions database

    endpoint

    the endpoint representing the lightwalletd instance you want to point to

    spendParamsURL

    location of the spend parameters

    outputParamsURL

    location of the output parameters

  • Initialize the wallet with the given seed and return the related private keys for each account specified or null if the wallet was previously initialized and block data exists on disk. When this method returns null, that signals that the wallet will need to retrieve the private keys from its own secure storage. In other words, the private keys are only given out once for each set of database files. Subsequent calls to [initialize] will only load the Rust library and return null.

    ‘compactBlockCache.db’ and ‘transactionData.db’ files are created by this function (if they do not already exist). These files can be given a prefix for scenarios where multiple wallets operate in one app–for instance, when sweeping funds from another wallet seed.

    Declaration

    Swift

    public func initialize(seedProvider: SeedProvider, walletBirthdayHeight: BlockHeight, numberOfAccounts: Int = 1) throws -> [String]?

    Parameters

    seedProvider

    the seed to use for initializing this wallet.

    walletBirthdayHeight

    the height corresponding to when the wallet seed was created. If null, this signals that the wallet is being born.

    numberOfAccounts

    the number of accounts to create from this seed.

  • get address from the given account index

    Declaration

    Swift

    public func getAddress(index account: Int = 0) -> String?

    Parameters

    account

    the index of the account

  • get (unverified) balance from the given account index

    Declaration

    Swift

    public func getBalance(account index: Int = 0) -> Int64

    Parameters

    account

    the index of the account

  • get verified balance from the given account index

    Declaration

    Swift

    public func getVerifiedBalance(account index: Int = 0) -> Int64

    Parameters

    account

    the index of the account

  • checks if the provided address is a valid shielded zAddress

    Declaration

    Swift

    public func isValidShieldedAddress(_ address: String) -> Bool
  • checks if the provided address is a transparent zAddress

    Declaration

    Swift

    public func isValidTransparentAddress(_ address: String) -> Bool
  • underlying CompactBlockProcessor for this initializer

    Although it is recommended to always use the higher abstraction first, if you need a more fine grained control over synchronization, you can use a CompactBlockProcessor instead of a Synchronizer.

    Declaration

    Swift

    public func blockProcessor() -> CompactBlockProcessor?