gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated (339080e01 -> 582b6ae5f)


From: gnunet
Subject: [taler-wallet-core] branch master updated (339080e01 -> 582b6ae5f)
Date: Thu, 23 Feb 2023 16:07:22 +0100

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

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

    from 339080e01 embedded: add missing DB remove call in reset
     new dd9e4555b wallet-core: fixup for legacy peer-push-debit transaction
     new 582b6ae5f wallet-core: report correct amountEffective in 
peer-pull-credit even before withdrawal is active

The 2 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:
 .../src/crypto/workers/nodeThreadWorker.ts         |  2 +-
 packages/taler-wallet-core/src/db.ts               | 31 ++++++++++++++++++++--
 .../taler-wallet-core/src/operations/exchanges.ts  |  1 +
 .../taler-wallet-core/src/operations/pay-peer.ts   | 14 ++++++++++
 .../src/operations/transactions.ts                 |  2 +-
 5 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts 
b/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts
index d9b4399d6..eaa0108bb 100644
--- a/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts
+++ b/packages/taler-wallet-core/src/crypto/workers/nodeThreadWorker.ts
@@ -151,7 +151,7 @@ class NodeThreadCryptoWorker implements CryptoWorker {
         this.onmessage(v);
       }
     });
-    this.nodeWorker.unref();
+    //this.nodeWorker.unref();
   }
 
   /**
diff --git a/packages/taler-wallet-core/src/db.ts 
b/packages/taler-wallet-core/src/db.ts
index 29e97cd90..a7bdda3ec 100644
--- a/packages/taler-wallet-core/src/db.ts
+++ b/packages/taler-wallet-core/src/db.ts
@@ -118,7 +118,7 @@ export const CURRENT_DB_CONFIG_KEY = "currentMainDbName";
  * backwards-compatible way or object stores and indices
  * are added.
  */
-export const WALLET_DB_MINOR_VERSION = 5;
+export const WALLET_DB_MINOR_VERSION = 6;
 
 /**
  * Ranges for operation status fields.
@@ -1795,6 +1795,8 @@ export interface PeerPullPaymentInitiationRecord {
    */
   amount: AmountString;
 
+  estimatedAmountEffective: AmountString;
+
   /**
    * Purse public key.  Used as the primary key to look
    * up this record.
@@ -2606,6 +2608,29 @@ export const walletDbFixups: FixupDescription[] = [
       });
     },
   },
+  {
+    name: "PeerPullPaymentInitiationRecord_estimatedAmountEffective_add",
+    async fn(tx): Promise<void> {
+      await tx.peerPullPaymentInitiations.iter().forEachAsync(async (pi) => {
+        if (pi.estimatedAmountEffective) {
+          return;
+        }
+        pi.estimatedAmountEffective = pi.amount;
+        await tx.peerPullPaymentInitiations.put(pi);
+      });
+    },
+  },
+  {
+    name: "PeerPushPaymentInitiationRecord_ALL_removeLegacyTx",
+    async fn(tx): Promise<void> {
+      await tx.peerPushPaymentInitiations.iter().forEachAsync(async (pi) => {
+        // Remove legacy transactions that don't have the totalCost field yet.
+        if (!pi.totalCost) {
+          await tx.peerPushPaymentInitiations.delete(pi.pursePub);
+        }
+      });
+    },
+  },
 ];
 
 const logger = new Logger("db.ts");
@@ -2613,11 +2638,13 @@ const logger = new Logger("db.ts");
 export async function applyFixups(
   db: DbAccess<typeof WalletStoresV1>,
 ): Promise<void> {
+  logger.trace("applying fixups");
   await db.mktxAll().runReadWrite(async (tx) => {
     for (const fixupInstruction of walletDbFixups) {
+      logger.trace(`checking fixup ${fixupInstruction.name}`);
       const fixupRecord = await tx.fixups.get(fixupInstruction.name);
       if (fixupRecord) {
-        return;
+        continue;
       }
       logger.info(`applying DB fixup ${fixupInstruction.name}`);
       await fixupInstruction.fn(tx);
diff --git a/packages/taler-wallet-core/src/operations/exchanges.ts 
b/packages/taler-wallet-core/src/operations/exchanges.ts
index 457344e06..8a98c8299 100644
--- a/packages/taler-wallet-core/src/operations/exchanges.ts
+++ b/packages/taler-wallet-core/src/operations/exchanges.ts
@@ -260,6 +260,7 @@ async function validateWireInfo(
       throw Error("exchange acct signature invalid");
     }
   }
+  logger.trace("account validation done");
   const feesForType: WireFeeMap = {};
   for (const wireMethod of Object.keys(wireInfo.fees)) {
     const feeList: WireFee[] = [];
diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts 
b/packages/taler-wallet-core/src/operations/pay-peer.ts
index 541e96280..05338b83e 100644
--- a/packages/taler-wallet-core/src/operations/pay-peer.ts
+++ b/packages/taler-wallet-core/src/operations/pay-peer.ts
@@ -1580,6 +1580,8 @@ export async function checkPeerPullPaymentInitiation(
   // Select an exchange where we have money in the specified currency
   // FIXME: How do we handle regional currency scopes here? Is it an 
additional input?
 
+  logger.trace("checking peer-pull-credit fees");
+
   const currency = Amounts.currencyOf(req.amount);
   let exchangeUrl;
   if (req.exchangeBaseUrl) {
@@ -1592,6 +1594,8 @@ export async function checkPeerPullPaymentInitiation(
     throw Error("no exchange found for initiating a peer pull payment");
   }
 
+  logger.trace(`found ${exchangeUrl} as preferred exchange`);
+
   const wi = await getExchangeWithdrawalInfo(
     ws,
     exchangeUrl,
@@ -1599,6 +1603,8 @@ export async function checkPeerPullPaymentInitiation(
     undefined,
   );
 
+  logger.trace(`got withdrawal info`);
+
   return {
     exchangeBaseUrl: exchangeUrl,
     amountEffective: wi.withdrawalAmountEffective,
@@ -1649,6 +1655,13 @@ export async function initiatePeerPullPayment(
   const mergeReserveRowId = mergeReserveInfo.rowId;
   checkDbInvariant(!!mergeReserveRowId);
 
+  const wi = await getExchangeWithdrawalInfo(
+    ws,
+    exchangeBaseUrl,
+    Amounts.parseOrThrow(req.partialContractTerms.amount),
+    undefined,
+  );
+
   await ws.db
     .mktx((x) => [x.peerPullPaymentInitiations, x.contractTerms])
     .runReadWrite(async (tx) => {
@@ -1667,6 +1680,7 @@ export async function initiatePeerPullPayment(
         contractPriv: contractKeyPair.priv,
         contractPub: contractKeyPair.pub,
         withdrawalGroupId,
+        estimatedAmountEffective: wi.withdrawalAmountEffective,
       });
       await tx.contractTerms.put({
         contractTermsRaw: contractTerms,
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index 764115cef..54fe1320d 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -542,7 +542,7 @@ function buildTransactionForPeerPullCredit(
 
   return {
     type: TransactionType.PeerPullCredit,
-    amountEffective: Amounts.stringify(peerContractTerms.amount),
+    amountEffective: Amounts.stringify(pullCredit.amount),
     amountRaw: Amounts.stringify(peerContractTerms.amount),
     exchangeBaseUrl: pullCredit.exchangeBaseUrl,
     extendedStatus: ExtendedStatus.Pending,

-- 
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]