summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-core/src/operations
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2020-12-17 12:21:03 +0100
committerFlorian Dold <florian@dold.me>2020-12-17 12:21:03 +0100
commit84d5b5e5ef34f7289256c6fd301206cda19be694 (patch)
tree5db646c7fb1b782b42150a38c6d4f1e6bdfea55f /packages/taler-wallet-core/src/operations
parentbafb52edff4d56bcb9e3c3d0a260f507c517b08c (diff)
downloadwallet-core-84d5b5e5ef34f7289256c6fd301206cda19be694.tar.gz
wallet-core-84d5b5e5ef34f7289256c6fd301206cda19be694.tar.bz2
wallet-core-84d5b5e5ef34f7289256c6fd301206cda19be694.zip
export complete backup, derive planchets in withdrawal
Diffstat (limited to 'packages/taler-wallet-core/src/operations')
-rw-r--r--packages/taler-wallet-core/src/operations/backup.ts44
-rw-r--r--packages/taler-wallet-core/src/operations/reserves.ts1
-rw-r--r--packages/taler-wallet-core/src/operations/tip.ts8
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts2
4 files changed, 39 insertions, 16 deletions
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<void> {
- 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(
diff --git a/packages/taler-wallet-core/src/operations/reserves.ts b/packages/taler-wallet-core/src/operations/reserves.ts
index 95c38120c..4e4db1fc9 100644
--- a/packages/taler-wallet-core/src/operations/reserves.ts
+++ b/packages/taler-wallet-core/src/operations/reserves.ts
@@ -623,6 +623,7 @@ async function updateReserve(
retryInfo: initRetryInfo(),
lastError: undefined,
denomsSel: denomSelectionInfoToState(denomSelInfo),
+ secretSeed: encodeCrock(getRandomBytes(64)),
};
newReserve.lastError = undefined;
diff --git a/packages/taler-wallet-core/src/operations/tip.ts b/packages/taler-wallet-core/src/operations/tip.ts
index f47f76623..f683999bc 100644
--- a/packages/taler-wallet-core/src/operations/tip.ts
+++ b/packages/taler-wallet-core/src/operations/tip.ts
@@ -48,7 +48,7 @@ import {
} from "../util/http";
import { URL } from "../util/url";
import { Logger } from "../util/logging";
-import { checkDbInvariant } from "../util/invariants";
+import { checkDbInvariant, checkLogicInvariant } from "../util/invariants";
import { TalerErrorCode } from "../TalerErrorCode";
import { initRetryInfo, updateRetryInfoTimeout } from "../util/retries";
import { j2s } from "../util/helpers";
@@ -221,13 +221,13 @@ async function processTipImpl(
dh.denomPubHash,
]);
checkDbInvariant(!!denom, "denomination should be in database");
- denomForPlanchet[planchets.length] = denom;
for (let i = 0; i < dh.count; i++) {
const p = await ws.cryptoApi.createTipPlanchet({
- denomPub: dh.denomPubHash,
+ denomPub: denom.denomPub,
planchetIndex: planchets.length,
secretSeed: tipRecord.secretSeed,
});
+ denomForPlanchet[planchets.length] = denom;
planchets.push(p);
planchetsDetail.push({
coin_ev: p.coinEv,
@@ -275,7 +275,9 @@ async function processTipImpl(
const blindedSig = response.blind_sigs[i].blind_sig;
const denom = denomForPlanchet[i];
+ checkLogicInvariant(!!denom);
const planchet = planchets[i];
+ checkLogicInvariant(!!planchet);
const denomSig = await ws.cryptoApi.rsaUnblind(
blindedSig,
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index 758b80787..c2dfcd1c4 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -284,6 +284,8 @@ async function processPlanchetGenerate(
reservePriv: reserve.reservePriv,
reservePub: reserve.reservePub,
value: denom.value,
+ coinIndex: coinIdx,
+ secretSeed: withdrawalGroup.secretSeed,
});
const newPlanchet: PlanchetRecord = {
blindingKey: r.blindingKey,