From 84d5b5e5ef34f7289256c6fd301206cda19be694 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 17 Dec 2020 12:21:03 +0100 Subject: export complete backup, derive planchets in withdrawal --- .../taler-wallet-core/src/operations/backup.ts | 44 +++++++++++++++------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'packages/taler-wallet-core/src/operations/backup.ts') diff --git a/packages/taler-wallet-core/src/operations/backup.ts b/packages/taler-wallet-core/src/operations/backup.ts index 1e5aa542d..f071b6d08 100644 --- a/packages/taler-wallet-core/src/operations/backup.ts +++ b/packages/taler-wallet-core/src/operations/backup.ts @@ -198,17 +198,17 @@ export async function exportBackup( const withdrawalGroups = (withdrawalGroupsByReserve[ wg.reservePub ] ??= []); - // FIXME: finish! - // withdrawalGroups.push({ - // raw_withdrawal_amount: Amounts.stringify(wg.rawWithdrawalAmount), - // selected_denoms: wg.denomsSel.selectedDenoms.map((x) => ({ - // count: x.count, - // denom_pub_hash: x.denomPubHash, - // })), - // timestamp_start: wg.timestampStart, - // timestamp_finish: wg.timestampFinish, - // withdrawal_group_id: wg.withdrawalGroupId, - // }); + withdrawalGroups.push({ + raw_withdrawal_amount: Amounts.stringify(wg.rawWithdrawalAmount), + selected_denoms: wg.denomsSel.selectedDenoms.map((x) => ({ + count: x.count, + denom_pub_hash: x.denomPubHash, + })), + timestamp_start: wg.timestampStart, + timestamp_finish: wg.timestampFinish, + withdrawal_group_id: wg.withdrawalGroupId, + secret_seed: wg.secretSeed + }); }); await tx.iter(Stores.reserves).forEach((reserve) => { @@ -572,11 +572,29 @@ export async function encryptBackup( throw Error("not implemented"); } -export function importBackup( +export async function importBackup( ws: InternalWalletState, backupRequest: BackupRequest, ): Promise { - throw Error("not implemented"); + await provideBackupState(ws); + return ws.db.runWithWriteTransaction( + [ + Stores.config, + Stores.exchanges, + Stores.coins, + Stores.denominations, + Stores.purchases, + Stores.proposals, + Stores.refreshGroups, + Stores.backupProviders, + Stores.tips, + Stores.recoupGroups, + Stores.reserves, + Stores.withdrawalGroups, + ], + async (tx) => { + + }); } function deriveAccountKeyPair( -- cgit v1.2.3