aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations/backup
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2022-08-09 15:00:45 +0200
committerFlorian Dold <florian@dold.me>2022-08-16 17:55:12 +0200
commitac8f116780a860c8f4acfdf5553bf90d76afe236 (patch)
tree38abecb5ad3a3660161909ee9ca229d4ce08eb4a /packages/taler-wallet-core/src/operations/backup
parentfb8372dfbf27b7b4e8b2fe4f81aa2ba18bfcf638 (diff)
downloadwallet-core-ac8f116780a860c8f4acfdf5553bf90d76afe236.tar.xz
implement peer to peer push payments
Diffstat (limited to 'packages/taler-wallet-core/src/operations/backup')
-rw-r--r--packages/taler-wallet-core/src/operations/backup/export.ts24
-rw-r--r--packages/taler-wallet-core/src/operations/backup/import.ts185
2 files changed, 92 insertions, 117 deletions
diff --git a/packages/taler-wallet-core/src/operations/backup/export.ts b/packages/taler-wallet-core/src/operations/backup/export.ts
index d4c822972..c77ce1a85 100644
--- a/packages/taler-wallet-core/src/operations/backup/export.ts
+++ b/packages/taler-wallet-core/src/operations/backup/export.ts
@@ -88,7 +88,6 @@ export async function exportBackup(
backupProviders: x.backupProviders,
tips: x.tips,
recoupGroups: x.recoupGroups,
- reserves: x.reserves,
withdrawalGroups: x.withdrawalGroups,
}))
.runReadWrite(async (tx) => {
@@ -128,29 +127,6 @@ export async function exportBackup(
});
});
- await tx.reserves.iter().forEach((reserve) => {
- const backupReserve: BackupReserve = {
- initial_selected_denoms: reserve.initialDenomSel.selectedDenoms.map(
- (x) => ({
- count: x.count,
- denom_pub_hash: x.denomPubHash,
- }),
- ),
- initial_withdrawal_group_id: reserve.initialWithdrawalGroupId,
- instructed_amount: Amounts.stringify(reserve.instructedAmount),
- reserve_priv: reserve.reservePriv,
- timestamp_created: reserve.timestampCreated,
- withdrawal_groups:
- withdrawalGroupsByReserve[reserve.reservePub] ?? [],
- // FIXME!
- timestamp_last_activity: reserve.timestampCreated,
- };
- const backupReserves = (backupReservesByExchange[
- reserve.exchangeBaseUrl
- ] ??= []);
- backupReserves.push(backupReserve);
- });
-
await tx.tips.iter().forEach((tip) => {
backupTips.push({
exchange_base_url: tip.exchangeBaseUrl,
diff --git a/packages/taler-wallet-core/src/operations/backup/import.ts b/packages/taler-wallet-core/src/operations/backup/import.ts
index e099fae57..f26c42770 100644
--- a/packages/taler-wallet-core/src/operations/backup/import.ts
+++ b/packages/taler-wallet-core/src/operations/backup/import.ts
@@ -236,7 +236,6 @@ export async function importBackup(
backupProviders: x.backupProviders,
tips: x.tips,
recoupGroups: x.recoupGroups,
- reserves: x.reserves,
withdrawalGroups: x.withdrawalGroups,
tombstones: x.tombstones,
depositGroups: x.depositGroups,
@@ -427,94 +426,98 @@ export async function importBackup(
}
}
- for (const backupReserve of backupExchangeDetails.reserves) {
- const reservePub =
- cryptoComp.reservePrivToPub[backupReserve.reserve_priv];
- const ts = makeEventId(TombstoneTag.DeleteReserve, reservePub);
- if (tombstoneSet.has(ts)) {
- continue;
- }
- checkLogicInvariant(!!reservePub);
- const existingReserve = await tx.reserves.get(reservePub);
- const instructedAmount = Amounts.parseOrThrow(
- backupReserve.instructed_amount,
- );
- if (!existingReserve) {
- let bankInfo: ReserveBankInfo | undefined;
- if (backupReserve.bank_info) {
- bankInfo = {
- exchangePaytoUri: backupReserve.bank_info.exchange_payto_uri,
- statusUrl: backupReserve.bank_info.status_url,
- confirmUrl: backupReserve.bank_info.confirm_url,
- };
- }
- await tx.reserves.put({
- currency: instructedAmount.currency,
- instructedAmount,
- exchangeBaseUrl: backupExchangeDetails.base_url,
- reservePub,
- reservePriv: backupReserve.reserve_priv,
- bankInfo,
- timestampCreated: backupReserve.timestamp_created,
- timestampBankConfirmed:
- backupReserve.bank_info?.timestamp_bank_confirmed,
- timestampReserveInfoPosted:
- backupReserve.bank_info?.timestamp_reserve_info_posted,
- senderWire: backupReserve.sender_wire,
- retryInfo: RetryInfo.reset(),
- lastError: undefined,
- initialWithdrawalGroupId:
- backupReserve.initial_withdrawal_group_id,
- initialWithdrawalStarted:
- backupReserve.withdrawal_groups.length > 0,
- // FIXME!
- reserveStatus: ReserveRecordStatus.QueryingStatus,
- initialDenomSel: await getDenomSelStateFromBackup(
- tx,
- backupExchangeDetails.base_url,
- backupReserve.initial_selected_denoms,
- ),
- // FIXME!
- operationStatus: OperationStatus.Pending,
- });
- }
- for (const backupWg of backupReserve.withdrawal_groups) {
- const ts = makeEventId(
- TombstoneTag.DeleteWithdrawalGroup,
- backupWg.withdrawal_group_id,
- );
- if (tombstoneSet.has(ts)) {
- continue;
- }
- const existingWg = await tx.withdrawalGroups.get(
- backupWg.withdrawal_group_id,
- );
- if (!existingWg) {
- await tx.withdrawalGroups.put({
- denomsSel: await getDenomSelStateFromBackup(
- tx,
- backupExchangeDetails.base_url,
- backupWg.selected_denoms,
- ),
- exchangeBaseUrl: backupExchangeDetails.base_url,
- lastError: undefined,
- rawWithdrawalAmount: Amounts.parseOrThrow(
- backupWg.raw_withdrawal_amount,
- ),
- reservePub,
- retryInfo: RetryInfo.reset(),
- secretSeed: backupWg.secret_seed,
- timestampStart: backupWg.timestamp_created,
- timestampFinish: backupWg.timestamp_finish,
- withdrawalGroupId: backupWg.withdrawal_group_id,
- denomSelUid: backupWg.selected_denoms_id,
- operationStatus: backupWg.timestamp_finish
- ? OperationStatus.Finished
- : OperationStatus.Pending,
- });
- }
- }
- }
+
+ // FIXME: import reserves with new schema
+
+ // for (const backupReserve of backupExchangeDetails.reserves) {
+ // const reservePub =
+ // cryptoComp.reservePrivToPub[backupReserve.reserve_priv];
+ // const ts = makeEventId(TombstoneTag.DeleteReserve, reservePub);
+ // if (tombstoneSet.has(ts)) {
+ // continue;
+ // }
+ // checkLogicInvariant(!!reservePub);
+ // const existingReserve = await tx.reserves.get(reservePub);
+ // const instructedAmount = Amounts.parseOrThrow(
+ // backupReserve.instructed_amount,
+ // );
+ // if (!existingReserve) {
+ // let bankInfo: ReserveBankInfo | undefined;
+ // if (backupReserve.bank_info) {
+ // bankInfo = {
+ // exchangePaytoUri: backupReserve.bank_info.exchange_payto_uri,
+ // statusUrl: backupReserve.bank_info.status_url,
+ // confirmUrl: backupReserve.bank_info.confirm_url,
+ // };
+ // }
+ // await tx.reserves.put({
+ // currency: instructedAmount.currency,
+ // instructedAmount,
+ // exchangeBaseUrl: backupExchangeDetails.base_url,
+ // reservePub,
+ // reservePriv: backupReserve.reserve_priv,
+ // bankInfo,
+ // timestampCreated: backupReserve.timestamp_created,
+ // timestampBankConfirmed:
+ // backupReserve.bank_info?.timestamp_bank_confirmed,
+ // timestampReserveInfoPosted:
+ // backupReserve.bank_info?.timestamp_reserve_info_posted,
+ // senderWire: backupReserve.sender_wire,
+ // retryInfo: RetryInfo.reset(),
+ // lastError: undefined,
+ // initialWithdrawalGroupId:
+ // backupReserve.initial_withdrawal_group_id,
+ // initialWithdrawalStarted:
+ // backupReserve.withdrawal_groups.length > 0,
+ // // FIXME!
+ // reserveStatus: ReserveRecordStatus.QueryingStatus,
+ // initialDenomSel: await getDenomSelStateFromBackup(
+ // tx,
+ // backupExchangeDetails.base_url,
+ // backupReserve.initial_selected_denoms,
+ // ),
+ // // FIXME!
+ // operationStatus: OperationStatus.Pending,
+ // });
+ // }
+ // for (const backupWg of backupReserve.withdrawal_groups) {
+ // const ts = makeEventId(
+ // TombstoneTag.DeleteWithdrawalGroup,
+ // backupWg.withdrawal_group_id,
+ // );
+ // if (tombstoneSet.has(ts)) {
+ // continue;
+ // }
+ // const existingWg = await tx.withdrawalGroups.get(
+ // backupWg.withdrawal_group_id,
+ // );
+ // if (!existingWg) {
+ // await tx.withdrawalGroups.put({
+ // denomsSel: await getDenomSelStateFromBackup(
+ // tx,
+ // backupExchangeDetails.base_url,
+ // backupWg.selected_denoms,
+ // ),
+ // exchangeBaseUrl: backupExchangeDetails.base_url,
+ // lastError: undefined,
+ // rawWithdrawalAmount: Amounts.parseOrThrow(
+ // backupWg.raw_withdrawal_amount,
+ // ),
+ // reservePub,
+ // retryInfo: RetryInfo.reset(),
+ // secretSeed: backupWg.secret_seed,
+ // timestampStart: backupWg.timestamp_created,
+ // timestampFinish: backupWg.timestamp_finish,
+ // withdrawalGroupId: backupWg.withdrawal_group_id,
+ // denomSelUid: backupWg.selected_denoms_id,
+ // operationStatus: backupWg.timestamp_finish
+ // ? OperationStatus.Finished
+ // : OperationStatus.Pending,
+ // });
+ // }
+ // }
+ // }
+
}
for (const backupProposal of backupBlob.proposals) {
@@ -920,10 +923,6 @@ export async function importBackup(
} else if (type === TombstoneTag.DeleteRefund) {
// Nothing required, will just prevent display
// in the transactions list
- } else if (type === TombstoneTag.DeleteReserve) {
- // FIXME: Once we also have account (=kyc) reserves,
- // we need to check if the reserve is an account before deleting here
- await tx.reserves.delete(rest[0]);
} else if (type === TombstoneTag.DeleteTip) {
await tx.tips.delete(rest[0]);
} else if (type === TombstoneTag.DeleteWithdrawalGroup) {