gnunet-svn
[Top][All Lists]
Advanced

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

[taler-wallet-core] branch master updated: -deletion


From: gnunet
Subject: [taler-wallet-core] branch master updated: -deletion
Date: Mon, 20 Feb 2023 03:56:52 +0100

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

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

The following commit(s) were added to refs/heads/master by this push:
     new a6d78f12d -deletion
a6d78f12d is described below

commit a6d78f12df0bf42838f424e889f376ca19bfd96c
Author: Florian Dold <florian@dold.me>
AuthorDate: Mon Feb 20 03:56:43 2023 +0100

    -deletion
---
 .../taler-wallet-core/src/operations/common.ts     |  2 +
 .../src/operations/transactions.ts                 | 69 ++++++++++++++++++++--
 2 files changed, 66 insertions(+), 5 deletions(-)

diff --git a/packages/taler-wallet-core/src/operations/common.ts 
b/packages/taler-wallet-core/src/operations/common.ts
index 2db5cd7b4..35e6455bc 100644
--- a/packages/taler-wallet-core/src/operations/common.ts
+++ b/packages/taler-wallet-core/src/operations/common.ts
@@ -338,6 +338,8 @@ export enum TombstoneTag {
   DeleteRefund = "delete-refund",
   DeletePeerPullDebit = "delete-peer-pull-debit",
   DeletePeerPushDebit = "delete-peer-push-debit",
+  DeletePeerPullCredit = "delete-peer-pull-credit",
+  DeletePeerPushCredit = "delete-peer-push-credit",
 }
 
 /**
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts 
b/packages/taler-wallet-core/src/operations/transactions.ts
index faac808b1..9ee1c1e74 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -1413,11 +1413,70 @@ export async function deleteTransaction(
 ): Promise<void> {
   const { type, args: rest } = parseId("txn", transactionId);
 
-  if (
-    type === TransactionType.Withdrawal ||
-    type === TransactionType.PeerPullCredit ||
-    type === TransactionType.PeerPushCredit
-  ) {
+  if (type === TransactionType.PeerPushCredit) {
+    const peerPushPaymentIncomingId = rest[0];
+    await ws.db
+      .mktx((x) => [
+        x.withdrawalGroups,
+        x.peerPushPaymentIncoming,
+        x.tombstones,
+      ])
+      .runReadWrite(async (tx) => {
+        const pushInc = await tx.peerPushPaymentIncoming.get(
+          peerPushPaymentIncomingId,
+        );
+        if (!pushInc) {
+          return;
+        }
+        if (pushInc.withdrawalGroupId) {
+          const withdrawalGroupId = pushInc.withdrawalGroupId;
+          const withdrawalGroupRecord = await tx.withdrawalGroups.get(
+            withdrawalGroupId,
+          );
+          if (withdrawalGroupRecord) {
+            await tx.withdrawalGroups.delete(withdrawalGroupId);
+            await tx.tombstones.put({
+              id: TombstoneTag.DeleteWithdrawalGroup + ":" + withdrawalGroupId,
+            });
+          }
+        }
+        await tx.peerPushPaymentIncoming.delete(peerPushPaymentIncomingId);
+        await tx.tombstones.put({
+          id:
+            TombstoneTag.DeletePeerPushCredit + ":" + 
peerPushPaymentIncomingId,
+        });
+      });
+  } else if (type === TransactionType.PeerPullCredit) {
+    const pursePub = rest[0];
+    await ws.db
+      .mktx((x) => [
+        x.withdrawalGroups,
+        x.peerPullPaymentInitiations,
+        x.tombstones,
+      ])
+      .runReadWrite(async (tx) => {
+        const pullIni = await tx.peerPullPaymentInitiations.get(pursePub);
+        if (!pullIni) {
+          return;
+        }
+        if (pullIni.withdrawalGroupId) {
+          const withdrawalGroupId = pullIni.withdrawalGroupId;
+          const withdrawalGroupRecord = await tx.withdrawalGroups.get(
+            withdrawalGroupId,
+          );
+          if (withdrawalGroupRecord) {
+            await tx.withdrawalGroups.delete(withdrawalGroupId);
+            await tx.tombstones.put({
+              id: TombstoneTag.DeleteWithdrawalGroup + ":" + withdrawalGroupId,
+            });
+          }
+        }
+        await tx.peerPullPaymentInitiations.delete(pursePub);
+        await tx.tombstones.put({
+          id: TombstoneTag.DeletePeerPullCredit + ":" + pursePub,
+        });
+      });
+  } else if (type === TransactionType.Withdrawal) {
     const withdrawalGroupId = rest[0];
     await ws.db
       .mktx((x) => [x.withdrawalGroups, x.tombstones])

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