WalletCacheService
public class WalletCacheService
A service class used to store and retrieve Wallet objects such as RegularWallet, HDWallet, LedgerWallet and TorusWallet from the devices disk.
This class will use the secure enclave (keychain if not available) to generate a key used to encrypt the contents locally, and retrieve.
This class will also store non senstiivve “metadata” about wallets, to allow storage of UI related data users might want to add, without cluttering up the wallet objects themselves
-
Empty
Declaration
Swift
public init()
-
Securely cache a walelt object, and record a default metadata object
Declaration
Swift
public func cache<T>(wallet: T, childOfIndex: Int?, backedUp: Bool) throws where T : WalletParameters
walletAn object conforming to
Walletto be storedchildOfIndexAn optional
Intto denote the index of the HD wallet that this wallet is a child ofReturn Value
Bool, indicating if the storage was successful or not
-
Cahce a watch wallet metadata obj, only. Metadata cahcing handled via wallet cache method
Declaration
Swift
public func cacheWatchWallet(metadata: WalletMetadata) throws -
Delete both a secure wallet entry and its related metadata object
Declaration
Swift
public func deleteWallet(withAddress: String, parentIndex: Int?) -> BoolParameters
withAddressThe address of the wallet
parentIndexAn optional
Intto denote the index of the HD wallet that this wallet is a child ofReturn Value
Bool, indicating if the storage was successful or not
-
Clear a watch wallet meatadata obj from the metadata cache only, does not affect actual wallet cache
Declaration
Swift
public func deleteWatchWallet(address: String) -> Bool -
Migrate a LedgerWallet and its children to a new physical device, denoted by a new UUID
Declaration
Swift
public func migrateLedger(metadata: WalletMetadata, toNewUUID: String) -> Bool -
Delete the cached files and the assoicate keys used to encrypt it
Declaration
Swift
public func deleteAllCacheAndKeys() -> BoolReturn Value
Bool, indicating if the process was successful or not
-
Write an ordered array of
WalletMetadatato disk, replacing existing file if existsDeclaration
Swift
public func encryptAndWriteMetadataToDisk(_ metadata: WalletMetadataList) -> Bool -
Return an ordered array of
WalletMetadataif present on diskDeclaration
Swift
public func readMetadataFromDiskAndDecrypt() -> WalletMetadataList
-
Load the key references from the secure enclave (or keychain), or create them if non exist
Declaration
Swift
public func loadOrCreateKeys() -> BoolReturn Value
Bool, indicating if operation was successful
-
Clear the key refrences
Declaration
Swift
public func unloadKeys() -
Delete a key from the secure enclave
Declaration
Swift
public func deleteKey() throws -
Encrypts string using the Secure Enclave
Throws
CryptoKit errorDeclaration
Swift
public func encrypt(_ string: String) throws -> DataParameters
stringclear text to be encrypted
Return Value
cipherText encrypted string
-
Decrypts cipher text using the Secure Enclave
Throws
CryptoKit errorDeclaration
Swift
public func decrypt(_ cipherText: Data) throws -> StringParameters
cipherTextencrypted cipher text
Return Value
cleartext string
Install in Dash