Skip to content

Commit

Permalink
Rollback single wallet structure for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ant013 committed Oct 20, 2023
1 parent 2c361db commit 4dfaf1f
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class AppBackupProvider {
try accountIds.compactMap {
accountManager.account(id: $0)
}.compactMap {
try Self.encrypt(account: $0, wallets: enabledWallets(account: $0), passphrase: passphrase)
let walletBackup = try Self.encrypt(account: $0, wallets: enabledWallets(account: $0), passphrase: passphrase)
return RestoreCloudModule.RestoredBackup(name: $0.name, walletBackup: walletBackup)
}
}

Expand Down Expand Up @@ -253,7 +254,8 @@ extension AppBackupProvider {

func encrypt(raw: RawFullBackup, passphrase: String) throws -> FullBackup {
let wallets = try raw.accounts.map {
try Self.encrypt(account: $0.account, wallets: $0.enabledWallets, passphrase: passphrase)
let walletBackup = try Self.encrypt(account: $0.account, wallets: $0.enabledWallets, passphrase: passphrase)
return RestoreCloudModule.RestoredBackup(name: $0.account.name, walletBackup: walletBackup)
}

let contacts = try ContactBookManager.encrypt(contacts: raw.contacts, passphrase: passphrase)
Expand All @@ -270,11 +272,11 @@ extension AppBackupProvider {
)
}

static func encrypt(account: Account, wallets: [WalletBackup.EnabledWallet], passphrase: String) throws -> RestoreCloudModule.RestoredBackup {
static func encrypt(account: Account, wallets: [WalletBackup.EnabledWallet], passphrase: String) throws -> WalletBackup {
let message = account.type.uniqueId(hashed: false)
let crypto = try BackupCrypto.encrypt(data: message, passphrase: passphrase)

let walletBackup = WalletBackup(
return WalletBackup(
crypto: crypto,
enabledWallets: wallets,
id: account.type.uniqueId().hs.hex,
Expand All @@ -284,8 +286,6 @@ extension AppBackupProvider {
version: Self.version,
timestamp: Date().timeIntervalSince1970.rounded()
)

return .init(name: account.name, walletBackup: walletBackup)
}
}

Expand Down

0 comments on commit 4dfaf1f

Please sign in to comment.