fix issue 201 Throw exception when seed can't be provided

This commit is contained in:
Francisco Gindre 2020-10-03 13:48:33 -03:00
parent bfc717dc07
commit d4dfb23657
3 changed files with 4 additions and 4 deletions

View File

@ -44,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
walletBirthdayHeight: BlockHeight(DemoAppConfig.birthdayHeight)) // Init or DIE
var storage = SampleStorage.shared
storage!.seed = Data(DemoAppConfig().seed())
storage!.seed = Data(try! DemoAppConfig().seed())
storage!.privateKey = addresses?[0]
self.wallet = wallet
return wallet
@ -133,7 +133,7 @@ extension AppDelegate {
}
extension DemoAppConfig: SeedProvider {
func seed() -> [UInt8] {
func seed() throws -> [UInt8] {
DemoAppConfig.seed
}
}

View File

@ -173,7 +173,7 @@ public class Initializer {
self.processor = CompactBlockProcessorBuilder.buildProcessor(configuration: CompactBlockProcessor.Configuration(cacheDb: cacheDbURL, dataDb: dataDbURL, walletBirthday: walletBirthday?.height ?? self.lowerBoundHeight), downloader: self.downloader, transactionRepository: transactionRepository, backend: rustBackend)
guard let accounts = rustBackend.initAccountsTable(dbData: dataDbURL, seed: seedProvider.seed(), accounts: Int32(numberOfAccounts)) else {
guard let accounts = rustBackend.initAccountsTable(dbData: dataDbURL, seed: try seedProvider.seed(), accounts: Int32(numberOfAccounts)) else {
throw rustBackend.lastError() ?? InitializerError.accountInitFailed
}

View File

@ -11,5 +11,5 @@ import Foundation
Describes an interface for an entity that provides seed bytes
*/
public protocol SeedProvider {
func seed() -> [UInt8]
func seed() throws -> [UInt8]
}