gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-wallet-core] branch master updated (4221cad6 -> abb422e1)


From: gnunet
Subject: [taler-wallet-core] branch master updated (4221cad6 -> abb422e1)
Date: Tue, 08 Dec 2020 14:26:11 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a change to branch master
in repository wallet-core.

 discard 4221cad6 fee display regression test
     new abb422e1 fee display regression test

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (4221cad6)
            \
             N -- N -- N   refs/heads/master (abb422e1)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../taler-wallet-core/src/operations/backup.ts     | 168 ++++++++++-----------
 1 file changed, 78 insertions(+), 90 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/backup.ts 
b/packages/taler-wallet-core/src/operations/backup.ts
index cf73de62..9f412dc7 100644
--- a/packages/taler-wallet-core/src/operations/backup.ts
+++ b/packages/taler-wallet-core/src/operations/backup.ts
@@ -32,7 +32,6 @@ import {
   BackupDenomination,
   BackupExchange,
   BackupExchangeWireFee,
-  BackupReserve,
   WalletBackupContentV1,
 } from "../types/backupTypes";
 import { TransactionHandle } from "../util/query";
@@ -69,13 +68,13 @@ import {
 } from "../util/http";
 import { Logger } from "../util/logging";
 import { gzipSync } from "fflate";
+import { sign_keyPair_fromSeed } from "../crypto/primitives/nacl-fast";
 import { kdf } from "../crypto/primitives/kdf";
 
 interface WalletBackupConfState {
-  deviceId: string;
   walletRootPub: string;
   walletRootPriv: string;
-  clocks: { [device_id: string]: number };
+  clock: number;
   lastBackupHash?: string;
   lastBackupNonce?: string;
 }
