diff options
Diffstat (limited to 'packages/taler-wallet-core/src/db.ts')
-rw-r--r-- | packages/taler-wallet-core/src/db.ts | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/packages/taler-wallet-core/src/db.ts b/packages/taler-wallet-core/src/db.ts index 75e6408f7..f8fbe2f07 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -54,9 +54,7 @@ import { WireInfo, HashCodeString, Amounts, - AttentionPriority, AttentionInfo, - AbsoluteTime, Logger, CoinPublicKeyString, } from "@gnu-taler/taler-util"; @@ -72,7 +70,6 @@ import { StoreWithIndexes, } from "./util/query.js"; import { RetryInfo, RetryTags } from "./util/retries.js"; -import { Wallet } from "./wallet.js"; /** * This file contains the database schema of the Taler wallet together @@ -121,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 = 3; +export const WALLET_DB_MINOR_VERSION = 4; /** * Ranges for operation status fields. @@ -539,6 +536,13 @@ export interface ExchangeRecord { baseUrl: string; /** + * When did we confirm the last withdrawal from this exchange? + * + * Used mostly in the UI to suggest exchanges. + */ + lastWithdrawal?: TalerProtocolTimestamp; + + /** * Pointer to the current exchange details. * * Should usually not change. Only changes when the @@ -1852,6 +1856,20 @@ export enum PeerPullPaymentIncomingStatus { Paid = 50 /* DORMANT_START */, } +export interface PeerPullPaymentCoinSelection { + contributions: AmountString[]; + coinPubs: CoinPublicKeyString[]; + + /** + * Total cost based on the coin selection. + * Non undefined after status === "Accepted" + */ + totalCost: AmountString | undefined; +} + +/** + * AKA PeerPullDebit. + */ export interface PeerPullPaymentIncomingRecord { peerPullPaymentIncomingId: string; @@ -1863,6 +1881,9 @@ export interface PeerPullPaymentIncomingRecord { timestampCreated: TalerProtocolTimestamp; + /** + * Contract priv that we got from the other party. + */ contractPriv: string; /** @@ -1871,10 +1892,11 @@ export interface PeerPullPaymentIncomingRecord { status: PeerPullPaymentIncomingStatus; /** - * Total cost based on the coin selection. - * Non undefined after status === "Accepted" + * Estimated total cost when the record was created. */ - totalCost: AmountString | undefined; + totalCostEstimated: AmountString; + + coinSel?: PeerPullPaymentCoinSelection; } /** @@ -2251,6 +2273,14 @@ export const WalletStoresV1 = { "exchangeBaseUrl", "pursePub", ]), + byExchangeAndContractPriv: describeIndex( + "byExchangeAndContractPriv", + ["exchangeBaseUrl", "contractPriv"], + { + versionAdded: 4, + unique: true, + }, + ), byStatus: describeIndex("byStatus", "status"), }, ), @@ -2484,6 +2514,20 @@ export const walletDbFixups: FixupDescription[] = [ }); }, }, + { + name: "PeerPullPaymentIncomingRecord_totalCostEstimated_add", + async fn(tx): Promise<void> { + await tx.peerPullPaymentIncoming.iter().forEachAsync(async (pi) => { + if (pi.totalCostEstimated) { + return; + } + // Not really the cost, but a good substitute for older transactions + // that don't sture the effective cost of the transaction. + pi.totalCostEstimated = pi.contractTerms.amount; + await tx.peerPullPaymentIncoming.put(pi); + }); + }, + }, ]; const logger = new Logger("db.ts"); |