From 10aa5e767a35d39d6612f5e4addf4e04f3241a42 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Thu, 13 Jun 2024 18:19:20 +0200 Subject: wallet-core: introduce coin history store, spend coins transactionally --- packages/taler-wallet-core/src/db.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 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 5c381eea7..0ce838fd2 100644 --- a/packages/taler-wallet-core/src/db.ts +++ b/packages/taler-wallet-core/src/db.ts @@ -912,6 +912,27 @@ export interface CoinRecord { ageCommitmentProof: AgeCommitmentProof | undefined; } +export type HistoryItem = + | { + type: "withdraw"; + transactionId: TransactionIdStr; + } + | { type: "spend"; transactionId: TransactionIdStr; amount: AmountString } + | { type: "refresh"; transactionId: TransactionIdStr; amount: AmountString } + | { type: "recoup"; transactionId: TransactionIdStr; amount: AmountString } + | { type: "refund"; transactionId: TransactionIdStr; amount: AmountString }; + +/** + * History event for a coin from the wallet's perspective. + */ +export interface CoinHistoryRecord { + coinPub: string; + + timestamp: DbPreciseTimestamp; + + item: HistoryItem; +} + /** * Coin allocation, i.e. what a coin has been used for. */ @@ -2423,6 +2444,11 @@ export const WalletStoresV1 = { }), }, ), + coinHistory: describeStoreV2({ + storeName: "coinHistory", + recordCodec: passthroughCodec(), + keyPath: ["coinPub", "timestamp"], + }), coins: describeStore( "coins", describeContents({ -- cgit v1.2.3