[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] 01/02: wallet-core: fixup for legacy peer-push-debit
From: |
gnunet |
Subject: |
[taler-wallet-core] 01/02: wallet-core: fixup for legacy peer-push-debit transaction |
Date: |
Thu, 23 Feb 2023 16:07:23 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
commit dd9e4555baf3b98478e9ad2b0edf81ea81add5e2
Author: Florian Dold <florian@dold.me>
AuthorDate: Thu Feb 23 15:52:32 2023 +0100
wallet-core: fixup for legacy peer-push-debit transaction
---
packages/taler-wallet-core/src/db.ts | 17 +++++++++++++++--
packages/taler-wallet-core/src/operations/pay-peer.ts | 6 ++++++
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/packages/taler-wallet-core/src/db.ts
b/packages/taler-wallet-core/src/db.ts
index 29e97cd90..630713ee3 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.
@@ -2606,6 +2606,17 @@ export const walletDbFixups: FixupDescription[] = [
});
},
},
+ {
+ 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 +2624,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/pay-peer.ts
b/packages/taler-wallet-core/src/operations/pay-peer.ts
index 541e96280..6a04bce7c 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,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.