From d4fda1eea86ef901d125078f1f4fe0fe4a141afb Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 20 Feb 2023 03:22:43 +0100 Subject: wallet-core: raw/effective amount for push transactions, fix transactions list for push/pull credit --- packages/taler-wallet-core/src/db.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'packages/taler-wallet-core/src/db.ts') diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 5f7a6a4c4..7e1906351 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -1850,6 +1850,8 @@ export interface PeerPushPaymentIncomingRecord { timestamp: TalerProtocolTimestamp; + estimatedAmountEffective: AmountString; + /** * Hash of the contract terms. Also * used to look up the contract terms in the DB. @@ -1865,6 +1867,14 @@ export interface PeerPushPaymentIncomingRecord { * Associated withdrawal group. */ withdrawalGroupId: string | undefined; + + /** + * Currency of the peer push payment credit transaction. + * + * Mandatory in current schema version, optional for compatibility + * with older (ver_minor<4) DB versions. + */ + currency: string | undefined; } export enum PeerPullPaymentIncomingStatus { @@ -2567,6 +2577,25 @@ export const walletDbFixups: FixupDescription[] = [ }); }, }, + { + name: "PeerPushPaymentIncomingRecord_totalCostEstimated_add", + async fn(tx): Promise { + await tx.peerPushPaymentIncoming.iter().forEachAsync(async (pi) => { + if (pi.estimatedAmountEffective) { + return; + } + const contractTerms = await tx.contractTerms.get(pi.contractTermsHash); + if (!contractTerms) { + // Not sure what we can do here! + } else { + // Not really the cost, but a good substitute for older transactions + // that don't sture the effective cost of the transaction. + pi.estimatedAmountEffective = contractTerms.contractTermsRaw.amount; + await tx.peerPushPaymentIncoming.put(pi); + } + }); + }, + }, ]; const logger = new Logger("db.ts"); -- cgit v1.2.3