@@ -97,10 +96,6 @@ async function provideBackupState(
   // We need to generate the key outside of the transaction
   // due to how IndexedDB works.
   const k = await ws.cryptoApi.createEddsaKeypair();
-  const d = getRandomBytes(5);
-  // FIXME: device ID should be configured when wallet is initialized
-  // and be based on hostname
-  const deviceId = `wallet-core-${encodeCrock(d)}`;
   return await ws.db.runWithWriteTransaction([Stores.config], async (tx) => {
     let backupStateEntry:
       | ConfigRecord<WalletBackupConfState>
@@ -109,10 +104,9 @@ async function provideBackupState(
       backupStateEntry = {
         key: WALLET_BACKUP_STATE_KEY,
         value: {
-          deviceId,
-          clocks: { [deviceId]: 1},
           walletRootPub: k.pub,
           walletRootPriv: k.priv,
+          clock: 0,
           lastBackupHash: undefined,
         },
       };
@@ -141,66 +135,8 @@ export async function exportBackup(
       const bs = await getWalletBackupState(ws, tx);
 
       const exchanges: BackupExchange[] = [];
-      const coinsByDenom: { [dph: string]: BackupCoin[] } = {};
-      const denominationsByExchange: { [url: string]: BackupDenomination[] } = 
{};
-      const reservesByExchange: { [url: string]: BackupReserve[] } = {};
-
-      await tx.iter(Stores.coins).forEach((coin) => {
-        let bcs: BackupCoinSource;
-        switch (coin.coinSource.type) {
-          case CoinSourceType.Refresh:
-            bcs = {
-              type: BackupCoinSourceType.Refresh,
-              old_coin_pub: coin.coinSource.oldCoinPub,
-            };
-            break;
-          case CoinSourceType.Tip:
-            bcs = {
-              type: BackupCoinSourceType.Tip,
-              coin_index: coin.coinSource.coinIndex,
-              wallet_tip_id: coin.coinSource.walletTipId,
-            };
-            break;
-          case CoinSourceType.Withdraw:
-            bcs = {
-              type: BackupCoinSourceType.Withdraw,
-              coin_index: coin.coinSource.coinIndex,
-              reserve_pub: coin.coinSource.reservePub,
-              withdrawal_group_id: coin.coinSource.withdrawalGroupId,
-            };
-            break;
-        }
-
-        const coins = (coinsByDenom[coin.denomPubHash] ??= []);
-        coins.push({
-          blinding_key: coin.blindingKey,
-          coin_priv: coin.coinPriv,
-          coin_source: bcs,
-          current_amount: Amounts.stringify(coin.currentAmount),
-          fresh: coin.status === CoinStatus.Fresh,
-          denom_sig: coin.denomSig,
-        });
-      });
-
-      await tx.iter(Stores.denominations).forEach((denom) => {
-        const backupDenoms = (denominationsByExchange[denom.exchangeBaseUrl] 
??= []);
-        backupDenoms.push({
-          coins: coinsByDenom[denom.denomPubHash] ?? [],
-          denom_pub: denom.denomPub,
-          fee_deposit: Amounts.stringify(denom.feeDeposit),
-          fee_refresh: Amounts.stringify(denom.feeRefresh),
-          fee_refund: Amounts.stringify(denom.feeRefund),
-          fee_withdraw: Amounts.stringify(denom.feeWithdraw),
-          is_offered: denom.isOffered,
-          is_revoked: denom.isRevoked,
-          master_sig: denom.masterSig,
-          stamp_expire_deposit: denom.stampExpireDeposit,
-          stamp_expire_legal: denom.stampExpireLegal,
-          stamp_expire_withdraw: denom.stampExpireWithdraw,
-          stamp_start: denom.stampStart,
-          value: Amounts.stringify(denom.value),
-        });
-      });
+      const coins: BackupCoin[] = [];
+      const denominations: BackupDenomination[] = [];
 
       await tx.iter(Stores.exchanges).forEach((ex) => {
         // Only back up permanently added exchanges.
@@ -236,12 +172,12 @@ export async function exportBackup(
         exchanges.push({
           base_url: ex.baseUrl,
           accounts: ex.wireInfo.accounts.map((x) => ({
-            payto_uri: x.payto_uri,
+            paytoUri: x.payto_uri,
           })),
           auditors: ex.details.auditors.map((x) => ({
-            auditor_pub: x.auditor_pub,
-            auditor_url: x.auditor_url,
-            denomination_keys: x.denomination_keys,
+            auditorPub: x.auditor_pub,
+            auditorUrl: x.auditor_url,
+            denominationKeys: x.denomination_keys,
           })),
           master_public_key: ex.details.masterPublicKey,
           currency: ex.details.currency,
@@ -249,39 +185,91 @@ export async function exportBackup(
           wire_fees: wireFees,
           signing_keys: ex.details.signingKeys.map((x) => ({
             key: x.key,
-            master_sig: x.master_sig,
-            stamp_end: x.stamp_end,
-            stamp_expire: x.stamp_expire,
-            stamp_start: x.stamp_start,
+            masterSig: x.master_sig,
+            stampEnd: x.stamp_end,
+            stampExpire: x.stamp_expire,
+            stampStart: x.stamp_start,
           })),
           tos_etag_accepted: ex.termsOfServiceAcceptedEtag,
           tos_etag_last: ex.termsOfServiceLastEtag,
-          denominations: denominationsByExchange[ex.baseUrl] ?? [],
-          reserves: reservesByExchange[ex.baseUrl] ?? [],
+        });
+      });
+
+      await tx.iter(Stores.denominations).forEach((denom) => {
+        denominations.push({
+          denom_pub: denom.denomPub,
+          denom_pub_hash: denom.denomPubHash,
+          exchangeBaseUrl: canonicalizeBaseUrl(denom.exchangeBaseUrl),
+          fee_deposit: Amounts.stringify(denom.feeDeposit),
+          fee_refresh: Amounts.stringify(denom.feeRefresh),
+          fee_refund: Amounts.stringify(denom.feeRefund),
+          fee_withdraw: Amounts.stringify(denom.feeWithdraw),
+          is_offered: denom.isOffered,
+          is_revoked: denom.isRevoked,
+          master_sig: denom.masterSig,
+          stamp_expire_deposit: denom.stampExpireDeposit,
+          stamp_expire_legal: denom.stampExpireLegal,
+          stamp_expire_withdraw: denom.stampExpireWithdraw,
+          stamp_start: denom.stampStart,
+          value: Amounts.stringify(denom.value),
+        });
+      });
+
+      await tx.iter(Stores.coins).forEach((coin) => {
+        let bcs: BackupCoinSource;
+        switch (coin.coinSource.type) {
+          case CoinSourceType.Refresh:
+            bcs = {
+              type: BackupCoinSourceType.Refresh,
+              old_coin_pub: coin.coinSource.oldCoinPub,
+            };
+            break;
+          case CoinSourceType.Tip:
+            bcs = {
+              type: BackupCoinSourceType.Tip,
+              coin_index: coin.coinSource.coinIndex,
+              wallet_tip_id: coin.coinSource.walletTipId,
+            };
+            break;
+          case CoinSourceType.Withdraw:
+            bcs = {
+              type: BackupCoinSourceType.Withdraw,
+              coin_index: coin.coinSource.coinIndex,
+              reserve_pub: coin.coinSource.reservePub,
+              withdrawal_group_id: coin.coinSource.withdrawalGroupId,
+            };
+            break;
+        }
+
+        coins.push({
+          exchangeBaseUrl: coin.exchangeBaseUrl,
+          blinding_key: coin.blindingKey,
+          coin_priv: coin.coinPriv,
+          coin_pub: coin.coinPub,
+          coin_source: bcs,
+          current_amount: Amounts.stringify(coin.currentAmount),
+          fresh: coin.status === CoinStatus.Fresh,
         });
       });
 
       const backupBlob: WalletBackupContentV1 = {
-        schema_id: "gnu-taler-wallet-backup-content",
+        schema_id: "gnu-taler-wallet-backup",
         schema_version: 1,
-        clocks: bs.clocks,
+        clock: bs.clock,
+        coins: coins,
         exchanges: exchanges,
+        planchets: [],
+        refreshSessions: [],
+        reserves: [],
+        denominations: [],
         wallet_root_pub: bs.walletRootPub,
-        backup_providers: [],
-        current_device_id: bs.deviceId,
-        proposals: [],
-        purchase_tombstones: [],
-        purchases: [],
-        recoup_groups: [],
-        refresh_groups: [],
-        tips: [],
       };
 
       // If the backup changed, we increment our clock.
 
       let h = encodeCrock(hash(stringToBytes(canonicalJson(backupBlob))));
       if (h != bs.lastBackupHash) {
-        backupBlob.clocks[bs.deviceId] = ++bs.clocks[bs.deviceId];
+        backupBlob.clock = ++bs.clock;
         bs.lastBackupHash = encodeCrock(
           hash(stringToBytes(canonicalJson(backupBlob))),
         );

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]